/* ==========================================
   ADMIN DASHBOARD — admin.css
   Interactive Reading Coach Platform
   ========================================== */

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

/* ===== DESIGN TOKENS ===== */
:root {
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Core Backgrounds */
    --bg-root:    #0A0D14;
    --bg-sidebar: #0D1117;
    --bg-card:    #111827;
    --bg-card-2:  #161D2E;
    --bg-input:   #0A0D14;

    /* Borders */
    --border:       #1E2A3F;
    --border-glow:  #2A3F60;
    --border-focus: rgba(20, 184, 166, 0.6);

    /* Text */
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted:     #475569;
    --text-label:     #64748B;

    /* Neon Teal Accent System */
    --teal:        #14B8A6;
    --teal-light:  #2DD4BF;
    --teal-dim:    rgba(20, 184, 166, 0.12);
    --teal-glow:   0 0 20px rgba(20, 184, 166, 0.25);

    /* Supporting Palette */
    --violet:      #8B5CF6;
    --violet-dim:  rgba(139, 92, 246, 0.12);
    --amber:       #F59E0B;
    --amber-dim:   rgba(245, 158, 11, 0.12);
    --emerald:     #10B981;
    --emerald-dim: rgba(16, 185, 129, 0.12);
    --rose:        #F43F5E;
    --rose-dim:    rgba(244, 63, 94, 0.12);
    --blue:        #3B82F6;
    --blue-dim:    rgba(59, 130, 246, 0.12);

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg:  0 8px 24px rgba(0,0,0,0.6);

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;

    /* Sidebar width */
    --sidebar-w: 240px;
    --topbar-h: 58px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 14px; }

body {
    background: var(--bg-root);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    height: 100vh;
    width: 100vw;
    display: flex;
    overflow: hidden;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal); }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 200;
    transition: var(--transition);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--teal), var(--violet));
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--teal-glow);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-tag {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--teal);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.72rem;
    color: var(--teal);
    font-weight: 500;
    background: var(--teal-dim);
    border-bottom: 1px solid var(--border);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pulse-teal {
    background: var(--teal);
    animation: pulseTeal 2s infinite;
}

@keyframes pulseTeal {
    0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0.6); }
    50% { box-shadow: 0 0 0 5px rgba(20, 184, 166, 0); }
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.75rem 1rem 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 0;
    position: relative;
    border-left: 2px solid transparent;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.03);
}

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

.nav-item.active svg {
    color: var(--teal);
}

.nav-badge {
    margin-left: auto;
    background: var(--teal-dim);
    color: var(--teal-light);
    border: 1px solid rgba(20, 184, 166, 0.2);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    font-family: var(--font-mono);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
}

.admin-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--violet), var(--teal));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
    flex-shrink: 0;
}

.admin-info {
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.admin-role {
    font-size: 0.65rem;
    color: var(--teal);
    font-weight: 500;
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-h);
    background: rgba(13, 17, 23, 0.95);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-glow);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.breadcrumb-active {
    color: var(--text-primary);
    font-weight: 600;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--teal);
    font-weight: 600;
    background: var(--teal-dim);
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.live-dot {
    width: 6px;
    height: 6px;
    background: var(--teal);
    border-radius: 50%;
    animation: pulseTeal 1.5s infinite;
}

.topbar-time {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.topbar-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem 0.65rem;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition);
    font-size: 0.75rem;
}

.topbar-btn:hover {
    border-color: var(--teal);
    color: var(--teal);
}

.topbar-btn.spinning svg {
    animation: spin 1s linear infinite;
}

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

/* ===== CONTENT SCROLL ===== */
.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.5rem 4rem; /* Added extra padding at bottom */
}

/* ===== SECTIONS ===== */
.content-section {
    display: none;
    animation: fadeIn 0.25s ease;
}

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

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

.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.section-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ===== KPI GRID ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 1rem;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    transition: var(--transition);
}

.kpi-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon-teal    { background: var(--teal-dim); color: var(--teal); }
.kpi-icon-violet  { background: var(--violet-dim); color: var(--violet); }
.kpi-icon-amber   { background: var(--amber-dim); color: var(--amber); }
.kpi-icon-emerald { background: var(--emerald-dim); color: var(--emerald); }
.kpi-icon-rose    { background: var(--rose-dim); color: var(--rose); }
.kpi-icon-blue    { background: var(--blue-dim); color: var(--blue); }

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.kpi-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.3;
}

.kpi-value {
    font-family: var(--font-heading);
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.kpi-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== PANEL CARDS ===== */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.panel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

.panel-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.panel-card-title svg { color: var(--text-secondary); }

/* ===== BADGES ===== */
.badge-teal {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--teal-dim);
    color: var(--teal-light);
    border: 1px solid rgba(20, 184, 166, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-amber {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--amber-dim);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-rose {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--rose-dim);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-violet {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--violet-dim);
    color: var(--violet);
    border: 1px solid rgba(139, 92, 246, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== PROFITABILITY MILESTONES ===== */
.profitability-milestones {
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.milestone-item {
    display: grid;
    grid-template-columns: 32px 1fr 80px 160px;
    align-items: center;
    gap: 0.75rem;
}

.milestone-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.milestone-icon.breakeven { background: var(--emerald-dim); color: var(--emerald); }
.milestone-icon.healthy   { background: var(--amber-dim); color: var(--amber); }
.milestone-icon.scale     { background: var(--violet-dim); color: var(--violet); }

.milestone-body {
    display: flex;
    flex-direction: column;
}

.milestone-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.milestone-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.milestone-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
}

.milestone-bar-wrap {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.milestone-bar {
    height: 100%;
    background: var(--emerald);
    border-radius: 3px;
    transition: width 0.8s ease;
}

.milestone-bar.bar-amber { background: var(--amber); }
.milestone-bar.bar-violet { background: var(--violet); }

.trajectory-summary {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--border);
}

.trajectory-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.8rem 1.1rem;
    border-right: 1px solid var(--border);
}

.trajectory-stat:last-child { border-right: none; }

.tstat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.tstat-val {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tstat-green { color: var(--emerald); }
.tstat-teal  { color: var(--teal); }

/* ===== TIER SUMMARY GRID ===== */
.tier-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0;
}

@media (max-width: 1200px) {
    .tier-summary-grid { grid-template-columns: 1fr 1fr; }
    .tier-card.tier-global-config { grid-column: span 2; }
}

@media (max-width: 768px) {
    .tier-summary-grid { grid-template-columns: 1fr; }
    .tier-card.tier-global-config { grid-column: span 1; }
}

.tier-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1rem;
}

.tier-card.tier-sandbox { border-top: 2px solid var(--amber); }
.tier-card.tier-subscribed { border-top: 2px solid var(--teal); }
.tier-card.tier-global-config { border-top: 2px solid var(--violet); }

.tier-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.tier-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
}

.tier-badge-sandbox   { background: var(--amber-dim);  color: var(--amber);  }
.tier-badge-subscribed { background: var(--teal-dim);  color: var(--teal-light); }
.tier-badge-config    { background: var(--violet-dim); color: var(--violet); }

.tier-stat {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.tier-rules {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.tier-rule {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tier-rule svg { color: var(--teal); flex-shrink: 0; }

/* ===== CONFIG FIELDS ===== */
.config-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.config-row.mt-sm { margin-top: 0.5rem; }

.config-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.config-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.config-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
    width: 70px;
    outline: none;
    transition: var(--transition);
}

.config-input.wide { width: 100px; }

.config-input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.1);
}

.config-unit {
    font-size: 0.67rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.config-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0.4rem 0;
    line-height: 1.5;
}

.config-section { padding: 1rem; }

/* ===== FEATURE TOGGLES ===== */
.feature-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.feature-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.feature-toggle-row.mb-sm { margin-bottom: 0.75rem; }

.panel-card > .feature-toggle-row {
    padding: 0.85rem 1.1rem;
}

.feature-toggle-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    display: block;
    width: 36px;
    height: 20px;
    background: var(--border-glow);
    border-radius: 20px;
    position: relative;
    transition: var(--transition);
}

.toggle-track::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-track {
    background: var(--teal);
    box-shadow: 0 0 8px rgba(20, 184, 166, 0.4);
}

.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(16px);
}

/* ===== TABLES ===== */
.table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 60vh;
    padding: 0 0 0.5rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 700px;
}

.admin-table thead tr {
    background: rgba(0,0,0,0.2);
}

.admin-table th {
    text-align: left;
    padding: 0.65rem 1rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 0.7rem 1rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(30, 42, 63, 0.5);
    vertical-align: middle;
    white-space: nowrap;
}

.admin-table tbody tr:hover td {
    background: rgba(255,255,255,0.02);
    color: var(--text-primary);
}

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

.table-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 2.5rem !important;
}

.table-count {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Table specific styling */
.user-id {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--teal);
}

.tier-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tier-pill-sandbox    { background: var(--amber-dim);  color: var(--amber); }
.tier-pill-subscribed { background: var(--teal-dim);   color: var(--teal-light); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill-active   { background: var(--emerald-dim); color: var(--emerald); }
.status-pill-inactive { background: var(--amber-dim);   color: var(--amber); }
.status-pill-none     { background: rgba(255,255,255,0.04); color: var(--text-muted); }
.status-pill-verified { background: var(--emerald-dim); color: var(--emerald); }
.status-pill-unverified { background: var(--rose-dim); color: var(--rose); }

.action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.55rem;
    border-radius: var(--r-sm);
    font-size: 0.65rem;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    border-color: var(--teal);
    color: var(--teal);
}

.action-btn.danger:hover {
    border-color: var(--rose);
    color: var(--rose);
}

/* ===== DANGER ZONE ===== */
.danger-zone {
    border-color: rgba(244, 63, 94, 0.25) !important;
    border-top: 2px solid var(--rose) !important;
}

.danger-title {
    color: var(--rose) !important;
}

.danger-title svg { color: var(--rose) !important; }

.danger-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.85rem 1.1rem;
    line-height: 1.6;
    border-bottom: 1px solid var(--border);
}

.danger-controls {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    padding: 0.85rem 1.1rem;
    flex-wrap: wrap;
}

.danger-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.admin-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
    outline: none;
    transition: var(--transition);
    min-width: 200px;
}

.admin-input:focus {
    border-color: var(--rose);
    box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.1);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: var(--rose);
    border-radius: var(--r-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-danger:hover {
    background: rgba(244, 63, 94, 0.2);
    border-color: var(--rose);
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.2);
}

/* ===== SAVE BUTTON ===== */
.btn-save {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--teal-dim);
    border: 1px solid rgba(20, 184, 166, 0.3);
    color: var(--teal-light);
    border-radius: var(--r-sm);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-save:hover {
    background: rgba(20, 184, 166, 0.2);
    box-shadow: 0 0 12px rgba(20, 184, 166, 0.15);
}

/* ===== SEARCH BOX ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0.35rem 0.7rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--teal);
    color: var(--teal);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    width: 200px;
}

.search-box input::placeholder { color: var(--text-muted); }

.admin-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    padding: 0.38rem 0.65rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.admin-select:focus {
    border-color: var(--teal);
}

.admin-select.sm { font-size: 0.73rem; padding: 0.35rem 0.55rem; }

/* ===== GUARDRAILS GRID ===== */
.guardrails-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

/* ===== DOMAIN LISTS ===== */
.domain-lists { padding: 0.85rem 1.1rem; }
.domain-list-block.mt-sm { margin-top: 0.85rem; }

.domain-list-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.domain-list-label.allowed { color: var(--emerald); }
.domain-list-label.blocked { color: var(--rose); }

.domain-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.domain-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-weight: 500;
}

.domain-tag.allowed  { background: var(--emerald-dim); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.2); }
.domain-tag.blocked  { background: var(--rose-dim); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.2); }

.add-tag {
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    border: 1px dashed var(--border-glow);
    cursor: pointer;
    transition: var(--transition);
}

.add-tag:hover {
    border-color: var(--teal);
    color: var(--teal);
}

/* ===== RATE GRID ===== */
.rate-grid {
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.rate-block { flex: 1; }

.rate-tier-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}

.rate-tier-label.subscribed { color: var(--teal-light); }

.rate-divider {
    width: 1px;
    background: var(--border);
    align-self: stretch;
    min-height: 60px;
}

.defense-toggles {
    padding: 0.85rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* ===== WORD CAP VISUAL ===== */
.word-cap-visual {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-input);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.wcv-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.wcv-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    width: 100px;
    flex-shrink: 0;
}

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

.wcv-bar {
    height: 100%;
    background: var(--amber);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.wcv-bar-teal { background: var(--teal); }

.wcv-val {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    width: 65px;
    text-align: right;
}

/* ===== FUNNEL ===== */
.funnel-container {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.funnel-stage { }

.funnel-bar-wrap {
    display: grid;
    grid-template-columns: 220px 1fr 48px;
    align-items: center;
    gap: 0.85rem;
}

.funnel-bar-label {
    display: flex;
    flex-direction: column;
}

.funnel-stage-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.funnel-stage-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.funnel-bar-bg {
    height: 28px;
    background: var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}

.funnel-bar-fill {
    height: 100%;
    border-radius: var(--r-sm);
    transition: width 0.8s ease;
}

.fb-teal   { background: linear-gradient(90deg, var(--teal), #0D9488); }
.fb-amber  { background: linear-gradient(90deg, var(--amber), #D97706); }
.fb-violet { background: linear-gradient(90deg, var(--violet), #7C3AED); }
.fb-emerald { background: linear-gradient(90deg, var(--emerald), #059669); }

.funnel-pct {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: right;
}

.funnel-arrow {
    padding: 0.1rem 0 0.1rem 220px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.funnel-drop {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--rose);
}

.funnel-stage-final .funnel-stage-name { color: var(--emerald); }
.funnel-stage-final .funnel-bar-bg { border: 1px solid rgba(16, 185, 129, 0.2); }

.funnel-economics {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
    flex-wrap: wrap;
}

.econ-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.econ-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.econ-val {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.econ-red   { color: var(--rose); }
.econ-green { color: var(--emerald); }

.econ-divider {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 300;
    padding-top: 0.85rem;
}

.econ-stat.highlight {
    background: var(--emerald-dim);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--r-md);
    padding: 0.5rem 0.85rem;
}

/* ===== CLASSROOM SUMMARY ===== */
.classroom-summary {
    display: flex;
    border-top: 1px solid var(--border);
}

.cs-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 1rem;
    border-right: 1px solid var(--border);
}

.cs-stat:last-child { border-right: none; }

.cs-label {
    font-size: 0.67rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.cs-val {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.cs-green { color: var(--emerald); }
.cs-teal  { color: var(--teal); }

/* ===== AI KPI GRID ===== */
.ai-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 1100px) {
    .ai-kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .ai-kpi-grid { grid-template-columns: 1fr; }
}

.ai-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.1rem;
    transition: var(--transition);
}

.ai-kpi-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.ai-kpi-card.highlight-card {
    border-color: rgba(16, 185, 129, 0.25);
    background: linear-gradient(135deg, var(--bg-card), rgba(16, 185, 129, 0.04));
}

.ai-kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.ai-kpi-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-blue   { background: var(--blue-dim);   color: var(--blue); }
.icon-violet { background: var(--violet-dim); color: var(--violet); }
.icon-emerald{ background: var(--emerald-dim);color: var(--emerald); }

.ai-kpi-val {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.6rem;
}

.ai-kpi-val.zero-cost {
    color: var(--emerald);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.ai-kpi-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.65rem;
    padding: 0.6rem;
    background: var(--bg-input);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.akb-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.akb-val { font-family: var(--font-mono); color: var(--text-secondary); }
.akb-val.verified { color: var(--emerald); font-weight: 600; }
.akb-val.none { color: var(--text-muted); }

.ai-kpi-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== CACHING COMPARISON ===== */
.caching-comparison {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 1.1rem;
    gap: 1.1rem;
}

.cache-mode {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem;
    transition: var(--transition);
}

.cache-mode.active-cache {
    border-color: rgba(20, 184, 166, 0.3);
    background: rgba(20, 184, 166, 0.04);
    box-shadow: 0 0 16px rgba(20, 184, 166, 0.08);
}

.cache-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.cache-mode-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cache-mode-cost {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 0.2rem;
}

.cache-mode-cost.cost-green { color: var(--teal); }

.cache-mode-per {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

.cache-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cb-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.cb-none  { color: var(--text-muted); font-style: italic; }
.cb-green { color: var(--teal); font-weight: 600; }

.cache-vs {
    display: flex;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

.cache-config {
    padding: 0 1.1rem 1.1rem;
}

.cache-savings-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background: var(--teal-dim);
    border: 1px solid rgba(20, 184, 166, 0.25);
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    color: var(--teal-light);
    margin-top: 0.75rem;
}

.cache-savings-banner svg { color: var(--teal); flex-shrink: 0; }

/* ===== TOKEN GAUGES ===== */
.token-gauge-grid {
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.token-gauge { }

.gauge-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.gauge-val {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: 600;
}

.gauge-bar-bg {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.gauge-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.gb-teal   { background: linear-gradient(90deg, var(--teal), #0D9488); }
.gb-blue   { background: linear-gradient(90deg, var(--blue), #1D4ED8); }
.gb-violet { background: linear-gradient(90deg, var(--violet), #7C3AED); }
.gb-amber  { background: linear-gradient(90deg, var(--amber), #D97706); }

.model-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.model-badge strong { color: var(--teal-light); }
.model-badge svg { color: var(--teal); }

/* ===== UTILITIES ===== */
.mt-lg { margin-top: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.mb-sm { margin-bottom: 0.65rem; }

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card-2, #161D2E);
    border: 1px solid var(--border-glow);
    border-radius: var(--r-md);
    padding: 0.75rem 1rem;
    font-size: 0.78rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideInToast 0.25s ease;
    pointer-events: all;
    min-width: 260px;
    max-width: 380px;
}

.toast.toast-success { border-color: rgba(16, 185, 129, 0.4); }
.toast.toast-error   { border-color: rgba(244, 63, 94, 0.4); }
.toast.toast-info    { border-color: rgba(20, 184, 166, 0.4); }

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

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--r-lg);
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.2s ease;
}

.modal-icon-danger {
    width: 56px;
    height: 56px;
    background: var(--rose-dim);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--rose);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

.modal-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-btn-cancel {
    padding: 0.55rem 1.25rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glow);
    color: var(--text-secondary);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
}

.modal-btn-cancel:hover { color: var(--text-primary); border-color: var(--border-glow); background: rgba(255,255,255,0.07); }

.modal-btn-confirm {
    padding: 0.55rem 1.25rem;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--rose);
    color: var(--rose);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: var(--transition);
}

.modal-btn-confirm:hover { background: rgba(244, 63, 94, 0.25); box-shadow: 0 0 12px rgba(244, 63, 94, 0.2); }

/* ===== SIDEBAR COLLAPSED STATE ===== */
.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
    .main-wrapper { min-height: 0; }
    .milestone-item { grid-template-columns: 32px 1fr 60px; }
    .milestone-bar-wrap { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .funnel-bar-wrap { grid-template-columns: 1fr; }
    .caching-comparison { flex-direction: column; }
    .ai-kpi-grid { grid-template-columns: 1fr; }
}

/* ===================================================
   LOGIN GATE
   =================================================== */

.login-gate {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: var(--bg-root);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Animated dot-grid background */
.login-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, rgba(20, 184, 166, 0.08) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}

/* Ambient glow blobs */
.login-gate::before,
.login-gate::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    pointer-events: none;
    animation: blobFloat 8s ease-in-out infinite alternate;
}

.login-gate::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.12), transparent 70%);
    top: -150px;
    right: -100px;
}

.login-gate::after {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1), transparent 70%);
    bottom: -100px;
    left: -80px;
    animation-delay: -4s;
}

@keyframes blobFloat {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(30px, 20px) scale(1.08); }
}

/* Decorative corner brackets */
.login-corner {
    position: absolute;
    width: 60px;
    height: 60px;
    border-color: rgba(20, 184, 166, 0.2);
    border-style: solid;
    pointer-events: none;
}

.login-corner-tl {
    top: 24px; left: 24px;
    border-width: 2px 0 0 2px;
    border-radius: 4px 0 0 0;
}

.login-corner-br {
    bottom: 24px; right: 24px;
    border-width: 0 2px 2px 0;
    border-radius: 0 0 4px 0;
}

/* Card */
.login-card {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 0 0 1px rgba(20, 184, 166, 0.06),
        0 32px 64px rgba(0, 0, 0, 0.6),
        0 0 80px rgba(20, 184, 166, 0.06);
    animation: cardEntry 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardEntry {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Brand header */
.login-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 2rem;
}

.login-brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--teal), var(--violet));
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 24px rgba(20, 184, 166, 0.35);
}

.login-brand-name {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.login-brand-tag {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--teal);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Title */
.login-title {
    font-family: var(--font-heading);
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 0.4rem;
    letter-spacing: -0.02em;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 1.75rem;
}

/* Form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.login-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 0.8rem;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
    transition: var(--transition);
}

.login-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-glow);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    padding: 0.75rem 2.8rem 0.75rem 2.6rem;
    outline: none;
    transition: var(--transition);
    caret-color: var(--teal);
}

.login-input::placeholder { color: var(--text-muted); }

.login-input:focus {
    border-color: var(--teal);
    background: rgba(20, 184, 166, 0.04);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.login-input:focus + .login-input-icon,
.login-input-wrap:focus-within .login-input-icon {
    color: var(--teal);
}

/* Field-level error state */
.login-field.has-error .login-input {
    border-color: var(--rose);
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.1);
}

.login-field-error {
    font-size: 0.7rem;
    color: var(--rose);
    min-height: 1em;
    display: block;
}

/* Eye toggle */
.login-eye-btn {
    position: absolute;
    right: 0.8rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

.login-eye-btn:hover { color: var(--text-primary); }

/* Global error banner */
.login-error-banner {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: var(--r-sm);
    font-size: 0.78rem;
    color: var(--rose);
    line-height: 1.4;
    animation: shakeX 0.4s ease;
}

.login-error-banner.visible {
    display: flex;
}

@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}

/* Submit button */
.login-submit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, var(--teal), #0D9488);
    border: none;
    border-radius: var(--r-md);
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.25rem;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(20, 184, 166, 0.3);
}

.login-submit::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
    border-radius: inherit;
}

.login-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(20, 184, 166, 0.45);
}

.login-submit:active:not(:disabled) {
    transform: translateY(0);
}

.login-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.login-submit-arrow {
    transition: var(--transition);
    flex-shrink: 0;
}

.login-submit:hover:not(:disabled) .login-submit-arrow {
    transform: translateX(3px);
}

/* Spinner inside button */
.login-submit-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.login-submit.loading .login-submit-text  { opacity: 0.6; }
.login-submit.loading .login-submit-arrow { display: none; }
.login-submit.loading .login-submit-spinner { display: block; }

/* Success flash */
.login-submit.success {
    background: linear-gradient(135deg, var(--emerald), #059669);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
}

/* Footer note */
.login-footer-note {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    justify-content: center;
}

.login-footer-note svg { color: var(--text-muted); flex-shrink: 0; }

/* Gate exit animation */
.login-gate.exiting {
    animation: gateExit 0.45s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes gateExit {
    0%   { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.03); pointer-events: none; }
}

/* ===================================================
   LOGOUT BUTTON (Sidebar Footer)
   =================================================== */

.sidebar-footer {
    gap: 0.55rem;
}

.logout-btn {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.logout-btn:hover {
    border-color: var(--rose);
    color: var(--rose);
    background: rgba(244, 63, 94, 0.08);
}

/* Sync Button Styling */
.btn-sync {
    background: rgba(139, 92, 246, 0.15); /* Soft purple glassmorphism */
    color: #A78BFA; /* Neon purple text */
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease-in-out;
}

.btn-sync:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: #A78BFA;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
    transform: translateY(-1px);
}

.btn-sync:active {
    transform: translateY(0);
}

.btn-sync svg {
    transition: transform 0.3s ease;
}

.btn-sync:hover svg {
    /* Subtle rotate animation to imply 'syncing' when hovered */
    transform: rotate(180deg); 
}
