/* AI Usage Dashboard — minimal styles */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-openai: #6366f1;
    --color-anthropic: #10b981;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow);
}

.header-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.header-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.header-spacer { flex: 1; }

.header-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .375rem .75rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-sm { padding: .25rem .625rem; font-size: 12px; }
.btn-danger { background: #fef2f2; color: var(--color-danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.filter-control {
    padding: .375rem .625rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font);
    background: var(--color-surface);
    color: var(--color-text);
}
.filter-control:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; border-color: var(--color-primary); }
.filter-control:disabled { background: var(--color-bg); color: var(--color-text-muted); }

.filter-errors {
    width: 100%;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: .5rem .75rem;
    color: var(--color-danger);
    font-size: 12px;
}

/* ── Summary cards ────────────────────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.125rem;
    box-shadow: var(--shadow);
}

.card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .375rem;
}

.card-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -.01em;
}

.card-value-sm {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.card-sub {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: .25rem;
}

.card-openai .card-value { color: var(--color-openai); }
.card-anthropic .card-value { color: var(--color-anthropic); }

/* ── Chart ────────────────────────────────────────────────────────────────── */
.chart-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: .75rem;
}

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

/* ── Tables ───────────────────────────────────────────────────────────────── */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 .75rem 0;
}

.table-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-card-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: .5rem 1rem;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    white-space: nowrap;
}

.data-table th.text-right,
.data-table td.text-right { text-align: right; }

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

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-bg); }

.badge {
    display: inline-block;
    padding: .125rem .4rem;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-priced { background: #d1fae5; color: #065f46; }
.badge-unpriced { background: #fee2e2; color: #991b1b; }
.badge-ambiguous { background: #fef3c7; color: #92400e; }
.badge-openai { background: #ede9fe; color: #4c1d95; }
.badge-anthropic { background: #d1fae5; color: #065f46; }

.pct-bar-cell { min-width: 100px; }
.pct-bar-track {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}
.pct-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width .3s;
}

/* ── Reconciliation ───────────────────────────────────────────────────────── */
.reconciliation-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.recon-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .375rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}
.recon-row:last-child { border-bottom: none; }

.recon-label { color: var(--color-text-muted); }
.recon-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.recon-boundary-note {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--color-border);
    font-style: italic;
}

/* ── Pricing warning ──────────────────────────────────────────────────────── */
.pricing-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 13px;
    color: #92400e;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}
.pricing-warning-icon { flex-shrink: 0; font-size: 16px; }

/* ── Freshness ────────────────────────────────────────────────────────────── */
.freshness-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.freshness-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    box-shadow: var(--shadow);
}

.freshness-provider {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: .5rem;
}

.freshness-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: .2rem 0;
    color: var(--color-text-muted);
}

.freshness-row span:last-child { color: var(--color-text); font-variant-numeric: tabular-nums; }
.freshness-running { color: var(--color-warning); font-weight: 600; }
.freshness-error { color: var(--color-danger); font-size: 11px; margin-top: .25rem; }

/* ── Sync status snippet ──────────────────────────────────────────────────── */
#sync-status {
    font-size: 12px;
    color: var(--color-text-muted);
}
.sync-running { color: var(--color-warning); font-weight: 600; }
.sync-pending { color: var(--color-primary); }

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

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .375rem;
}

.form-input {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--font);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color .15s;
}
.form-input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; border-color: var(--color-primary); }

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: .625rem .875rem;
    color: var(--color-danger);
    font-size: 13px;
    margin-bottom: 1rem;
}

.login-submit {
    width: 100%;
    padding: .625rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background .15s;
}
.login-submit:hover { background: var(--color-primary-hover); }

/* ── Two-column layout for tables ────────────────────────────────────────── */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
    .grid-2col { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.empty-state { color: var(--color-text-muted); text-align: center; padding: 2rem; font-style: italic; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
