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

:root {
    --bg-base: #0b0f19;
    --bg-surface: #111827;
    --bg-elevated: #1a2332;
    --bg-input: #0d1117;
    --bg-hover: #1e293b;
    --bg-active: rgba(59, 130, 246, 0.12);

    --border: #1e293b;
    --border-light: #2a3548;
    --border-focus: #3b82f6;

    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-muted: rgba(59, 130, 246, 0.15);

    --green: #10b981;
    --green-muted: rgba(16, 185, 129, 0.15);
    --red: #ef4444;
    --red-muted: rgba(239, 68, 68, 0.15);
    --amber: #f59e0b;
    --amber-muted: rgba(245, 158, 11, 0.15);
    --cyan: #06b6d4;
    --cyan-muted: rgba(6, 182, 212, 0.15);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.125rem;
    --text-2xl: 1.5rem;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

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

    --sidebar-w: 260px;
    --header-h: 56px;
    --transition: 200ms ease;
}

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

body {
    font-family: var(--font);
    font-size: var(--text-base);
    color: var(--text);
    background: var(--bg-base);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* ───── Layout ───── */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

.app-content {
    flex: 1;
    padding: var(--space-6);
    max-width: 1400px;
    width: 100%;
    min-width: 0;
}

/* ───── Sidebar ───── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-brand {
    padding: 0 var(--space-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--header-h);
    flex-shrink: 0;
}

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

.sidebar-brand-text {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    overflow-y: auto;
}

.sidebar-section {
    padding: var(--space-3) var(--space-3) var(--space-1);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-link--active {
    background: var(--bg-active);
    color: var(--accent);
}

.sidebar-link--active:hover {
    background: var(--bg-active);
    color: var(--accent);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay--visible {
    display: block;
}

/* ───── Header ───── */

.app-header {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    gap: var(--space-4);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.header-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius);
    transition: color var(--transition);
}

.header-menu-btn:hover {
    color: var(--text);
}

.header-menu-btn svg {
    width: 24px;
    height: 24px;
}

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

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ───── Cards ───── */

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

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

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

.token-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-2);
    font-variant-numeric: tabular-nums;
}

.token-count-value {
    color: var(--text);
}

.token-count-sep {
    color: var(--text-muted);
    margin: 0 1px;
}

.token-count-total {
    color: var(--text-muted);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

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

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ───── Buttons ───── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

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

.btn--primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn--danger {
    background: var(--red);
    color: white;
}

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

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

.btn--success:hover:not(:disabled) {
    background: #059669;
}

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

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

.btn--sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn--xs {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
}

.btn--danger {
    background: var(--red);
    color: white;
    border: 1px solid transparent;
}

.btn--danger:hover:not(:disabled) {
    filter: brightness(1.15);
}

.btn--accent {
    background: var(--accent-muted);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn--accent:hover:not(:disabled) {
    background: var(--accent);
    color: white;
}

.btn--icon {
    padding: var(--space-2);
}

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

/* ───── Forms ───── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--text-sm);
    line-height: 1.5;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

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

.form-input:focus,
.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-select {
    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'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option {
    background: var(--bg-surface);
    color: var(--text);
}

.form-help {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.form-help--error {
    color: var(--red);
}

.form-row--align-end {
    align-items: end;
}

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

.form-inline {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
}

.form-inline .form-group {
    flex: 1;
}

.form-row--wrap {
    display: flex;
    flex-wrap: wrap;
}

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

.form-input--number {
    max-width: 200px;
}

.form-checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: var(--space-2);
}

.strategy-config-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-6);
}

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

.strategy-config-card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.strategy-config-card-body {
    padding: var(--space-5);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-5);
}

.strategy-form-group {
    margin-bottom: 0;
}

.strategy-form-group--full {
    grid-column: 1 / -1;
}

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

.token-interval-picker {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.token-interval-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.token-interval-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.token-interval-chip:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.token-interval-chip--selected {
    background: var(--accent-muted);
    border-color: var(--border-focus);
}

.token-interval-chip input {
    margin: 0;
}

/* ───── Tables ───── */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

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

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

/* ───── Badges ───── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}

.badge--neutral {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge--success {
    background: var(--green-muted);
    color: var(--green);
}

.badge--danger {
    background: var(--red-muted);
    color: var(--red);
}

.badge--warning {
    background: var(--amber-muted);
    color: var(--amber);
}

.badge--info {
    background: var(--cyan-muted);
    color: var(--cyan);
}

.badge--accent {
    background: var(--accent-muted);
    color: var(--accent);
}

/* ───── Tabs ───── */

.tabs-header {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-5);
}

.tab {
    padding: var(--space-3) var(--space-5);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: -1px;
}

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

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

/* ───── Chips ───── */

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.chip {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
}

.chip:hover {
    border-color: var(--border-light);
    color: var(--text);
}

.chip--active {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent);
}

.chip--unavailable {
    border-style: dashed;
    border-color: var(--red);
    color: var(--text-muted);
}

.chip--unavailable.chip--active {
    background: var(--red-muted);
    border-color: var(--red);
    border-style: solid;
    color: var(--red);
}

/* ───── Toggle ───── */

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid var(--border);
    padding: 0;
    flex-shrink: 0;
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

.toggle--active {
    background: var(--accent-muted);
    border-color: var(--accent);
}

.toggle--active::after {
    transform: translateX(16px);
    background: var(--accent);
}

/* ───── Modal ───── */

dialog.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    color: var(--text);
    padding: 0;
    width: min(90vw, 560px);
    box-shadow: var(--shadow-lg);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-shrink: 0;
}

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

.modal-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    color: var(--text);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-confirm {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.modal-confirm .form-alert {
    margin: 0;
}

.modal-confirm-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}

.btn-group {
    display: flex;
    gap: var(--space-1);
    align-items: center;
}

.modal-panel--confirm {
    max-width: 480px;
}

.modal-panel--wide {
    max-width: min(96vw, 1100px);
}

.strategy-detail-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.strategy-detail-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.strategy-detail-heading {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

.strategy-detail-dl {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
}

.strategy-detail-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: var(--space-3);
    align-items: center;
}

.strategy-detail-row dt {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 400;
    margin: 0;
}

.strategy-detail-row dd {
    margin: 0;
    font-size: var(--text-sm);
}

.strategy-detail-config {
    margin: 0;
    padding: var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.5;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
}

.strategy-detail-config code {
    white-space: pre;
}

.form-input--code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: var(--text-xs);
    line-height: 1.6;
    white-space: pre;
    resize: vertical;
    tab-size: 2;
    overflow-x: auto;
}

/* ───── Form Alerts ───── */

.form-alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.form-alert ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.form-alert--error {
    background: var(--red-muted);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.form-alert--success {
    background: var(--green-muted);
    color: var(--green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.form-alert--warning {
    background: var(--amber-muted);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.form-input--error,
.form-select--error {
    border-color: var(--red);
}

.form-input--error:focus,
.form-select--error:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-muted);
}

/* ───── Empty State ───── */

.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    color: var(--text-muted);
    opacity: 0.4;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    max-width: 360px;
    margin: 0 auto;
}

/* ───── Auth / Login ───── */

.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-4);
    background: linear-gradient(135deg, #0b0f19 0%, #0f172a 50%, #0b1224 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.auth-header {
    padding: var(--space-8) var(--space-8) var(--space-4);
    text-align: center;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

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

.auth-brand-text {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}

.auth-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.auth-body {
    padding: var(--space-4) var(--space-8) var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-body .btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
}

.btn--block {
    width: 100%;
}

.auth-flash {
    margin: 0 var(--space-8) var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}
.auth-flash--error {
    background: var(--red-muted);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.auth-form .form-group {
    margin-bottom: 0;
}

.is-hidden {
    display: none !important;
}

.auth-card--sent .auth-header {
    padding-bottom: var(--space-6);
}

.auth-success-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-4);
    color: var(--green);
}

.auth-success-icon svg {
    width: 100%;
    height: 100%;
}

.auth-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-2);
}

.auth-form .form-group + .btn {
    margin-top: var(--space-2);
}

.auth-cooldown {
    margin: 0 var(--space-8) var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
}

.auth-cooldown strong {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ───── Stat Cards ───── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-2);
}

.stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-mono);
}

/* ───── Section Header ───── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.section-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text);
}

.section-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ───── Toolbar ───── */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.toolbar-search {
    min-width: 140px;
    max-width: 200px;
}

.toolbar-actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

/* ───── Indicator Config Row ───── */

.indicator-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
}

.indicator-row-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 100px;
}

.indicator-cell {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.indicator-cell-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

.indicator-sep {
    color: var(--text-muted);
    font-size: var(--text-xs);
    margin: 0 1px;
}

.badge--xs {
    font-size: 10px;
    padding: 1px 5px;
    line-height: 1.4;
}

/* ───── Filter Bar ───── */

.filter-bar {
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--border);
}

.filter-bar-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-bar-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.filter-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px var(--space-2);
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-indent {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-left: calc(60px + var(--space-2));
    border-left: 2px solid var(--border);
    margin-left: 30px;
}

.chip--filter {
    font-size: 10px;
    padding: 1px var(--space-2);
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}

.btn--filter-active {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-mode {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.filter-mode-btn {
    padding: 2px var(--space-3);
    font-size: 10px;
    font-weight: 500;
    font-family: var(--font);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-mode-btn:hover {
    color: var(--text-secondary);
}

.filter-mode-btn--active {
    background: var(--accent-muted);
    color: var(--accent);
}

.filter-mode-btn--exclude {
    background: var(--red-muted);
    color: var(--red);
}

/* ───── Reset Token List ───── */

.reset-token-list {
    list-style: none;
    margin-top: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.reset-token-list li {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    font-size: var(--text-sm);
}

.indicator-row-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ───── Loading ───── */

[data-loading] {
    position: relative;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 15, 25, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}

/* ───── Utilities ───── */

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

/* ───── Responsive ───── */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay--visible {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .header-menu-btn {
        display: flex;
    }
}

@media (max-width: 640px) {
    .app-content {
        padding: var(--space-4);
    }

    .card-header {
        padding: var(--space-3) var(--space-4);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .card-header .toolbar {
        width: 100%;
    }

    .card-body {
        padding: var(--space-4);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .auth-header,
    .auth-body {
        padding-left: var(--space-5);
        padding-right: var(--space-5);
    }

    .toolbar-search {
        max-width: none;
        flex: 1;
    }

    .toolbar-actions {
        margin-left: 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .indicator-row {
        flex-direction: column;
    }

    .filter-bar {
        padding: var(--space-3) var(--space-4);
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .filter-label {
        min-width: auto;
    }

}

/* ── API Check ── */

.check-config {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.check-config-intro {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.check-config-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.check-config-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.check-config-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.check-config-card-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.check-config-card-desc {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.check-config-rate {
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.check-config-rate-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.check-config-rate-row .form-input {
    flex-shrink: 0;
}

.check-config-rate-unit {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.check-config-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--space-2);
}

.check-progress-wrap {
    margin-bottom: var(--space-3);
}

.check-progress-wrap.hidden {
    display: none;
}

.check-progress-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.check-progress-bar {
    flex: 1;
    height: 10px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.check-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.25s ease-out;
    min-width: 0;
}

.check-progress-pct {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: right;
}

.check-completed {
    margin-bottom: var(--space-3);
}

.check-completed.hidden {
    display: none;
}

.check-completed-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
}

.check-completed--success .check-completed-badge {
    background: var(--green-muted);
    color: var(--green);
}

.check-completed--partial .check-completed-badge {
    background: var(--amber-muted);
    color: var(--amber);
}

.check-results-filter {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.check-results-filter.hidden {
    display: none;
}

.check-results-filter-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 500;
}

.check-results-filter-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
}

.check-results-search input {
    min-width: 0;
}

.check-results-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.check-results-view .check-progress-wrap,
.check-results-view .check-completed {
    flex-shrink: 0;
}

.check-results-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.check-results-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.check-results-actions-bar.hidden {
    display: none;
}

.check-result-actions {
    white-space: nowrap;
}

.check-result-actions .btn {
    padding: var(--space-1) var(--space-2);
    min-width: 0;
}

.check-results-footer {
    margin-top: var(--space-4);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-shrink: 0;
}

.check-results-scroll {
    height: min(50vh, 400px);
    min-height: 280px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.check-results-table {
    font-size: var(--text-xs);
    table-layout: fixed;
    width: 100%;
}

.check-results-table th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 1;
}

.check-results-table th:nth-child(1) { width: 14%; }   /* Token */
.check-results-table th:nth-child(2) { width: 10%; }   /* Indicator */
.check-results-table th:nth-child(3) { width: 8%; }    /* Interval */
.check-results-table th:nth-child(4) { width: 6%; }    /* Period */
.check-results-table th:nth-child(5) { width: 8%; }    /* Status */
.check-results-table th:nth-child(6) { width: 32%; }
.check-results-table th:nth-child(7) { width: 7%; }
.check-results-table th:nth-child(8) { width: 4%; }

.check-results-table td {
    padding: var(--space-2) var(--space-3);
    vertical-align: middle;
}

.check-results-table td:nth-child(6) {
    max-width: 0; /* allows column to respect table-layout fixed */
}

.token-quote {
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--text-muted);
}

.check-result-code {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-secondary);
}

.check-summary {
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    text-align: center;
}

.check-summary-stats {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .modal-overlay {
        padding: var(--space-2);
        align-items: flex-start;
    }

    .modal-panel--wide {
        max-width: 100%;
        max-height: calc(100vh - var(--space-4));
    }

    .check-config-stats {
        grid-template-columns: 1fr;
    }

    .check-config-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    .check-results-view .check-progress-wrap,
    .check-results-view .check-completed {
        margin-bottom: var(--space-2);
    }

    .check-results-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }

    .check-results-filter-row .chip-group {
        width: 100%;
    }

    .check-results-search input {
        width: 100%;
        max-width: none;
    }

    .check-results-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .check-results-actions-bar .btn-group {
        justify-content: stretch;
    }

    .check-results-actions-bar .btn-group .btn,
    .check-results-actions-bar .btn {
        min-height: 44px;
    }

    .check-results-scroll {
        height: min(55vh, 360px);
        min-height: 240px;
        overflow-x: hidden;
    }

    .check-results-table,
    .check-results-table thead,
    .check-results-table tbody,
    .check-results-table tr {
        display: block;
    }

    .check-results-table thead {
        display: none;
    }

    .check-results-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-2);
        padding: var(--space-3);
        background: var(--bg-surface);
    }

    .check-results-table tr.hidden {
        display: none;
    }

    .check-results-table td {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        padding: var(--space-2) 0;
        border: none;
        width: 100%;
    }

    .check-results-table td:not(:last-child) {
        border-bottom: 1px solid var(--border-light);
    }

    .check-results-table td:last-child {
        border-bottom: none;
        padding-top: var(--space-2);
        justify-content: flex-end;
    }

    .check-results-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: var(--text-xs);
        color: var(--text-muted);
        min-width: 4.5rem;
        flex-shrink: 0;
    }

    .check-results-table td[data-label=""]::before {
        content: none;
    }

    .check-results-table td:nth-child(6) {
        max-width: none;
        flex-wrap: wrap;
    }

    .check-result-code {
        flex: 1;
        min-width: 0;
        overflow-x: auto;
        white-space: pre;
        word-break: break-all;
        -webkit-overflow-scrolling: touch;
    }

    .check-results-footer {
        margin-top: var(--space-3);
    }

    .check-results-footer .btn {
        min-height: 44px;
        width: 100%;
    }
}
