/* ============================================================================
   Cowboys AC Admin — site stylesheet
   Theme tokens lifted directly from cowboys v2 (charcoal + gold + red).
   See docs/ARCHITECTURE.md "Theme" section.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    /* Backgrounds — same scale as cowboys v2 */
    --bg-deep:        #0a1828;
    --bg-primary:     #0f1f33;
    --bg-secondary:   #1a2a42;
    --bg-surface:     #1f3550;
    --bg-elevated:    #2a3f5f;
    --bg-glass:       rgba(15, 31, 51, 0.88);

    /* Gold */
    --gold:           #d4a574;
    --gold-bright:    #e0ad4a;
    --gold-dim:       #b48954;
    --gold-deep:      #7a5b30;
    --gold-glow:      rgba(212, 165, 116, 0.35);
    --gold-subtle:    rgba(212, 165, 116, 0.10);
    --gold-border:    rgba(212, 165, 116, 0.25);

    /* Red */
    --red:            #e63946;
    --red-bright:     #ff4d5c;
    --red-dim:        #b71c2c;
    --red-deep:       #8b1520;
    --red-glow:       rgba(230, 57, 70, 0.40);
    --red-subtle:     rgba(230, 57, 70, 0.12);
    --red-border:     rgba(230, 57, 70, 0.35);

    /* Text */
    --text-primary:   #ffffff;
    --text-secondary: rgba(220, 230, 245, 0.75);
    --text-muted:     rgba(180, 200, 220, 0.50);
    --text-gold:      #e0ad4a;

    /* Status */
    --success:        #22c55e;
    --error:          #e63946;
    --warning:        #f59e0b;

    /* Type */
    --font-display:   'Outfit', system-ui, sans-serif;
    --font-body:      'Outfit', system-ui, sans-serif;
    --font-mono:      'JetBrains Mono', ui-monospace, monospace;
    --font-accent:    'Playfair Display', Georgia, serif;

    /* Space */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --space-4xl: 6rem;

    /* Radii */
    --radius-sm:  0.375rem;
    --radius-md:  0.75rem;
    --radius-lg:  1.25rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.50);
    --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.55);
    --shadow-lg:  0 12px 40px rgba(0, 0, 0, 0.70);
    --shadow-gold: 0 0 30px rgba(212, 165, 116, 0.18);

    --container-max: 1440px;
    --nav-height: 72px;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100dvh;
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(212, 165, 116, 0.10), transparent 60%),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(230, 57, 70, 0.05), transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; background: none; border: none; cursor: pointer; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: var(--gold); color: var(--bg-deep); }

:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 clamp(1.25rem, 4vw, 3rem);
}

/* ─── Top nav ────────────────────────────────────────────────────────── */
.topnav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--gold-border);
    height: var(--nav-height);
}
.topnav__inner {
    display: flex;
    align-items: center;
    height: 100%;
    gap: var(--space-xl);
}
.topnav__brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: 0.02em;
    font-size: 1.05rem;
}
.topnav__brand .mark {
    color: var(--gold-bright);
    font-size: 1.25rem;
    line-height: 1;
}
.topnav__brand .tag {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-left: var(--space-sm);
    padding-left: var(--space-sm);
    border-left: 1px solid var(--gold-border);
}
.topnav__links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-left: auto;
    font-size: 0.9rem;
}
.topnav__link {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: color 160ms ease, background 160ms ease;
}
.topnav__link:hover { color: var(--text-primary); background: var(--gold-subtle); }
.topnav__link.is-active {
    color: var(--gold-bright);
    background: var(--gold-subtle);
}
.topnav__user {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-left: var(--space-md);
}
.topnav__logout {
    margin-left: var(--space-sm);
    color: var(--red-bright);
    font-size: 0.85rem;
}

/* ─── Page header ────────────────────────────────────────────────────── */
.page-header {
    padding: var(--space-2xl) 0 var(--space-lg);
}
.page-header h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    letter-spacing: -0.01em;
    line-height: 1.1;
}
.page-header .eyebrow {
    font-family: var(--font-mono);
    color: var(--gold-bright);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    margin-bottom: var(--space-sm);
}
.page-header .lede {
    color: var(--text-secondary);
    margin-top: var(--space-sm);
    max-width: 60ch;
}
.page-header__row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--gold-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
}
.card--padded { padding: var(--space-2xl); }
.card h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    margin-bottom: var(--space-sm);
}
.card .caption {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
}

.grid {
    display: grid;
    gap: var(--space-lg);
}
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

/* ─── KPI stat card ──────────────────────────────────────────────────── */
.stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}
.stat__label {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.stat__value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 2rem;
    color: var(--gold-bright);
    letter-spacing: -0.01em;
}
.stat__value.is-negative { color: var(--red-bright); }
.stat__sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    transition: transform 120ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
    border: 1px solid transparent;
    user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
    background: var(--gold-bright);
    color: var(--bg-deep);
    box-shadow: var(--shadow-gold);
}
.btn--primary:hover { background: var(--gold); }
.btn--ghost {
    background: transparent;
    color: var(--gold-bright);
    border-color: var(--gold-border);
}
.btn--ghost:hover { background: var(--gold-subtle); }
.btn--danger {
    background: var(--red);
    color: white;
}
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th, .table td {
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--gold-border);
    vertical-align: top;
}
.table th {
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: var(--nav-height);
    z-index: 5;
}
.table td.num,
.table th.num { text-align: right; font-family: var(--font-mono); }
.table tbody tr:hover { background: rgba(212, 165, 116, 0.04); }
.table .pos { color: var(--gold-bright); }
.table .neg { color: var(--red-bright); }

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--gold-border);
    background: var(--bg-surface);
}

/* ─── Forms ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-md); }
.field__label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}
.field input, .field select, .field textarea {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--gold-border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--gold-bright);
    box-shadow: 0 0 0 3px var(--gold-subtle);
}

.filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: end;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--gold-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}
.filterbar .field { margin-bottom: 0; min-width: 160px; }

/* ─── Badges ─────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border-radius: var(--radius-full);
    background: var(--gold-subtle);
    color: var(--gold-bright);
    border: 1px solid var(--gold-border);
}
.badge--vip      { background: var(--gold-bright); color: var(--bg-deep); border-color: transparent; }
.badge--active   { background: rgba(34, 197, 94, 0.15); color: var(--success); border-color: rgba(34, 197, 94, 0.40); }
.badge--lapsed   { background: rgba(245, 158, 11, 0.12); color: var(--warning); border-color: rgba(245, 158, 11, 0.40); }
.badge--lost     { background: var(--red-subtle); color: var(--red-bright); border-color: var(--red-border); }
.badge--oneshot  { background: rgba(180, 200, 220, 0.10); color: var(--text-secondary); }

/* ─── Alerts ─────────────────────────────────────────────────────────── */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gold-border);
    background: var(--gold-subtle);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
}
.alert--error  { background: var(--red-subtle); border-color: var(--red-border); color: var(--red-bright); }
.alert--info   { background: var(--gold-subtle); border-color: var(--gold-border); color: var(--gold-bright); }

/* ─── Login page ─────────────────────────────────────────────────────── */
.page-login {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(212, 165, 116, 0.18), transparent 60%),
        radial-gradient(ellipse 60% 50% at 50% 100%, rgba(230, 57, 70, 0.12), transparent 60%),
        var(--bg-deep);
}
.login-shell { width: min(420px, calc(100% - 2rem)); }
.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--gold-border);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-lg);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    font-family: var(--font-display);
    font-weight: 800;
}
.login-brand__mark { color: var(--gold-bright); font-size: 1.4rem; }
.login-brand__tag {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.login-heading {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.75rem;
}
.login-sub { color: var(--text-secondary); margin-top: var(--space-xs); margin-bottom: var(--space-xl); }
.login-foot {
    margin-top: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ─── Sync badge ─────────────────────────────────────────────────────── */
.syncbadge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px solid var(--gold-border);
    border-radius: var(--radius-full);
    padding: 0.3rem 0.75rem;
    background: var(--bg-secondary);
}
.syncbadge .dot {
    width: 6px; height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}
.syncbadge.is-stale .dot { background: var(--warning); box-shadow: 0 0 8px rgba(245, 158, 11, 0.6); }
.syncbadge.is-error .dot { background: var(--red-bright); box-shadow: 0 0 8px rgba(255, 77, 92, 0.6); }

/* ─── Footer ─────────────────────────────────────────────────────────── */
.footer {
    margin-top: var(--space-3xl);
    padding: var(--space-xl) 0;
    border-top: 1px solid var(--gold-border);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

/* ─── Helpers ────────────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }
.gold { color: var(--gold-bright); }
.red  { color: var(--red-bright); }
.spacer-md { height: var(--space-md); }
.spacer-lg { height: var(--space-lg); }
