/* WinWin design system — loads without Tailwind CDN */
:root {
    --font-ui: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-display: "IBM Plex Serif", Georgia, serif;
    --bg: #F4F6FB;
    --bg-elevated: #FFFFFF;
    --bg-muted: #EEF2F7;
    --text: #0F172A;
    --text-muted: #64748B;
    --text-soft: #94A3B8;
    --border: #E2E8F0;
    --border-strong: #CBD5E1;
    --accent: #0D9488;
    --accent-soft: #F0FDFA;
    --accent-text: #0F766E;
    --navy: #0B1D3A;
    --nav-bg: #0B1D3A;
    --danger: #DC2626;
    --danger-bg: #FEF2F2;
    --success: #059669;
    --success-bg: #ECFDF5;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
    --radius: 12px;
    --font-size-body: 15px;
    --font-weight-body: 400;
    --letter-spacing: 0;
    --line-height: 1.55;
}

html.dark {
    color-scheme: dark;
    --font-ui: "Source Sans 3", "IBM Plex Sans", sans-serif;
    --font-display: "IBM Plex Serif", Georgia, serif;
    --bg: #2B2144;
    --bg-elevated: #3A2F58;
    --bg-muted: #453868;
    --text: #F5F3FF;
    --text-muted: #DDD6FE;
    --text-soft: #C4B5FD;
    --border: #5B4A7A;
    --border-strong: #8B5CF6;
    --accent: #C4B5FD;
    --accent-soft: #4C1D95;
    --accent-text: #EDE9FE;
    --navy: #5B21B6;
    --nav-bg: #3B0764;
    --danger: #FCA5A5;
    --danger-bg: #4C0519;
    --success: #6EE7B7;
    --success-bg: #064E3B;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 12px 32px -16px rgba(91, 33, 182, 0.4);
    --font-size-body: 15.5px;
    --font-weight-body: 450;
    --letter-spacing: 0.015em;
    --line-height: 1.6;
}

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-body);
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease, font-size .15s ease;
}

img, video { max-width: 100%; height: auto; }
[x-cloak] { display: none !important; }

.page-container { width: 100%; max-width: 80rem; margin-left: auto; margin-right: auto; padding-left: 1rem; padding-right: 1rem; }
@media (min-width: 640px) { .page-container { padding-left: 1.5rem; padding-right: 1.5rem; } }
@media (min-width: 1024px) { .page-container { padding-left: 2rem; padding-right: 2rem; } }
.page-section { padding-top: 1.5rem; padding-bottom: 1.5rem; }
@media (min-width: 640px) { .page-section { padding-top: 2rem; padding-bottom: 2rem; } }
.page-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.5rem; }
@media (min-width: 640px) {
    .page-header { flex-direction: row; align-items: flex-end; justify-content: space-between; }
}
.page-title {
    margin: 0;
    font-size: clamp(1.4rem, 2vw, 1.875rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--navy);
    font-family: var(--font-display);
}
html.dark .page-title { color: #F5F3FF; font-weight: 600; letter-spacing: 0; }
.page-subtitle { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--text-muted); }

.fin-card, .fin-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}
.fin-panel { box-shadow: none; }

.btn-primary, .btn-navy, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 42px; padding: 0.55rem 1rem; border-radius: 0.55rem;
    font-size: 0.875rem; font-weight: 600; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
html.dark .btn-primary { background: #7C3AED; color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-navy { background: var(--navy); color: #fff; }
html.dark .btn-navy { background: #6D28D9; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }

.fin-input {
    width: 100%; min-height: 42px; padding: 0.6rem 0.9rem;
    border: 1px solid var(--border); border-radius: 0.55rem;
    background: var(--bg-elevated); color: var(--text);
    font: inherit; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}
.fin-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.fin-input::placeholder { color: var(--text-soft); }
select.fin-input { appearance: auto; }
.fin-label { display: block; margin-bottom: 0.4rem; font-size: 0.75rem; font-weight: 650; color: var(--text-muted); }

.filter-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.55rem; border-radius: 0.4rem; font-size: 0.75rem; font-weight: 600;
    background: var(--accent-soft); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
}
.status-badge {
    display: inline-flex; align-items: center; padding: 0.2rem 0.55rem;
    border-radius: 0.4rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; border: 1px solid var(--border);
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table thead th {
    text-align: left; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); padding: 0.75rem 1rem;
    background: var(--bg-muted); border-bottom: 1px solid var(--border);
}
.data-table tbody td {
    padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text);
}
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.status-tab {
    display: inline-flex; padding: 0.45rem 0.75rem; border-radius: 0.5rem;
    font-size: 0.75rem; font-weight: 650; text-decoration: none; white-space: nowrap; color: var(--text-muted);
}
.status-tab:hover { background: var(--bg-muted); color: var(--text); }
.status-tab-active { background: var(--navy); color: #fff; }
html.dark .status-tab-active { background: #7C3AED; color: #fff; }
.status-tab-idle { color: var(--text-muted); }

.alert-success { background: var(--success-bg); border: 1px solid color-mix(in srgb, var(--success) 30%, var(--border)); color: var(--success); padding: 0.75rem 1rem; border-radius: 0.55rem; font-size: 0.9rem; font-weight: 500; }
.alert-error { background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); color: var(--danger); padding: 0.75rem 1rem; border-radius: 0.55rem; font-size: 0.9rem; font-weight: 500; }
.empty-state { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center; }

.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; border: 0; background: transparent;
    color: rgba(255,255,255,.8); cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.1); color: #fff; }

.row-enter { animation: rowIn 280ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes rowIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid rgba(255,255,255,.1);
}
html.dark .main-nav {
    background: linear-gradient(180deg, #4C1D95 0%, #3B0764 100%);
    border-bottom-color: rgba(196, 181, 253, 0.2);
}

details.fin-panel > summary { list-style: none; }
details.fin-panel > summary::-webkit-details-marker { display: none; }

/* Dark readability for leftover Tailwind utility classes */
html.dark .text-surface-900,
html.dark .text-surface-800,
html.dark .text-brand-navy { color: #F5F3FF !important; }
html.dark .text-surface-700,
html.dark .text-surface-600,
html.dark .text-surface-500,
html.dark .text-surface-400 { color: #DDD6FE !important; }
html.dark .bg-white { background-color: var(--bg-elevated) !important; }
html.dark .bg-surface-50,
html.dark .bg-surface-100 { background-color: var(--bg-muted) !important; }
html.dark .border-surface-100,
html.dark .border-surface-200 { border-color: var(--border) !important; }
html.dark .bg-brand-navy { background-color: #5B21B6 !important; }
html.dark .bg-brand-light,
html.dark .bg-brand-teal-light { background-color: #4C1D95 !important; }
html.dark .text-brand-teal { color: #C4B5FD !important; }
html.dark .divide-surface-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border); }
