/* ═══════════════════════════════════════════════════════════════
   NEXTCON DESIGN SYSTEM v2.0
   Unified tokens, base styles, and shared components.
   This is the SINGLE SOURCE OF TRUTH for all pages.
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── Light Mode Tokens ─── */
:root {
    /* Primary — Indigo-Violet */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.25);
    --primary-subtle: rgba(99, 102, 241, 0.08);
    --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* Accent Colors */
    --accent-emerald: #10b981;
    --accent-emerald-subtle: rgba(16, 185, 129, 0.1);
    --accent-rose: #ef4444;
    --accent-rose-subtle: rgba(239, 68, 68, 0.08);
    --accent-amber: #f59e0b;
    --accent-amber-subtle: rgba(245, 158, 11, 0.1);
    --accent-blue: #3b82f6;
    --accent-blue-subtle: rgba(59, 130, 246, 0.08);

    /* Backgrounds */
    --bg-body: #f0f2f7;
    --bg-mesh-1: #ddd6fe;
    --bg-mesh-2: #f0f2f7;
    --bg-mesh-3: #c7d2fe;

    /* Surfaces */
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --surface-glass-border: rgba(148, 163, 184, 0.22);
    --surface-glass-shadow: rgba(15, 23, 42, 0.06);

    /* Text */
    --text: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-input: #cbd5e1;

    /* Radii */
    --radius: 1rem;
    --radius-xs: 0.375rem;
    --radius-sm: 0.5rem;
    --radius-md: 0.625rem;
    --radius-lg: 0.75rem;
    --radius-xl: 0.85rem;
    --radius-2xl: 1rem;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);
    --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.18);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Layout */
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 72px;
    --topbar-height: 58px;
    --header-height: 58px;
    --page-max-width: 1540px;
    --panel-radius: 0.85rem;
    --target-size: 24px;
}

@media (pointer: coarse) {
    :root {
        --target-size: 44px;
    }
}

/* ─── Dark Mode Tokens ─── */
[data-theme="dark"] {
    --bg-body: #0b0e1a;
    --bg-mesh-1: #1e1547;
    --bg-mesh-2: #0b0e1a;
    --bg-mesh-3: #151040;

    --surface: #151929;
    --surface-raised: #1a2035;
    --surface-glass: rgba(21, 25, 41, 0.82);
    --surface-glass-border: rgba(99, 102, 241, 0.12);
    --surface-glass-shadow: rgba(0, 0, 0, 0.3);

    --text: #f1f5f9;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --border: #1e293b;
    --border-light: #1e293b;
    --border-input: #334155;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.28);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.35);
    --shadow-xl: 0 24px 48px -12px rgba(0,0,0,0.45);

    --primary-glow: rgba(99, 102, 241, 0.35);
    --primary-subtle: rgba(99, 102, 241, 0.14);
}


/* ═══════════════════════════════════════════════════════════════
   CSS RESET & BASE
   ═══════════════════════════════════════════════════════════════ */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px) + 0.75rem);
    scroll-padding-bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3 {
    text-wrap: balance;
}

p, li {
    text-wrap: pretty;
}

img, video {
    max-inline-size: 100%;
    block-size: auto;
}

:where(a, code) {
    overflow-wrap: anywhere;
}

/* Mesh gradient background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.1) 50%, rgba(255,255,255,0)),
        radial-gradient(ellipse 65% 50% at 12% 8%, var(--bg-mesh-1), transparent 50%),
        radial-gradient(ellipse 55% 55% at 85% 15%, var(--bg-mesh-3), transparent 48%),
        var(--bg-mesh-2);
    opacity: 0.7;
    transition: opacity var(--transition-slow);
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-wrap: break-word;
    padding-top: 0 !important;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

a { color: inherit; text-decoration: none; }

::selection {
    background: var(--primary);
    color: white;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--text-faint);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* ═══════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════ */

.text-xs { font-size: 0.68rem; }
.text-sm { font-size: 0.78rem; }
.text-base { font-size: 0.88rem; }
.text-lg { font-size: 1.05rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-primary-color { color: var(--primary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }


/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
    filter: brightness(1.08);
}

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

.btn-secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

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

.btn-ghost:hover {
    background: var(--primary-subtle);
    color: var(--primary);
}

.btn-danger {
    background: var(--accent-rose);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background: var(--accent-emerald);
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-sm {
    padding: 0.32rem 0.65rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}


/* ═══════════════════════════════════════════════════════════════
   FORM INPUTS
   ═══════════════════════════════════════════════════════════════ */

.input-field {
    width: 100%;
    padding: 0.52rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.5;
    transition: all var(--transition-fast);
    outline: none;
}

.input-field:hover {
    border-color: var(--border-input);
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-field::placeholder {
    color: var(--text-faint);
    font-weight: 400;
}

select.input-field {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
    cursor: pointer;
}

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

.form-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.form-grid {
    display: grid;
    gap: 0.65rem;
}

label,
.input-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

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


/* ═══════════════════════════════════════════════════════════════
   GLASS PANEL / CARD
   ═══════════════════════════════════════════════════════════════ */

.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border: 1px solid var(--surface-glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}


/* ═══════════════════════════════════════════════════════════════
   DATA TABLE
   ═══════════════════════════════════════════════════════════════ */

.table-wrapper,
.table-wrap,
.ts-table-wrap,
.table-container {
    overflow-x: auto;
    max-inline-size: 100%;
    container-type: inline-size;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table th {
    background: var(--bg-body);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--primary-subtle);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.015);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

.data-table .text-right { text-align: right; }


/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: all var(--transition-fast);
}

.status-badge.badge-draft,
.badge-draft { background: #f1f5f9; color: #64748b; }
.status-badge.badge-ready-for-review,
.badge-ready-for-review { background: #ede9fe; color: #7c3aed; }
.status-badge.badge-sent,
.badge-sent { background: #dbeafe; color: #2563eb; }
.status-badge.badge-approved,
.badge-approved { background: #d1fae5; color: #059669; }
.status-badge.badge-invoiced,
.badge-invoiced { background: #fef3c7; color: #d97706; }
.status-badge.badge-paid,
.badge-paid { background: #a7f3d0; color: #047857; }

/* Dark mode badge adjustments */
[data-theme="dark"] .badge-draft { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-ready-for-review { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .badge-sent { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-approved { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-invoiced { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .badge-paid { background: #064e3b; color: #34d399; }


/* ═══════════════════════════════════════════════════════════════
   MODERN SIDEBAR & TOPBAR NAVIGATION SYSTEM
   ═══════════════════════════════════════════════════════════════ */

/* Backdrop for Mobile Drawer */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    transition: opacity var(--transition-base);
}

body.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    opacity: 1;
}

/* Sidebar Container */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95)),
        var(--surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transition: width var(--transition-base), transform var(--transition-base);
    user-select: none;
    box-shadow: 2px 0 16px rgba(15, 23, 42, 0.03);
    overflow-x: hidden;
}

[data-theme="dark"] .app-sidebar {
    background:
        linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(11, 15, 28, 0.98)),
        #0b0f1c;
    border-right-color: rgba(255, 255, 255, 0.08);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.35);
}

/* Sidebar Brand Header */
.sidebar-brand-container {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    min-width: 0;
}

.brand-badge {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--primary-glow);
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.brand-text-wrap {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.brand-title {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    line-height: 1.2;
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.sidebar-collapse-btn svg {
    transition: transform var(--transition-base);
}

/* Quick Action Button */
.sidebar-action-wrap {
    padding: 0.85rem 0.85rem 0.4rem;
    flex-shrink: 0;
}

.sidebar-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    color: #ffffff !important;
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
    box-shadow: 0 3px 12px var(--primary-glow);
    transition: all var(--transition-fast);
    border: none;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.sidebar-btn-primary .btn-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar-btn-primary .btn-text {
    transition: opacity var(--transition-fast);
}

/* Sidebar Navigation Items */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

.nav-group-title {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-faint);
    padding: 0.85rem 1.15rem 0.35rem;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.62rem 0.85rem;
    margin: 0.18rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: calc(100% - 1.5rem);
    white-space: nowrap;
}

.sidebar-nav-item:hover {
    color: var(--text-primary);
    background: var(--primary-subtle);
    transform: translateX(2px);
}

.sidebar-nav-item.active {
    color: #ffffff !important;
    background: var(--primary-gradient);
    box-shadow: 0 4px 14px var(--primary-glow);
    font-weight: 700;
}

.sidebar-nav-item .nav-icon {
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.sidebar-nav-item .nav-icon svg { width: 19px; height: 19px; display: block; }
.sidebar-nav-item:focus-visible, .workflow-alert:focus-visible, .pipeline-action:focus-visible, .view-switch button:focus-visible, .quote-guide-nav button:focus-visible, .registry-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.sidebar-nav-item .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: rgba(0, 0, 0, 0.015);
    flex-shrink: 0;
}

[data-theme="dark"] .sidebar-footer {
    background: rgba(0, 0, 0, 0.2);
}

.server-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    width: fit-content;
    white-space: nowrap;
}

.status-indicator-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: status-pulse 2s infinite ease-in-out;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.theme-toggle-btn .theme-toggle-icon {
    font-size: 0.95rem;
}

/* ═══════════════════════════════════════════════════════════════
   APP MAIN LAYOUT & TOP ACTION BAR
   ═══════════════════════════════════════════════════════════════ */

.app-layout {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-base);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    min-block-size: var(--topbar-height);
    height: auto;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255,255,255,0.85)),
        var(--surface-glass);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(0.45rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-right, 0px)) 0.45rem max(1.25rem, env(safe-area-inset-left, 0px));
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    transition: background var(--transition-slow), border-color var(--transition-slow);
}

[data-theme="dark"] .app-topbar {
    background:
        linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(11, 15, 28, 0.9)),
        var(--surface-glass);
    border-bottom-color: rgba(99, 102, 241, 0.12);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.topbar-mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.topbar-page-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-page-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════
   COLLAPSED SIDEBAR STATE (DESKTOP ONLY)
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 1025px) {
    body.sidebar-collapsed {
        --sidebar-width: var(--sidebar-width-collapsed);
    }

    body.sidebar-collapsed .brand-text-wrap,
    body.sidebar-collapsed .btn-text,
    body.sidebar-collapsed .nav-group-title,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .status-indicator-text,
    body.sidebar-collapsed .theme-toggle-label {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar-brand {
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-btn-primary {
        padding: 0.65rem;
        justify-content: center;
    }

    body.sidebar-collapsed .sidebar-nav-item {
        justify-content: center;
        padding: 0.65rem 0;
        margin: 0.2rem 0.4rem;
        width: calc(100% - 0.8rem);
    }

    body.sidebar-collapsed .sidebar-footer {
        padding: 0.75rem 0.4rem;
        align-items: center;
    }

    body.sidebar-collapsed .server-status-pill {
        padding: 0.35rem;
        border-radius: 50%;
    }

    body.sidebar-collapsed .theme-toggle-btn {
        justify-content: center;
        padding: 0.45rem;
    }

    body.sidebar-collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: min(280px, 84vw) !important;
        height: 100dvh;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.25);
    }

    body.sidebar-mobile-open {
        overflow: hidden;
    }

    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    .app-layout {
        margin-left: 0 !important;
    }

    .topbar-mobile-toggle {
        display: flex;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    .btn-delete-history,
    .btn-duplicate-history,
    .btn-remove-card {
        opacity: 1 !important;
    }
}

@media (hover: none), (pointer: coarse) {
    :where(button, select, textarea, input:not([type="checkbox"], [type="radio"]), [role="button"], .action-btn, .sidebar-nav-item, .hero-action) {
        min-block-size: 40px;
    }
    .btn-delete-history,
    .btn-duplicate-history,
    .btn-remove-card {
        opacity: 1 !important;
        min-inline-size: 32px;
        min-block-size: 32px;
    }
}

@media (max-width: 768px) {
    .app-topbar {
        padding: max(0.45rem, env(safe-area-inset-top, 0px)) 0.85rem 0.5rem;
        min-block-size: 52px;
        height: auto;
        gap: 0.45rem 0.65rem;
    }
    .topbar-left {
        flex: 1 1 auto;
        min-width: 0;
    }
    .topbar-page-info {
        min-width: 0;
    }
    .topbar-page-title {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-right {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 0.15rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .topbar-right::-webkit-scrollbar {
        display: none;
    }
    .topbar-right > * {
        flex-shrink: 0;
    }
    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        top: auto;
        bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    }
    .toast {
        max-width: 100%;
        width: 100%;
    }
    .history-panel {
        max-width: 100%;
    }
    .system-modal-box,
    .modal-box {
        width: 96%;
        max-height: 90dvh;
        padding: 1.15rem;
    }
    .system-modal-header,
    .system-modal-body,
    .system-tabs {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .sidebar-backdrop,
    .sidebar-collapse-btn {
        display: none !important;
    }
    .app-layout {
        margin-left: 0 !important;
        padding-top: 0 !important;
        display: block !important;
    }
    body {
        padding-top: 0 !important;
        display: block !important;
    }
}

/* Legacy Header Fallback */
.global-header {
    display: none !important;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 32px;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.nav-item svg {
    width: 15px;
    height: 15px;
    opacity: 0.65;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

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

.nav-item:hover {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}

.nav-item.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

/* Header action buttons */
.action-btn {
    height: 34px;
    padding: 0 0.7rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.action-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

.action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
    transform: translateY(-1px);
}

.action-btn.btn-primary-action {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.action-btn.btn-primary-action:hover {
    color: white;
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.action-btn.btn-primary-action svg { opacity: 1; }

/* Theme toggle */
.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

/* Hamburger menu button (mobile) */
.hamburger-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    padding: 0;
}

.hamburger-btn svg {
    width: 18px;
    height: 18px;
}

.hamburger-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Mobile nav panel */
.mobile-nav-panel {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    padding: 0.75rem;
    animation: slideDown 0.25s var(--ease-spring);
}

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

.mobile-nav-panel.open {
    display: block;
}

.mobile-nav-panel .nav-item {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius-md);
}

.mobile-nav-panel .mobile-nav-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.mobile-nav-panel .action-btn {
    width: 100%;
    justify-content: center;
}

/* Autosave indicator */
.autosave-indicator {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-faint);
    padding: 0 0.5rem;
}

.autosave-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-emerald);
    transition: background var(--transition-fast);
}

.autosave-indicator.saving .autosave-dot {
    background: var(--accent-amber);
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}


/* ═══════════════════════════════════════════════════════════════
   OVERLAYS — History Drawer & Modals
   ═══════════════════════════════════════════════════════════════ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 14, 26, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1001;
    display: flex;
    justify-content: flex-end;
    animation: overlayFadeIn 0.2s ease;
}

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

.history-panel {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    height: 100%;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s var(--ease-spring);
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.history-header {
    padding: 1.15rem 1.35rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    flex-shrink: 0;
}

.history-header h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-header h3 svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.history-search {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-body);
    flex-shrink: 0;
}

.history-search .input-field {
    margin-bottom: 0.5rem;
}

.history-search .filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-search .filter-row .input-field {
    flex: 1;
    min-width: 110px;
    padding: 0.35rem 0.5rem;
    font-size: 0.78rem;
    margin-bottom: 0;
}

.history-search .filter-row select.input-field {
    padding-right: 2rem;
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close svg {
    width: 16px;
    height: 16px;
}

.btn-close:hover {
    background: var(--accent-rose-subtle);
    color: var(--accent-rose);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem;
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 0.65rem;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
    text-align: left;
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--primary-subtle);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.history-item h4 {
    margin: 0 0 0.2rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 700;
    padding-right: 3.5rem;
}

.history-item p {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.history-item .item-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.6rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-subtle);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
}

.history-item-actions {
    display: flex;
    gap: 0.25rem;
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
}

.btn-delete-history,
.btn-duplicate-history {
    background: var(--accent-rose-subtle);
    color: var(--accent-rose);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all var(--transition-fast);
    opacity: 0;
}

.btn-duplicate-history {
    background: var(--primary-subtle);
    color: var(--primary);
}

.history-item:hover .btn-delete-history,
.history-item:hover .btn-duplicate-history {
    opacity: 1;
}

.btn-delete-history:hover { background: var(--accent-rose); color: white; }
.btn-duplicate-history:hover { background: var(--primary); color: white; }


/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 0.75rem);
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    animation: toastIn 0.35s var(--ease-spring);
    max-width: 360px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

/* Toast progress bar */
.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--primary);
    animation: toastProgress 3.5s linear forwards;
}

.toast.toast-exit { animation: toastOut 0.25s ease-in forwards; }

.toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.toast-icon svg {
    width: 18px;
    height: 18px;
}

.toast-success { border-left: 3px solid var(--accent-emerald); }
.toast-success::after { background: var(--accent-emerald); }
.toast-error { border-left: 3px solid var(--accent-rose); }
.toast-error::after { background: var(--accent-rose); }
.toast-info { border-left: 3px solid var(--primary); }
.toast-warning { border-left: 3px solid var(--accent-amber); }
.toast-warning::after { background: var(--accent-amber); }

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

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

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}


/* ═══════════════════════════════════════════════════════════════
   CONFIRMATION MODAL
   ═══════════════════════════════════════════════════════════════ */

.modal-overlay,
.nextcon-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 14, 26, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: overlayFadeIn 0.15s ease;
}

.action-btn.primary {
    background: var(--primary-gradient);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.action-btn.primary:hover:not(:disabled) {
    color: #fff;
    filter: brightness(1.08);
}

.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s var(--ease-spring);
    border: 1px solid var(--border-light);
}

.modal-box h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-box p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.35rem;
    line-height: 1.55;
    text-align: left;
}

.modal-actions {
    display: flex;
    gap: 0.55rem;
    justify-content: flex-end;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.94) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}


/* ═══════════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

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

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

.animate-in {
    animation: fadeSlideUp 0.45s var(--ease-spring) backwards;
}

/* Staggered children */
.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.2s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.3s; }


/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-faint);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: var(--primary-subtle);
    border-radius: var(--radius-2xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.empty-state-icon svg {
    width: 24px;
    height: 24px;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 320px;
    margin: 0 auto;
}


/* ═══════════════════════════════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════════════════════════════ */

@media print {
    @page { margin: 0 !important; }
    html, body {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
        min-height: 0 !important;
        height: auto !important;
    }
    body::before { display: none !important; }
    .no-print { display: none !important; }
    .global-header { display: none !important; }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1180px) {
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 0.65rem 0;
        gap: 0.55rem;
        align-items: stretch;
    }
    .global-header {
        height: auto;
        position: sticky;
        padding: 0 1rem;
    }
    body { padding-top: 0 !important; }

    .header-left,
    .header-right {
        width: 100%;
    }
    .header-left { justify-content: space-between; }
    .header-right { justify-content: flex-start; }
}


/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Show hamburger, hide desktop nav & actions in header */
    .hamburger-btn { display: flex; }
    .main-nav { display: none; }
    .header-right .action-btn,
    .header-right .autosave-indicator { display: none; }

    .header-content {
        flex-direction: row;
        padding: 0;
        gap: 0.5rem;
    }

    .header-left {
        flex-direction: row;
        gap: 0.5rem;
        align-items: center;
    }

    .header-right {
        gap: 0.35rem;
    }

    .global-header {
        height: var(--header-height);
        position: fixed;
    }

    body { padding-top: 0 !important; }

    /* Ensure iOS doesn't zoom on input focus */
    input, select, textarea { font-size: 16px !important; }
}

@media (max-width: 480px) {
    :root {
        --header-height: 50px;
    }
    .brand { font-size: 0.9rem; }
}


/* ═══════════════════════════════════════════════════════════════
   UTILITY: prefers-reduced-motion
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   LIVE SERVER STATUS PILL & SYSTEM CENTER MODAL
   ═══════════════════════════════════════════════════════════════ */

.server-status-pill {
    cursor: pointer;
    transition: all var(--transition-fast);
}
.server-status-pill:hover {
    border-color: var(--primary);
    background: var(--primary-subtle);
    color: var(--text-primary);
}
.status-indicator-dot.status-syncing {
    background: var(--accent-amber);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
    animation: status-pulse 0.8s infinite ease-in-out;
}
.status-indicator-dot.status-offline {
    background: var(--accent-rose);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
    animation: none;
}

.system-modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 94%;
    max-width: 760px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: modalIn 0.25s var(--ease-spring);
}

.system-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.system-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.system-tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.6rem 1.35rem;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.system-tab-btn {
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.system-tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface);
}

.system-tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.system-modal-body {
    padding: 1.25rem 1.35rem;
    overflow-y: auto;
    flex: 1;
}

.sys-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.sys-list-item strong {
    font-size: 0.84rem;
    color: var(--text-primary);
}

.sys-list-item small {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.badge-deleted {
    background: var(--accent-rose-subtle);
    color: var(--accent-rose);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
}

.badge-active {
    background: var(--accent-emerald-subtle);
    color: var(--accent-emerald);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
}

