/* ============================================================================
   Cadence v2 — Design Foundations
   SPEC.md §6.16. Tokens extracted verbatim from the v1 admin layout, which
   already carries the brand's dark/gold identity.

   Rules for every later phase:
     1. Never write a raw colour, radius or spacing value in a view. Use a token.
     2. Never put a <style> block in a view file. That is how v1 ended up with
        600–1000-line views and why the Phase G redesign would otherwise be a
        rewrite instead of a grooming pass.
     3. Safari on macOS is a first-class target — the venue player runs there.
        Every backdrop-filter ships its -webkit- prefix.
     4. Status is a coloured dot PLUS a word. Never colour alone.
   ========================================================================== */

:root {
    /* ── Surfaces ───────────────────────────────────────────────────────── */
    --bg:              #08070b;
    --bg-glow-1:       radial-gradient(1100px 800px at 12% -5%,  rgba(120,96,200,0.16), transparent 60%);
    --bg-glow-2:       radial-gradient(900px 700px at 105% 110%, rgba(216,184,120,0.13), transparent 55%);
    --card:            rgba(255,255,255,0.055);
    --card-border:     rgba(255,255,255,0.09);
    --card-hover:      rgba(255,255,255,0.08);
    --sidebar:         rgba(14,13,18,0.55);
    --hairline:        rgba(255,255,255,0.07);

    /* ── Text ───────────────────────────────────────────────────────────── */
    --text:            #f4f1ea;
    --text-dim:        rgba(244,241,234,0.55);
    --text-dimmer:     rgba(244,241,234,0.35);

    /* ── Brand + status ─────────────────────────────────────────────────── */
    --gold:            #ecd6a6;
    --gold-deep:       #b8945a;
    --gold-gradient:   linear-gradient(150deg, #ecd6a6, #b8945a);
    --on-gold:         #1a1206;
    --green:           #5ec98a;
    --red:             #e8786e;
    --yellow:          #ecc14e;
    --violet:          #7c6cff;

    /* ── Shape ──────────────────────────────────────────────────────────── */
    --radius-card:     20px;
    --radius-btn:      13px;
    --radius-input:    12px;
    --radius-pill:     40px;

    /* ── Spacing scale ──────────────────────────────────────────────────── */
    /* Four-point base. Use these, not arbitrary pixels — consistent rhythm is
       most of what makes a multi-screen product feel designed. */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  24px;
    --space-6:  32px;
    --space-7:  48px;
    --space-8:  64px;

    /* ── Effects ────────────────────────────────────────────────────────── */
    --blur-card:       blur(34px) saturate(150%);
    --blur-sidebar:    blur(40px) saturate(150%);
    --shadow-card:     0 18px 50px -20px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
    --shadow-gold:     0 10px 28px -10px rgba(216,184,120,0.6);
    --shadow-gold-lift:0 14px 32px -10px rgba(216,184,120,0.7);

    /* ── Type ───────────────────────────────────────────────────────────── */
    --font:            'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --fs-display:      26px;
    --fs-h1:           22px;
    --fs-h2:           17px;
    --fs-body:         14px;
    --fs-small:        13px;
    --fs-micro:        12px;
    --fs-label:        10px;

    /* ── Motion ─────────────────────────────────────────────────────────── */
    --ease:            cubic-bezier(0.22, 0.61, 0.36, 1);
    --t-fast:          0.15s;
    --t-base:          0.2s;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: var(--fs-body);
    background: var(--bg);
    color: var(--text);
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    /* Every count, time and duration in this product lines up in a column. */
    font-variant-numeric: tabular-nums;
}

h1, h2, h3 { letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }

a { color: inherit; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: rgba(236,214,166,0.25); }

:focus-visible {
    outline: 2px solid rgba(236,214,166,0.55);
    outline-offset: 2px;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes drift1 { from { transform: translate(-8%,-6%) scale(1); } to { transform: translate(10%,8%) scale(1.18); } }
@keyframes drift2 { from { transform: translate(6%,10%) scale(1.1); } to { transform: translate(-10%,-8%) scale(1); } }
@keyframes pulse  { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Background ─────────────────────────────────────────────────────────── */
.app-bg {
    position: fixed; inset: 0; z-index: 0;
    background: var(--bg-glow-1), var(--bg-glow-2), var(--bg);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app-layout {
    position: relative; z-index: 1;
    display: flex; height: 100vh; width: 100vw; overflow: hidden;
}

.sidebar {
    width: 248px; flex-shrink: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
    padding: var(--space-5) var(--space-4) var(--space-7);
    background: var(--sidebar);
    backdrop-filter: var(--blur-sidebar);
    -webkit-backdrop-filter: var(--blur-sidebar);
    border-right: 1px solid var(--hairline);
}

.main-content { flex: 1; height: 100vh; overflow-y: auto; position: relative; }

.page { padding: var(--space-6) var(--space-7) var(--space-8); max-width: 1180px; }
.page-head { margin-bottom: var(--space-6); animation: fadeUp 0.4s var(--ease) both; }
.page-head h1 { font-size: var(--fs-display); }
.page-head .sub { color: var(--text-dim); margin-top: var(--space-2); max-width: 68ch; line-height: 1.55; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.spacer { flex: 1; }

/* ── Sidebar navigation ─────────────────────────────────────────────────── */
.sidebar-logo { display: flex; align-items: center; gap: 11px; padding: var(--space-1) var(--space-2) var(--space-5); }
.sidebar-logo-icon {
    width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
    background: var(--gold-gradient);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px -6px rgba(216,184,120,0.6);
}
.sidebar-logo-dot { width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid var(--on-gold); }
.sidebar-logo-text { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.sidebar-logo-sub { font-size: var(--fs-label); color: var(--text-dimmer); letter-spacing: 0.08em; text-transform: uppercase; }

.nav-group { margin-bottom: var(--space-4); }
.nav-group-label {
    font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase;
    color: var(--text-dimmer); padding: 0 10px var(--space-2);
}
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: var(--space-2) 10px; border-radius: 11px; margin-bottom: 2px;
    font-size: var(--fs-small); color: var(--text-dim); text-decoration: none;
    border-left: 2px solid transparent;
    transition: background var(--t-base), color var(--t-base);
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active { background: rgba(236,214,166,0.1); color: var(--gold); border-left-color: var(--gold); }
.nav-item.soon { opacity: 0.4; pointer-events: none; }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-dimmer); flex-shrink: 0; }
.nav-item.active .nav-dot { background: var(--gold); }

.sidebar-footer { margin-top: auto; padding-top: var(--space-5); border-top: 1px solid var(--hairline); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    padding: var(--space-5);
    border-radius: var(--radius-card);
    background: var(--card);
    border: 1px solid var(--card-border);
    backdrop-filter: var(--blur-card);
    -webkit-backdrop-filter: var(--blur-card);
    box-shadow: var(--shadow-card);
}
.card-tight { padding: var(--space-4); }
.card-title { font-size: var(--fs-h2); font-weight: 600; margin-bottom: var(--space-1); }
.card-note { font-size: var(--fs-small); color: var(--text-dim); line-height: 1.55; }

/* Stat tile — one number, one label, optional status word. */
.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-value { font-size: var(--fs-display); font-weight: 600; letter-spacing: -0.02em; }
.stat-label { font-size: var(--fs-micro); color: var(--text-dim); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost, .btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: 11px 20px; border-radius: var(--radius-btn);
    font-size: var(--fs-body); font-weight: 600; text-decoration: none;
    transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.btn-primary { color: var(--on-gold); background: var(--gold-gradient); box-shadow: var(--shadow-gold); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-gold-lift); }

.btn-ghost { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: inherit; }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

.btn-danger { background: rgba(232,120,110,0.14); border: 1px solid rgba(232,120,110,0.32); color: #f4a09a; }
.btn-danger:hover { background: rgba(232,120,110,0.22); }

.btn-small { padding: 7px 13px; font-size: var(--fs-micro); border-radius: 10px; }

.btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; }
.field + .field { margin-top: var(--space-3); }
.field-label { font-size: var(--fs-micro); color: var(--text-dim); margin-bottom: 7px; }
.field-input {
    width: 100%; padding: 12px 14px;
    border-radius: var(--radius-input);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text); outline: none;
    transition: border-color var(--t-base);
}
.field-input:focus { border-color: rgba(236,214,166,0.4); }
.field-input::placeholder { color: var(--text-dimmer); }
.field-hint { font-size: var(--fs-micro); color: var(--text-dimmer); margin-top: 6px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
input[type="file"].field-input { padding: 10px 12px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.table th {
    text-align: left; font-size: var(--fs-label); font-weight: 600;
    letter-spacing: 0.11em; text-transform: uppercase; color: var(--text-dimmer);
    padding: 0 var(--space-3) var(--space-2); white-space: nowrap;
}
.table td { padding: var(--space-3); border-top: 1px solid var(--hairline); vertical-align: middle; }
.table tbody tr:hover td { background: rgba(255,255,255,0.025); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ── Status ─────────────────────────────────────────────────────────────── */
/* Always a dot AND a word — colour alone fails for colour-blind users and in
   the strong ambient light of a venue. */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-micro); }
.status-ok   { color: var(--green); }
.status-warn { color: var(--yellow); }
.status-bad  { color: var(--red); }
.status-idle { color: var(--text-dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
.dot-live { animation: pulse 2s ease-in-out infinite; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: var(--radius-pill);
    font-size: var(--fs-micro);
    background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
    color: var(--text-dim);
}
.pill-gold { background: rgba(236,214,166,0.12); border-color: rgba(236,214,166,0.3); color: var(--gold); }

/* ── Meter ──────────────────────────────────────────────────────────────── */
.meter { height: 7px; border-radius: 7px; background: rgba(255,255,255,0.08); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 7px; background: var(--gold-gradient); transition: width var(--t-base); }
.meter-fill.warn { background: linear-gradient(150deg, var(--yellow), #c99b22); }
.meter-fill.bad  { background: linear-gradient(150deg, var(--red), #b8443a); }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash { padding: 12px 18px; border-radius: var(--radius-input); font-size: var(--fs-small); margin-bottom: var(--space-4); line-height: 1.55; }
.flash-ok  { background: rgba(94,201,138,0.12);  border: 1px solid rgba(94,201,138,0.3);  color: #7ddf7d; }
.flash-err { background: rgba(232,120,110,0.12); border: 1px solid rgba(232,120,110,0.3); color: #f4a09a; }
/* Between the two: something is wrong but still working — a subscription in its
   grace days, playing music it has not been paid for. */
.flash-warn { background: rgba(226,178,90,0.12); border: 1px solid rgba(226,178,90,0.32); color: #e8c37a; }

/* ── Empty state ────────────────────────────────────────────────────────── */
/* For the engine-driven product the empty state IS the normal state (§6.4):
   a new venue needs no manual scheduling. So it must read as reassurance,
   never as an error. */
.empty { text-align: center; padding: var(--space-7) var(--space-5); color: var(--text-dim); }
.empty-title { font-size: var(--fs-h2); color: var(--text); margin-bottom: var(--space-2); }
.empty-note { font-size: var(--fs-small); max-width: 46ch; margin: 0 auto; line-height: 1.6; }

/* ── Toggle ─────────────────────────────────────────────────────────────── */
.toggle { width: 50px; height: 28px; border-radius: 14px; position: relative; cursor: pointer; flex-shrink: 0; }
.toggle.on  { background: var(--gold-gradient); }
.toggle.off { background: rgba(255,255,255,0.12); }
.toggle-knob { position: absolute; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--on-gold); transition: left var(--t-base); }
.toggle.on .toggle-knob  { left: 25px; }
.toggle.off .toggle-knob { left: 3px; background: var(--text); }

/* ── Code ───────────────────────────────────────────────────────────────── */
.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: var(--fs-micro);
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--hairline);
    border-radius: 10px;
    padding: var(--space-3);
    overflow-x: auto;
    color: var(--text-dim);
    line-height: 1.6;
    word-break: break-all;
}

/* ── Centred single-card pages (login, installer, errors) ───────────────── */
.centre-wrap { position: relative; z-index: 2; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--space-7) var(--space-4); }
.centre-card { width: 100%; max-width: 440px; padding: var(--space-7); border-radius: 28px; background: var(--card); border: 1px solid var(--card-border); backdrop-filter: var(--blur-sidebar); -webkit-backdrop-filter: var(--blur-sidebar); box-shadow: 0 30px 80px -30px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.1); animation: fadeUp 0.5s var(--ease) both; }
.centre-card.wide { max-width: 720px; }
.orb1 { position: fixed; width: 680px; height: 680px; left: -10%; top: -20%; border-radius: 50%; background: radial-gradient(circle, rgba(124,108,255,0.35), transparent 65%); filter: blur(80px); animation: drift1 19s ease-in-out infinite alternate; }
.orb2 { position: fixed; width: 620px; height: 620px; right: -10%; bottom: -22%; border-radius: 50%; background: radial-gradient(circle, rgba(216,184,120,0.3), transparent 65%); filter: blur(80px); animation: drift2 23s ease-in-out infinite alternate; }
.eyebrow { font-size: var(--fs-micro); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-bottom: var(--space-2); }

/* ── Utilities (deliberately few) ───────────────────────────────────────── */
.dim { color: var(--text-dim); }
.dimmer { color: var(--text-dimmer); }
.gold { color: var(--gold); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-4 { margin-bottom: var(--space-4); }
.nowrap { white-space: nowrap; }

/* ── Narrow screens ─────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    .app-layout { flex-direction: column; height: auto; overflow: visible; }
    .sidebar { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: var(--space-3); border-right: none; border-bottom: 1px solid var(--hairline); }
    .sidebar nav { display: flex; flex-wrap: wrap; gap: var(--space-1); }
    .nav-group { display: flex; margin-bottom: 0; }
    .nav-group-label { display: none; }
    .sidebar-footer { margin: 0 0 0 auto; padding-top: 0; border-top: none; }
    .main-content { height: auto; }
    .page { padding: var(--space-5) var(--space-4) var(--space-7); }
    .field-row { grid-template-columns: 1fr; }
}

/* ── Range inputs ──────────────────────────────────────────────────────────
   A browser's default slider is bright system blue and belongs to no design.
   Styled here rather than per page so every slider in the product — the mixer,
   the player's volume, anything later — is the same control. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-gradient);
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--gold-gradient);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.45; cursor: not-allowed; }
