/* ============================================================================
   SMTP MASTER POOL — Design System
   Inspired by VMware vCenter, Linear, Vercel
   ============================================================================ */

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--text-primary); background: var(--bg-app); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font-family: inherit; font-size: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- DESIGN TOKENS ---------- */
:root {
    /* Spacing scale (4px base) */
    --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
    --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px;
    --sp-12: 48px; --sp-16: 64px;

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

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
    --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 8px 10px rgba(0,0,0,.04);

    /* Transitions */
    --ease-default: cubic-bezier(.4,0,.2,1);
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;

    /* Sidebar */
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --header-height: 56px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --text-xs: 0.75rem;    /* 10.5px */
    --text-sm: 0.8125rem;  /* 11.375px */
    --text-base: 0.875rem; /* 12.25px */
    --text-md: 1rem;       /* 14px */
    --text-lg: 1.125rem;   /* 15.75px */
    --text-xl: 1.25rem;    /* 17.5px */
    --text-2xl: 1.5rem;    /* 21px */
    --text-3xl: 1.875rem;  /* 26.25px */
}

/* ---------- LIGHT THEME (default) ---------- */
:root {
    --bg-app: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f9fafb;
    --bg-surface-active: #f3f4f6;
    --bg-elevated: #ffffff;
    --bg-sunken: #f0f1f3;
    --bg-sidebar: #1a1d23;
    --bg-sidebar-hover: #25282f;
    --bg-sidebar-active: #2d3139;

    --border-default: #e2e4e8;
    --border-subtle: #edeef0;
    --border-strong: #d1d5db;

    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --text-inverse: #ffffff;
    --text-sidebar: #9ca3af;
    --text-sidebar-active: #ffffff;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: #eff6ff;
    --accent-text: #1d4ed8;

    --success: #10b981;
    --success-subtle: #ecfdf5;
    --success-text: #065f46;
    --success-border: #a7f3d0;

    --warning: #f59e0b;
    --warning-subtle: #fffbeb;
    --warning-text: #92400e;
    --warning-border: #fde68a;

    --danger: #ef4444;
    --danger-subtle: #fef2f2;
    --danger-text: #991b1b;
    --danger-border: #fecaca;

    --info: #6366f1;
    --info-subtle: #eef2ff;
    --info-text: #4338ca;

    --neutral: #6b7280;
    --neutral-subtle: #f3f4f6;
    --neutral-text: #374151;
}

/* ---------- LAYOUT: SHELL ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- LAYOUT: TOP NAVBAR ---------- */
.navbar {
    height: var(--header-height);
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.navbar-inner {
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--sp-5);
    display: flex;
    align-items: center;
    gap: var(--sp-5);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-brand:hover { text-decoration: none; }

.navbar-brand-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--text-sm);
    font-weight: 700;
}

.navbar-brand-text {
    color: var(--text-inverse);
    font-weight: 600;
    font-size: var(--text-base);
    letter-spacing: -0.01em;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex: 1;
}

.navbar-link {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    color: rgba(255,255,255,.55);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--duration-fast) var(--ease-default);
    text-decoration: none;
    white-space: nowrap;
}

.navbar-link:hover {
    color: rgba(255,255,255,.9);
    background: var(--bg-sidebar-hover);
    text-decoration: none;
}

.navbar-link.active {
    color: #ffffff;
    background: var(--bg-sidebar-active);
}

.navbar-link i { font-size: var(--text-xs); }

.navbar-right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    flex-shrink: 0;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    transition: background var(--duration-fast);
}

.navbar-user:hover { background: var(--bg-sidebar-hover); }

.navbar-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--text-xs);
}

.navbar-user-name {
    color: rgba(255,255,255,.8);
    font-size: var(--text-sm);
    font-weight: 500;
}

.navbar-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration-fast) var(--ease-default);
    z-index: 200;
}

.navbar-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.navbar-dropdown-header {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.navbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background var(--duration-fast);
}

.navbar-dropdown-item:hover {
    background: var(--bg-surface-hover);
    text-decoration: none;
}

.navbar-dropdown-item i { width: 16px; text-align: center; color: var(--text-tertiary); }

.navbar-dropdown-danger { color: var(--danger-text); }
.navbar-dropdown-danger i { color: var(--danger); }

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: var(--text-md);
    padding: var(--sp-2);
    cursor: pointer;
}

/* ---------- LAYOUT: PAGE BAR ---------- */
.page-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    padding: var(--sp-2) var(--sp-6);
}

/* ---------- LAYOUT: MAIN CONTENT ---------- */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.breadcrumb-sep { color: var(--text-tertiary); }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

.top-header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    background: var(--success-subtle);
    color: var(--success-text);
}

.header-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s infinite;
}

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

/* ---------- LAYOUT: PAGE CONTENT ---------- */
.page-content {
    flex: 1;
    padding: var(--sp-6);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
}

.page-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--sp-1);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

/* ---------- CARDS ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.card-title i {
    color: var(--text-tertiary);
    font-size: var(--text-base);
}

.card-body {
    padding: var(--sp-5);
}

.card-body.no-padding { padding: 0; }

/* ---------- STAT CARDS ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    transition: border-color var(--duration-fast);
}

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

.stat-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--sp-2);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-detail {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--sp-1);
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.stat-trend-up { color: var(--success-text); }
.stat-trend-down { color: var(--danger-text); }

/* ---------- CHARTS GRID ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--sp-4) var(--sp-5);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--sp-4);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.chart-card-title i {
    color: var(--text-tertiary);
}

.chart-wrapper {
    position: relative;
    height: 200px;
}

.chart-wrapper.tall { height: 160px; }

/* ---------- DATA TABLES ---------- */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--sp-4);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
}

.table-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.table-title i { color: var(--text-tertiary); }

.table-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table thead th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.data-table tbody td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

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

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

.data-table .cell-mono {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: -0.01em;
}

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

.data-table .cell-compact {
    padding-top: var(--sp-2);
    padding-bottom: var(--sp-2);
}

/* ---------- BADGES / STATUS ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
    line-height: 1.4;
    white-space: nowrap;
}

.badge-success { background: var(--success-subtle); color: var(--success-text); }
.badge-warning { background: var(--warning-subtle); color: var(--warning-text); }
.badge-danger  { background: var(--danger-subtle);  color: var(--danger-text);  }
.badge-info    { background: var(--info-subtle);    color: var(--info-text);    }
.badge-neutral { background: var(--neutral-subtle); color: var(--neutral-text); }
.badge-accent  { background: var(--accent-subtle);  color: var(--accent-text);  }

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

.badge-success .dot { background: var(--success); }
.badge-warning .dot { background: var(--warning); }
.badge-danger .dot  { background: var(--danger);  }
.badge-info .dot    { background: var(--info);    }
.badge-neutral .dot { background: var(--neutral); }

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: all var(--duration-fast) var(--ease-default);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

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

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-surface-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-surface-active); color: var(--text-primary); }

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; }

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

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

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-md);
}

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

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

/* ---------- FORMS ---------- */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--sp-2);
}

.form-input {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

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

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--sp-1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-4);
}

/* ---------- PROGRESS BAR ---------- */
.progress {
    height: 6px;
    background: var(--bg-sunken);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--duration-slow) var(--ease-default);
}

.progress-fill.low    { background: var(--success); }
.progress-fill.medium { background: var(--warning); }
.progress-fill.high   { background: var(--danger);  }

/* ---------- ALERTS ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
}

.alert i { margin-top: 1px; flex-shrink: 0; }

.alert-success { background: var(--success-subtle); color: var(--success-text); border-color: var(--success-border); }
.alert-warning { background: var(--warning-subtle); color: var(--warning-text); border-color: var(--warning-border); }
.alert-danger  { background: var(--danger-subtle);  color: var(--danger-text);  border-color: var(--danger-border);  }
.alert-info    { background: var(--accent-subtle);  color: var(--accent-text); }

/* ---------- MODALS ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--duration-normal);
}

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

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: var(--text-md);
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    transition: all var(--duration-fast);
}

.modal-close:hover { background: var(--bg-surface-active); color: var(--text-primary); }

.modal-body {
    padding: var(--sp-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border-subtle);
}

/* ---------- TABS ---------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--sp-5);
}

.tab {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--duration-fast);
}

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

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

/* ---------- EMPTY STATE ---------- */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: var(--text-3xl);
    margin-bottom: var(--sp-3);
    display: block;
}

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

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

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

.skeleton {
    background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border-subtle) 50%, var(--bg-sunken) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- TOOLTIP ---------- */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--sp-1) var(--sp-2);
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-fast);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ---------- UTILITY ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .navbar-user-name { display: none; }
}

@media (max-width: 768px) {
    .navbar-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-sidebar);
        flex-direction: column;
        padding: var(--sp-2) var(--sp-3);
        border-bottom: 1px solid rgba(255,255,255,.1);
        box-shadow: var(--shadow-lg);
    }
    .navbar-links.open { display: flex; }
    .navbar-toggle { display: block; }
    .navbar-user-name { display: none; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
    .page-content { padding: var(--sp-4); }
    .page-bar { padding: var(--sp-2) var(--sp-4); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .navbar-brand-text { display: none; }
}

/* ---------- LOGIN PAGE ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-app);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-10);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-8);
}

.login-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--text-lg);
    font-weight: 700;
}

.login-logo-text {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-title {
    text-align: center;
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--sp-1);
}

.login-subtitle {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--sp-6);
}

.login-form .form-input {
    padding: var(--sp-3) var(--sp-4);
}

.login-footer {
    text-align: center;
    margin-top: var(--sp-6);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.btn-login {
    width: 100%;
    padding: var(--sp-3);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* ---------- SESSION WARNING ---------- */
.session-warning.show,
#sessionWarning.show {
    top: 2rem !important;
}

/* ---------- POSTFIX TUNER ---------- */
.tuner-section {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    margin-bottom: 0.6rem;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.tuner-section-header {
    padding: 0.6rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.tuner-section-header:hover { background: var(--bg-surface-hover); }

.tuner-section-header .label {
    font-weight: 600;
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.tuner-section-header .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.tuner-section-header .chevron {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    transition: transform 0.2s;
}

.tuner-section-header .chevron.open { transform: rotate(90deg); }

.tuner-section-body { display: none; }
.tuner-section-body.open { display: block; }

.tuner-row {
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
}

.tuner-row .row-left { flex: 1; }
.tuner-row .row-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.tuner-row .row-hint { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 0.1rem; }
.tuner-row .row-right { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

/* Stepper */
.ios-stepper {
    display: inline-flex;
    align-items: center;
    background: var(--bg-sunken);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-default);
}

.ios-stepper button {
    width: 32px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ios-stepper button:hover { background: var(--bg-surface-active); }

.ios-stepper .stepper-val {
    min-width: 42px;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    border-left: 1px solid var(--border-default);
    border-right: 1px solid var(--border-default);
    padding: 0 var(--sp-1);
}

/* Slider */
.ios-slider {
    -webkit-appearance: none;
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-sunken);
    outline: none;
}

.ios-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    border: 0.5px solid rgba(0,0,0,0.04);
}

.ios-slider-value {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 28px;
    text-align: right;
}

/* Changed row highlight */
.tuner-changed { background: var(--warning-subtle); }

.change-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    display: none;
    margin-left: 0.35rem;
}

.has-changes .change-dot { display: inline-block; }

/* Toast */
.tuner-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--sp-3) var(--sp-6);
    border-radius: var(--radius-full);
    color: white;
    font-size: var(--text-sm);
    font-weight: 500;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.tuner-toast.show { opacity: 1; }
.tuner-toast.success { background: var(--success); }
.tuner-toast.error { background: var(--danger); }

/* Preset cards */
.preset-card:active { transform: scale(0.97) !important; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
