/* Schema Sentinel — Global Styles
   Design: Dark sidebar, warm neutrals, indigo accent, refined typography */

/* ==================== Design Tokens ====================  */

:root {
    /* Brand / Accent */
    --color-primary: #4f46e5;
    --color-primary-light: #6366f1;
    --color-primary-dark: #3730a3;
    --color-primary-bg: rgba(79, 70, 229, 0.08);
    --color-primary-solid-bg: #eeedf9;
    --color-primary-ring: rgba(79, 70, 229, 0.25);
    --activity-h: 0px;

    /* Semantic */
    --color-success: #059669;
    --color-success-light: #d1fae5;
    --color-warning: #d97706;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;
    --color-info: #2563eb;
    --color-info-light: #dbeafe;

    /* Neutrals (warm-shifted) */
    --color-text: #18181b;
    --color-text-secondary: #52525b;
    --color-text-tertiary: #a1a1aa;
    --color-border: #e4e4e7;
    --color-border-light: #f4f4f5;
    --color-bg: #fafaf9;
    --color-bg-elevated: #ffffff;
    --color-bg-sunken: #f4f4f5;

    /* Sidebar (dark) */
    --sidebar-bg: #1e1b4b;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.08);
    --sidebar-bg-active: rgba(255, 255, 255, 0.12);
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 260px;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
}

/* ==================== Reset & Base ====================  */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* background/color/font-family/font-size handled by tokens.css on html[data-theme]
       so the Portcullis theme stays in charge. */
    line-height: var(--leading-normal);
}

/* ==================== Layout ====================  */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==================== Dark Sidebar ====================  */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e1b4b 0%, #1a1744 100%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--sidebar-text-active);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s ease;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    gap: 10px;
}

.nav-link:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.125rem;
    display: inline-flex;
    width: 20px;
    justify-content: center;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.user-badge {
    background-color: rgba(255, 255, 255, 0.06);
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--sidebar-text-active);
    font-size: var(--text-sm);
}

.user-email {
    font-size: var(--text-xs);
    color: var(--sidebar-text);
    margin-bottom: var(--spacing-sm);
    overflow: hidden;
    text-overflow: ellipsis;
}

.role-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.admin {
    background-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.role-badge.editor {
    background-color: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
}

.build-version {
    margin-top: 5px;
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.04em;
}

.logout-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--text-sm);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s ease;
}

.logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text-active);
}

/* ==================== Sidebar Toggle ====================  */

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--sidebar-text);
    font-size: 16px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background-color: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .logo-icon {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar-header {
    padding: 16px 12px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar.collapsed .sidebar-footer .user-badge {
    display: none;
}

.sidebar.collapsed .sidebar-footer .logout-btn {
    font-size: 0;
    padding: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer .logout-btn::before {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.7)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E");
    font-size: 18px;
}

.sidebar.collapsed .sidebar-toggle {
    display: flex;
}

/* ==================== Main Content ====================  */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
    background-color: var(--color-bg);
}

/* ==================== Flash Messages ====================  */

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: var(--text-sm);
    font-weight: 500;
    animation: slideIn 0.2s ease;
}

.flash-message.flash-success {
    background-color: var(--color-success-light);
    border-left: 3px solid var(--color-success);
    color: #065f46;
}

.flash-message.flash-error {
    background-color: var(--color-danger-light);
    border-left: 3px solid var(--color-danger);
    color: #991b1b;
}

.flash-message.flash-warning {
    background-color: var(--color-warning-light);
    border-left: 3px solid var(--color-warning);
    color: #92400e;
}

.flash-message.flash-info {
    background-color: var(--color-info-light);
    border-left: 3px solid var(--color-info);
    color: #1e40af;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0;
    margin-left: var(--spacing-md);
    opacity: 0.6;
    transition: opacity 0.15s;
}

.flash-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== Cards ====================  */

.card {
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--spacing-lg);
}

.card.compact {
    padding: var(--spacing-lg);
}

.card-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
}

.card-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.card-subtitle {
    margin: 6px 0 0 0;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* ==================== Status Badges ====================  */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status-badge::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge.ready {
    background-color: var(--color-success-light);
    color: #065f46;
}
.status-badge.ready::before { background-color: var(--color-success); }

.status-badge.incomplete {
    background-color: var(--color-warning-light);
    color: #92400e;
}
.status-badge.incomplete::before { background-color: var(--color-warning); }

.status-badge.missing {
    background-color: var(--color-danger-light);
    color: #991b1b;
}
.status-badge.missing::before { background-color: var(--color-danger); }

.status-badge.unmanaged {
    background-color: var(--color-info-light);
    color: #1e40af;
}
.status-badge.unmanaged::before { background-color: var(--color-info); }

/* Overlay flag icons (stale / deployed) */
.flag-stale { color: var(--color-warning); font-weight: bold; margin-left: 4px; }
.flag-deployed { color: var(--color-success); font-weight: bold; margin-left: 4px; }
.flag-not-deployed { color: var(--color-danger); font-weight: bold; margin-left: 4px; }
.flag-stale svg, .flag-deployed svg, .flag-not-deployed svg { vertical-align: middle; display: inline-block; }

/* Health badge: stale */
.health-count.stale { background-color: var(--color-warning); }

/* ==================== Forms ====================  */

.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--color-text);
    background-color: var(--color-bg-elevated);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-tertiary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ==================== Buttons ====================  */

button,
.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background-color: var(--color-primary-dark);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background-color: var(--color-bg-elevated);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background-color: var(--color-bg-sunken);
    border-color: #d4d4d8;
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-ghost {
    background: none;
    color: var(--color-text-secondary);
    border: none;
}

.btn-ghost:hover {
    background-color: var(--color-bg-sunken);
    color: var(--color-text);
}

.btn-sm {
    padding: 5px 10px;
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== Tables ====================  */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
}

th {
    background-color: var(--color-bg-sunken);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--color-border);
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
}

tbody tr {
    transition: background-color 0.1s ease;
}

tbody tr:hover {
    background-color: var(--color-bg-sunken);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ==================== Progress Bar ====================  */

.progress-bar-wrap {
    width: 100%;
    height: 6px;
    background-color: var(--color-border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: var(--radius-full);
}

/* ==================== Details/Collapsible ====================  */

details {
    margin-bottom: var(--spacing-lg);
}

summary {
    cursor: pointer;
    padding: 10px 14px;
    background-color: var(--color-bg-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--text-sm);
    user-select: none;
    transition: all 0.15s ease;
}

summary:hover {
    background-color: var(--color-border-light);
}

details[open] summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

details > *:not(summary) {
    padding: var(--spacing-md);
    border: 1px solid var(--color-border);
    border-top: none;
}

/* ==================== Utilities ====================  */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-secondary); }

.mt-0 { margin-top: 0; }
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-col { flex-direction: column; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--spacing-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--spacing-lg); }

/* ==================== Page Layout ====================  */

.page-container {
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: var(--spacing-xl);
}

.page-title {
    margin: 0 0 4px 0;
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.025em;
    line-height: var(--leading-tight);
}

.page-subtitle {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-tertiary);
}

/* ==================== Health Badges ====================  */

.health-badges {
    display: flex;
    gap: 12px;
}

.health-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.health-count {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-lg);
    color: white;
}

.health-count.ready { background-color: var(--color-success); }
.health-count.incomplete { background-color: var(--color-warning); }
.health-count.missing { background-color: var(--color-danger); }

.health-label {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ==================== Monitor Page ====================  */

.sitemaps-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sitemap-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    padding: 14px 16px;
    background-color: var(--color-bg-sunken);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    transition: all 0.15s ease;
}

.sitemap-row:hover {
    background-color: var(--color-bg-elevated);
    border-color: var(--color-border);
    box-shadow: var(--shadow-xs);
}

.sitemap-url {
    flex: 1;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--color-text);
    word-break: break-all;
}

.sitemap-count {
    padding: 4px 10px;
    background-color: var(--color-primary-bg);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-xs);
    white-space: nowrap;
}

.sitemap-actions {
    display: flex;
    gap: 6px;
}

.button-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-popover {
    position: relative;
    display: inline-flex;
    align-self: stretch;
}

.action-popover summary {
    list-style: none;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    height: 100%;
    box-sizing: border-box;
}

.action-popover summary::marker,
.action-popover summary::-webkit-details-marker {
    display: none;
}

.popover-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    z-index: 100;
    margin-top: 4px;
    padding: 4px;
    overflow: hidden;
}

.popover-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    transition: background-color 0.1s ease;
}

.popover-item:hover {
    background-color: var(--color-bg-sunken);
}

/* ==================== Page Detail Panel ====================  */

.page-detail-header {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.page-detail-title {
    margin: 0 0 var(--spacing-sm) 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    font-family: var(--font-mono);
    word-break: break-all;
}

.page-status {
    display: inline-block;
    margin-top: var(--spacing-sm);
}

.page-detail-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--spacing-lg);
}

.tab-button {
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tab-button:hover {
    color: var(--color-text);
}

.tab-button.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    position: relative;
}

.tab-pane {
    display: none;
    opacity: 0;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.audit-errors {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.audit-error {
    padding: 10px 14px;
    background-color: var(--color-danger-light);
    border-left: 3px solid var(--color-danger);
    color: #991b1b;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.page-history {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.history-entry {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
}

.history-entry:last-child {
    border-bottom: none;
}

.history-date {
    font-weight: 600;
    color: var(--color-text);
}

.history-action {
    margin-top: var(--spacing-xs);
    font-size: var(--text-xs);
}

/* ==================== Sort Headers ====================  */

.sort-header {
    cursor: pointer;
    user-select: none;
}

.sort-header:hover {
    color: var(--color-primary);
}

.sort-arrow {
    font-size: 10px;
    margin-left: 2px;
}

/* ==================== Button loading spinner ====================  */

button:disabled .spinner {
    width: 12px;
    height: 12px;
}

/* ==================== Sticky Table Header ====================  */

#pages-table {
    table-layout: fixed;
    width: 100%;
}

#pages-table thead th:nth-child(1) { width: 36px; }   /* Checkbox */
#pages-table thead th:nth-child(2) { width: 140px; }  /* Status */
#pages-table thead th:nth-child(4) { width: 90px; }   /* Type */
#pages-table thead th:nth-child(5) { width: 100px; }  /* Actions */

#pages-table thead th {
    position: sticky;
    top: var(--activity-h);
    z-index: 10;
    background-color: var(--color-bg-sunken);
}

/* Detail expansion row must not affect column widths */
#detail-expansion-row td {
    overflow: hidden;
}

.detail-panel-inner {
    max-width: 100%;
    overflow: hidden;
}

.detail-panel-inner .json-viewer {
    word-break: break-all;
}

/* ==================== Activity Panel ====================  */

#activity-panel {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-bottom: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--color-primary-solid-bg);
    color: var(--color-primary-dark);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    animation: slideIn 0.2s ease;
}
#activity-panel .activity-top {
    display: flex;
    align-items: center;
    gap: 10px;
}
#activity-panel .activity-msg { flex: 1; }
#activity-panel .activity-counter { font-weight: 600; font-size: 12px; color: var(--color-text-secondary); white-space: nowrap; }
#activity-panel .activity-close { background: none; border: none; cursor: pointer; color: var(--color-text-tertiary); font-size: 16px; padding: 0 4px; }
.activity-bar-wrap { width: 100%; height: 4px; background: var(--color-border-light); border-radius: 2px; margin-top: 6px; }
.activity-bar { height: 100%; background: var(--color-primary); border-radius: 2px; transition: width 0.3s ease; width: 0%; }
.activity-bar.done { background: var(--color-success); }

/* ==================== Filter Chip ====================  */

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background-color: var(--color-primary-bg);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    animation: slideIn 0.2s ease;
}

.filter-chip-close {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.filter-chip-close:hover {
    opacity: 1;
}

.sitemap-row.active-sitemap {
    border-color: var(--color-primary);
    background-color: var(--color-primary-bg);
    box-shadow: inset 3px 0 0 var(--color-primary);
}

/* ==================== Detail Panel Transition ====================  */

.detail-panel-inner {
    animation: detailSlideDown 0.25s ease;
}

@keyframes detailSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Detail panel inline tabs */
.detail-tab {
    padding: 8px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.detail-tab:hover {
    color: var(--color-text);
}

.detail-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ==================== Model List ====================  */

.model-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background-color: var(--color-bg-sunken);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
    font-family: var(--font-mono);
}

.model-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-badge.primary {
    background-color: var(--color-primary-bg);
    color: var(--color-primary);
    font-family: var(--font-sans);
}

/* ==================== LLM Files ====================  */

.llm-file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--color-bg-elevated);
}

.llm-file-row:last-child {
    margin-bottom: 0;
}

/* ==================== Progress Modal Improvements ====================  */

.progress-counters {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.progress-counter {
    display: flex;
    align-items: center;
    gap: 4px;
}

.progress-counter.success { color: var(--color-success); }
.progress-counter.skipped { color: var(--color-warning); }
.progress-counter.errors { color: var(--color-danger); }

.log-line-success { color: #34d399; }
.log-line-skip { color: #fbbf24; }
.log-line-error { color: #f87171; }

/* ==================== Empty States ====================  */

.empty-state-container {
    padding: 64px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    background-color: var(--color-primary-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon svg {
    width: 44px;
    height: 44px;
    color: var(--color-primary);
}

.empty-state-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.empty-state-desc {
    color: var(--color-text-tertiary);
    margin: 0 0 24px;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

/* ==================== Inline Generate States ====================  */

.btn-inline-success {
    background-color: var(--color-success) !important;
    color: white !important;
    pointer-events: none;
}

/* ==================== Glassmorphism Modals ====================  */

.modal-content {
    backdrop-filter: blur(16px);
    background-color: rgba(255, 255, 255, 0.98);
}

/* ==================== Keyboard Focus ====================  */

tr.row-focused {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    background-color: var(--color-primary-bg) !important;
}

/* ==================== Responsive ====================  */

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        background: linear-gradient(90deg, #1e1b4b 0%, #1a1744 100%);
    }

    .sidebar-header {
        border-bottom: none;
        padding: 12px 16px;
    }

    .sidebar-nav {
        flex: 1;
        padding: 0;
        flex-direction: row;
        align-items: center;
        gap: 0;
    }

    .nav-link {
        padding: 12px 14px;
        border-radius: 0;
    }

    .nav-link.active {
        background-color: var(--sidebar-bg-active);
    }

    .sidebar-footer {
        border-top: none;
        padding: 8px 16px;
    }

    .sidebar.collapsed {
        width: 100%;
    }

    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .sidebar-footer .user-badge {
        display: none;
    }

    .sidebar-toggle {
        display: none;
    }

    .user-badge {
        display: none;
    }

    .main-content {
        padding: 20px 16px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .sitemap-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .sitemap-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .health-badges {
        flex-direction: column;
        gap: 8px;
    }

    .button-group {
        flex-wrap: wrap;
    }
}
