/* ═══════════════════════════════════════════════════
   CRM SaaS Design System v2.0
   Professional Multi-tenant Annotation Platform
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* ── Color Palette ── */
    --bg-base: #0f1117;
    --bg-surface: #161922;
    --bg-elevated: #1c1f2e;
    --bg-hover: #232738;
    --bg-active: #2a2f42;
    --bg-input: #1a1d2b;

    --border-subtle: rgba(255,255,255,0.06);
    --border-default: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.12);
    --border-focus: rgba(99,102,241,0.5);

    --text-primary: #f1f3f9;
    --text-secondary: #8b8fa7;
    --text-muted: #5c6078;
    --text-inverse: #0f1117;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-primary-bg: rgba(99,102,241,0.12);
    --accent-primary-border: rgba(99,102,241,0.25);

    --accent-success: #10b981;
    --accent-success-bg: rgba(16,185,129,0.12);
    --accent-success-border: rgba(16,185,129,0.25);

    --accent-warning: #f59e0b;
    --accent-warning-bg: rgba(245,158,11,0.12);
    --accent-warning-border: rgba(245,158,11,0.25);

    --accent-danger: #ef4444;
    --accent-danger-bg: rgba(239,68,68,0.12);
    --accent-danger-border: rgba(239,68,68,0.25);

    --accent-info: #06b6d4;
    --accent-info-bg: rgba(6,182,212,0.12);

    /* ── Layout ── */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* ── Shadows ── */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.35);
    --shadow-glow: 0 0 20px rgba(99,102,241,0.15);

    /* ── Transitions ── */
    --transition-fast: 0.15s cubic-bezier(0.4,0,0.2,1);
    --transition-base: 0.2s cubic-bezier(0.4,0,0.2,1);
    --transition-slow: 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    min-height: 100vh;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ── Admin Layout ── */
.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    overflow-y: auto;
    z-index: 100;
}

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

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-title { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.01em; }
.brand-subtitle { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Navigation */
.nav { padding: 12px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-group-label {
    padding: 16px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    transition: var(--transition-fast);
    cursor: pointer;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-item.is-active {
    color: var(--accent-primary-hover);
    background: var(--accent-primary-bg);
}

.nav-item .nav-icon {
    width: 28px;
    height: 28px;
    padding: 5px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.04);
    opacity: 0.8;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.nav-item:hover .nav-icon {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
}

.nav-item.is-active .nav-icon {
    opacity: 1;
    background: rgba(99,102,241,0.14);
    border-color: rgba(99,102,241,0.2);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
}

.sidebar-user-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-success);
    box-shadow: 0 0 6px rgba(16,185,129,0.4);
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ── Main Panel ── */
.main-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-base);
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-height);
    padding: 0 32px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Site Switcher */
.site-switcher { display: flex; align-items: center; gap: 8px; }

.site-switcher select {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-primary);
    min-width: 160px;
    outline: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.site-switcher select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.site-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Content Area ── */
.content {
    padding: 28px 32px 40px;
    flex: 1;
}

/* ── Status Banner ── */
.status-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
}

.status-banner.ok {
    background: var(--accent-success-bg);
    border: 1px solid var(--accent-success-border);
    color: var(--accent-success);
}

.status-banner.warn {
    background: var(--accent-warning-bg);
    border: 1px solid var(--accent-warning-border);
    color: var(--accent-warning);
}

.status-banner.danger {
    background: var(--accent-danger-bg);
    border: 1px solid var(--accent-danger-border);
    color: var(--accent-danger);
}

.status-banner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    animation: pulse-dot 2s infinite;
}

.status-banner-icon {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    font-size: 14px;
    flex-shrink: 0;
}

.status-banner-text {
    flex: 1;
    min-width: 0;
}

.status-banner-close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    opacity: 0.8;
}

.status-banner-close:hover {
    opacity: 1;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Cards ── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition-base);
}

.card:hover {
    border-color: var(--border-strong);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.card-collapsible {
    padding: 0;
    overflow: hidden;
}

.card-collapse-trigger {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
}

.card-collapse-trigger::-webkit-details-marker {
    display: none;
}

.card-collapse-trigger::after {
    content: '展开';
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.card-collapsible[open] .card-collapse-trigger::after {
    content: '收起';
}

.card-collapse-content {
    padding: 0 24px 24px;
}

/* ── Grid Layouts ── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ── Stat Cards ── */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.06;
}

.stat-card.primary::after { background: var(--accent-primary); }
.stat-card.success::after { background: var(--accent-success); }
.stat-card.warning::after { background: var(--accent-warning); }
.stat-card.danger::after { background: var(--accent-danger); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    margin-top: 12px;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-card.primary .stat-value { color: var(--accent-primary-hover); }
.stat-card.success .stat-value { color: var(--accent-success); }
.stat-card.warning .stat-value { color: var(--accent-warning); }
.stat-card.danger .stat-value { color: var(--accent-danger); }

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    white-space: nowrap;
    outline: none;
    appearance: none;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(99,102,241,0.3);
}

.btn.primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
    transform: translateY(-1px);
}

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

.btn.ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn.danger {
    background: var(--accent-danger);
    color: #fff;
}

.btn.danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.full-width { width: 100%; }

/* ── Forms ── */
.form-stack { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.field-input,
.field select,
.field input,
.field textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.field textarea { resize: vertical; min-height: 120px; }

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.checkbox-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.password-field {
    display: flex;
    gap: 8px;
}

.password-field input { flex: 1; }

.inline-copy-field {
    display: flex;
    gap: 8px;
}

.inline-copy-field input {
    flex: 1;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

.table th {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-elevated);
}

.table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.table td { font-size: 13px; color: var(--text-secondary); }

.table tbody tr { transition: var(--transition-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table-row-current { background: var(--accent-primary-bg) !important; }
.table-strong { font-weight: 600; color: var(--text-primary); }

/* ── Tags & Badges ── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tag.success { background: var(--accent-success-bg); color: var(--accent-success); border: 1px solid var(--accent-success-border); }
.tag.warning { background: var(--accent-warning-bg); color: var(--accent-warning); border: 1px solid var(--accent-warning-border); }
.tag.danger { background: var(--accent-danger-bg); color: var(--accent-danger); border: 1px solid var(--accent-danger-border); }
.tag.info { background: var(--accent-info-bg); color: var(--accent-info); border: 1px solid rgba(6,182,212,0.25); }
.tag.default { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-default); }

/* ── Progress ── */
.progress-card { display: flex; flex-direction: column; gap: 16px; }

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.progress-bar {
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-primary-hover));
    transition: width 0.5s ease;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.progress-stats > div {
    text-align: center;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
}

.progress-stats span { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.progress-stats strong { font-size: 18px; font-weight: 700; color: var(--text-primary); }

/* ── Code / Log Preview ── */
.code-preview {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    max-height: 400px;
    overflow-y: auto;
}

/* ── Detail / Info Panels ── */
.info-list { display: flex; flex-direction: column; gap: 1px; }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    font-size: 13px;
}

.info-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.info-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }

.info-row span { color: var(--text-muted); }
.info-row strong { color: var(--text-primary); font-weight: 600; }

/* ── Schedule Cards ── */
.schedule-list { display: flex; flex-direction: column; gap: 8px; }

.schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    transition: var(--transition-fast);
}

.schedule-item:hover { border-color: var(--border-strong); }

.schedule-title { font-weight: 600; font-size: 14px; color: var(--text-primary); }

.schedule-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Alert Notes ── */
.alert-note {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
}

.alert-note.warning {
    background: var(--accent-warning-bg);
    border: 1px solid var(--accent-warning-border);
    color: var(--accent-warning);
}

.alert-note.danger {
    background: var(--accent-danger-bg);
    border: 1px solid var(--accent-danger-border);
    color: var(--accent-danger);
}

.alert-note.info {
    background: var(--accent-primary-bg);
    border: 1px solid var(--accent-primary-border);
    color: var(--accent-primary-hover);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Chart ── */
.chart-shell { height: 280px; position: relative; }

/* ── Actions Row ── */
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.dashboard-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
    gap: 20px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
    gap: 20px;
}

.dashboard-hero {
    background:
        radial-gradient(circle at top right, rgba(99,102,241,0.18), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.02), transparent 100%),
        var(--bg-surface);
}

.dashboard-kicker {
    font-size: 12px;
    color: var(--accent-primary-hover);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.dashboard-hero-text {
    max-width: 680px;
}

.dashboard-hero-text h2 {
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
}

.dashboard-hero-text p {
    color: var(--text-secondary);
    max-width: 620px;
}

.focus-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.focus-metric {
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
}

.focus-metric-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.focus-metric-value {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.focus-list {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.focus-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

.focus-item-label {
    color: var(--text-muted);
    font-size: 12px;
}

.focus-item-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

.onboarding-card {
    border-color: rgba(99,102,241,0.22);
    background:
        linear-gradient(180deg, rgba(99,102,241,0.08), rgba(99,102,241,0.02)),
        var(--bg-surface);
}

.onboarding-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
}

.onboarding-step-index {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(99,102,241,0.16);
    color: var(--accent-primary-hover);
    font-weight: 800;
    flex-shrink: 0;
}

.onboarding-step strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.dashboard-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-feed-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}

.dashboard-feed-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.dashboard-feed-title {
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-feed-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.dashboard-feed-text {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-stack {
    display: grid;
    gap: 12px;
}

.detail-card {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

.detail-card-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.detail-card-content {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-stream {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.log-stream-empty {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.log-line {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 13px;
}

.log-line-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    margin-top: 6px;
    flex-shrink: 0;
    background: var(--text-muted);
}

.log-line.success .log-line-dot { background: var(--accent-success); }
.log-line.warning .log-line-dot { background: var(--accent-warning); }
.log-line.danger .log-line-dot { background: var(--accent-danger); }

.toast {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.toast-body {
    flex: 1;
    min-width: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.toast-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Login Page ── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.login-body::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.08), transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(168,85,247,0.06), transparent 50%);
    animation: login-bg 20s ease infinite;
}

@keyframes login-bg {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, -1%); }
}

.login-shell {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 36px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-heading {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.login-subtext {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ── Toast Notifications ── */
#toast-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10000;
}

.toast {
    min-width: 260px;
    max-width: 380px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
}

.toast.success { border-left: 3px solid var(--accent-success); }
.toast.error { border-left: 3px solid var(--accent-danger); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 14px; }

/* ── Loading Spinner ── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

/* ── Responsive ── */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .form-row.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .dashboard-shell,
    .dashboard-grid,
    .onboarding-steps { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-default);
    }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
    .progress-stats { grid-template-columns: repeat(3, 1fr); }
    .focus-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .card { padding: 18px; }
    .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; }
    .progress-stats { grid-template-columns: repeat(2, 1fr); }
    .card-collapse-trigger,
    .card-collapse-content { padding-left: 18px; padding-right: 18px; }
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Config Display ── */
.config-list { display: flex; flex-direction: column; gap: 1px; }
.config-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-elevated);
}
.config-row:first-child { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.config-row:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.config-key { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.config-value { color: var(--text-secondary); font-size: 13px; text-align: right; max-width: 50%; word-break: break-all; }

/* ── Section margin helper ── */
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.muted { color: var(--text-muted); font-size: 13px; }
.text-sm { font-size: 13px; }
