/* ============================================================
   AIDI Admin Dashboard — Component Styles
   Tokens live in design-system.css (loaded before this file)
   ============================================================ */

/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

body.admin-app {
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: 14px;
}

input, select, textarea {
    background: var(--bg-tertiary);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    width: 100%;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

textarea {
    resize: vertical;
    line-height: 1.5;
}

/* ---------- Utility ---------- */
.hidden {
    display: none !important;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-danger {
    background: var(--error);
    color: #fff;
}
.btn-danger:hover {
    background: #c53030;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
}

.btn-full {
    width: 100%;
}

/* Glow variant */
.btn-glow {
    box-shadow: 0 0 20px var(--primary-glow);
}
.btn-glow:hover {
    box-shadow: 0 0 32px var(--primary-glow);
}

/* Icon buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.icon-btn-sm {
    width: 28px;
    height: 28px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-active    { background: var(--success-light); color: var(--success); }
.badge-paused    { background: var(--warning-light); color: var(--warning); }
.badge-removed   { background: var(--error-light); color: var(--error); }
.badge-passed    { background: var(--success-light); color: var(--success); }
.badge-failed    { background: var(--error-light); color: var(--error); }
.badge-in-progress { background: var(--primary-light); color: var(--primary); }
.badge-pending   { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--border); }

/* ============================================================
   LOGIN PAGE — Split-panel redesign
   Left: dark indigo brand panel
   Right: near-black form panel
   Design system tokens:
     --input-h      : 52px    (large inputs)
     --login-left-w : 44%     (left panel width)
   ============================================================ */

/* Design-system tokens for login */
:root {
    --input-h: 52px;
    --login-left-w: 44%;
    --login-left-bg: #1e1b4b;        /* deep indigo */
    --login-left-border: rgba(129, 140, 248, 0.15);
    --login-right-bg: #0d0f1a;       /* near-black */
    --login-form-max: 380px;
}

#page-login {
    min-height: 100vh;
    display: flex;
    position: relative;
    overflow: hidden;
}

#page-login.hidden {
    display: none !important;
}

/* ---- Left (brand) panel ---- */
.login-panel-left {
    width: var(--login-left-w);
    min-width: 320px;
    background: var(--login-left-bg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 48px 52px;
    border-right: 1px solid var(--login-left-border);
    flex-shrink: 0;
}

/* Subtle grid on left panel */
.login-panel-left::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(129, 140, 248, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(129, 140, 248, 0.06) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}

/* Radial glow top-right of left panel */
.login-panel-left::after {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 70%);
    top: -180px;
    right: -160px;
    pointer-events: none;
}

/* Left panel: brand logo at top */
.login-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: auto;
}

.login-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.3);
    border: 1px solid rgba(129, 140, 248, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.login-brand-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #e0e7ff;
}

.login-brand-sub {
    font-size: 11px;
    color: rgba(165, 180, 252, 0.6);
    margin-top: 1px;
    letter-spacing: 0.02em;
}

/* Left panel: headline area (vertically centred in remaining space) */
.login-hero {
    position: relative;
    z-index: 1;
    margin-top: 64px;
    margin-bottom: 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(129, 140, 248, 0.25);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #a5b4fc;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 20px;
    width: fit-content;
}

.login-hero-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #818cf8;
    animation: hero-dot-pulse 2s ease-in-out infinite;
}

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

.login-hero-headline {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.8px;
    line-height: 1.25;
    color: #eef2ff;
    margin-bottom: 16px;
}

.login-hero-headline span {
    color: #818cf8;
}

.login-hero-body {
    font-size: 15px;
    line-height: 1.65;
    color: rgba(165, 180, 252, 0.7);
    max-width: 340px;
}

/* Left panel: feature list */
.login-features {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 48px;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(165, 180, 252, 0.75);
}

.login-feature-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.25);
    border: 1px solid rgba(129, 140, 248, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #818cf8;
}

/* Left panel footer */
.login-left-footer {
    position: relative;
    z-index: 1;
    font-size: 11px;
    color: rgba(165, 180, 252, 0.35);
    letter-spacing: 0.01em;
}

/* Decorative orbs inside left panel */
.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.login-orb-1 {
    width: 300px;
    height: 300px;
    background: rgba(99, 102, 241, 0.18);
    bottom: 60px;
    left: -80px;
    animation: orb-drift 8s ease-in-out infinite;
}

.login-orb-2 {
    width: 200px;
    height: 200px;
    background: rgba(129, 140, 248, 0.12);
    top: 40%;
    right: 20px;
    animation: orb-drift 10s ease-in-out infinite reverse;
}

@keyframes orb-drift {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.04); }
}

/* ---- Right (form) panel ---- */
.login-panel-right {
    flex: 1;
    background: var(--login-right-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    position: relative;
}

/* Subtle radial glow bottom-left of right panel */
.login-panel-right::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
    bottom: -200px;
    left: -150px;
    pointer-events: none;
}

/* Form wrapper inside right panel */
.login-form-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: var(--login-form-max);
    display: flex;
    flex-direction: column;
}

/* Form header */
.login-form-header {
    margin-bottom: 32px;
}

.login-form-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6366f1;
    margin-bottom: 10px;
}

.login-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: #f0f0fa;
    margin-bottom: 6px;
    line-height: 1.2;
}

.login-subtitle {
    font-size: 14px;
    color: rgba(152, 152, 176, 0.8);
    line-height: 1.5;
}

/* Error alert */
.auth-error {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.4;
}

/* Login form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form .form-group label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: rgba(228, 228, 237, 0.7);
    display: block;
    margin-bottom: 7px;
    text-transform: uppercase;
}

/* Large inputs */
.login-form .input-wrapper input {
    height: var(--input-h);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    color: #e4e4ed;
    font-size: 14px;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    padding-left: 44px;
    width: 100%;
}

.login-form .input-wrapper input::placeholder {
    color: rgba(107, 107, 130, 0.6);
}

.login-form .input-wrapper input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* Input with icon */
.input-wrapper {
    position: relative;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(107, 107, 130, 0.7);
    pointer-events: none;
    z-index: 1;
}

/* Submit button */
.login-form .btn-full {
    height: var(--input-h);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-top: 8px;
    border-radius: var(--radius);
    background: #6366f1;
    border: none;
    color: #fff;
    transition: background var(--transition), transform 0.1s ease, box-shadow var(--transition);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.login-form .btn-full:hover:not(:disabled) {
    background: #5558e6;
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
}

.login-form .btn-full:active:not(:disabled) {
    transform: translateY(0);
}

/* Form footer line */
.login-footer {
    margin-top: 28px;
    font-size: 11px;
    color: rgba(107, 107, 130, 0.5);
    text-align: center;
}

/* ---- Responsive: stack vertically on mobile ---- */
@media (max-width: 768px) {
    #page-login {
        flex-direction: column;
    }

    .login-panel-left {
        width: 100%;
        min-width: unset;
        padding: 32px 24px;
        min-height: unset;
        border-right: none;
        border-bottom: 1px solid var(--login-left-border);
    }

    .login-hero {
        margin-top: 24px;
        margin-bottom: 20px;
    }

    .login-hero-headline {
        font-size: 24px;
    }

    .login-features {
        display: none;
    }

    .login-hero-body {
        display: none;
    }

    .login-left-footer {
        display: none;
    }

    .login-panel-right {
        padding: 32px 20px 40px;
    }
}

/* Legacy shims (kept for backward compat — no longer rendered) */
.login-bg, .login-grid-overlay, .login-glow, .login-glow-1, .login-glow-2,
.login-container, .login-logo, .login-logo-icon, .login-logo-name,
.login-logo-sub, .login-card, .login-card-header { display: none !important; }

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar-admin {
    height: var(--topbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

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

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

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-brand {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
}

.topbar-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.topbar-user-label {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   APP LAYOUT: SIDEBAR + CONTENT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-h);
}

/* ---------- Sidebar ---------- */
.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 40;
}

.sidebar-section-label {
    padding: 20px 16px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 2px solid transparent;
}

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

.nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
}

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

.sidebar-version {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Main content ---------- */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 28px;
    flex: 1;
    min-width: 0;
}

/* ---------- Page sections ---------- */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

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

.page-title-group {
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text);
    margin-bottom: 3px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* Filter group in page header */
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-select {
    width: auto;
    min-width: 180px;
    padding: 7px 10px;
    font-size: 13px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }
.stat-icon-primary { background: var(--primary-light); color: var(--primary); }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-warning { background: var(--warning-light); color: var(--warning); }
.stat-icon-error   { background: var(--error-light); color: var(--error); }

.stat-card-body {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-value-success { color: var(--success); }
.stat-value-warning { color: var(--warning); }
.stat-value-primary { color: var(--primary); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   ANALYTICS
   ============================================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

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

.chart-card-body {
    padding: 20px;
    position: relative;
    height: 220px;
}

.chart-card-body canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Period tabs */
.period-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.period-tab {
    padding: 5px 12px;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.period-tab.btn-outline {
    background: transparent;
    border: none;
    color: var(--text-muted);
    box-shadow: none;
}

.period-tab.btn-outline:hover {
    background: var(--bg-hover);
    border: none;
    color: var(--text);
    transform: none;
}

.period-tab.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: none;
}

.period-tab.btn-primary:hover {
    background: var(--primary-hover);
    transform: none;
    box-shadow: none;
}

/* ============================================================
   DATA TABLES
   ============================================================ */

.data-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.data-table-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

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

.data-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 11px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    white-space: nowrap;
}

.data-table td {
    font-size: 13px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--bg-hover);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state-admin {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state-admin h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state-admin p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    box-shadow: var(--shadow-xl);
    animation: modal-in 0.2s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-sm {
    max-width: 400px;
}

.modal-lg {
    max-width: 560px;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.97) translateY(-8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header-bar h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.modal-body-pad {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.confirm-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================================
   SETTINGS
   ============================================================ */

.settings-layout {
    max-width: 580px;
}

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.settings-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.settings-card-title {
    font-size: 14px;
    font-weight: 600;
}

.settings-card-body {
    padding: 20px;
}

.settings-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.info-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 16px;
}

/* ============================================================
   DROPZONE
   ============================================================ */

.dropzone {
    border: 2px dashed var(--border);
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    margin-bottom: 16px;
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.dropzone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.dropzone.drag-over .dropzone-icon {
    color: var(--primary);
}

.dropzone-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.dropzone-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

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

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.upload-progress-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* ============================================================
   TOASTS
   ============================================================ */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px 12px 14px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    font-size: 14px;
    animation: slideIn 0.3s ease;
    min-width: 240px;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.toast-success {
    border-color: var(--success);
    color: var(--success);
}

.toast.toast-error {
    border-color: var(--error);
    color: var(--error);
}

.toast.toast-info {
    border-color: var(--primary);
    color: var(--primary);
}

@keyframes slideIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   SCENARIO CHECKBOXES (in create plan modal)
   ============================================================ */

.scenario-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.scenario-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.scenario-list label:last-child {
    border-bottom: none;
}

.scenario-list label:hover {
    background: var(--bg-hover);
}

.scenario-list input[type="checkbox"] {
    width: 14px;
    height: 14px;
    padding: 0;
    flex-shrink: 0;
}

.scenario-placeholder {
    padding: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================================
   COMPATIBILITY — keep old class names working for app.js
   ============================================================ */

/* Analytics period buttons — app.js toggles btn-primary/btn-outline */
.analytics-period.btn-outline {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: calc(var(--radius-sm) - 2px);
}

.analytics-period.btn-outline:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.analytics-period.btn-sm {
    padding: 5px 12px;
}

/* Settings save spinner (inside btn-primary) */
#settings-save-btn .spinner {
    border-top-color: #fff;
}

/* Login button spinner */
#login-btn .spinner {
    border-top-color: #fff;
}

/* Trend indicators on stat cards */
.stat-trend {
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.stat-trend-up { color: #22c55e; }
.stat-trend-down { color: #ef4444; }
.stat-trend-neutral { color: var(--text-muted, #6b6b82); }
