/* JT Marlon client portal
 *
 * Tokens are lifted from studio.html so the portal reads as the same brand,
 * but written by hand rather than pulled from the Tailwind CDN: compiling
 * styles in the browser needs a script-src exception, and nothing behind a
 * login should carry one. See lib/http.php for the CSP this pairs with.
 *
 * The portal is dark-only by design — it is the night half of the marketing
 * site, not a document that follows the reader's OS theme.
 */

:root {
  --night:    #0A0A0A;
  --panel:    #131315;
  --panel-2:  #18181B;
  --line:     rgba(255, 255, 255, 0.10);
  --line-2:   rgba(255, 255, 255, 0.16);

  --ink:      #EDEDEF;
  --ink-2:    #9A9AA3;
  /* 4.87:1 on --panel. The muted step carries a lot of small text — captions,
   * row meta, axis ticks at 11px — so it has to clear AA for body sizes, not
   * just for large text. A darker grey looked better and failed. */
  --ink-3:    #82828B;

  --gold:     #D9B45B;
  --gold-lo:  rgba(217, 180, 91, 0.12);

  /* Chart tokens. Contrast against --panel: gold 9.4:1, de-emphasis 5.4:1,
   * grid 1.2:1 (recessive by intent). */
  --mark:      #D9B45B;
  --mark-soft: rgba(217, 180, 91, 0.10);  /* area wash — 10%, never a block */
  --mark-dim:  #8A8A93;                   /* de-emphasis for sparkline context */
  --grid:      #26262B;

  /* Status. Reserved for state; never reused as a series color. */
  --good:  #58B368;
  --warn:  #E0A33E;
  --crit:  #E06C6C;

  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --radius: 1rem;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  font-family: 'Lato', system-ui, sans-serif;
  color: var(--ink);
  background: var(--night);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--gold); color: var(--night);
  padding: 0.6rem 1rem; font-weight: 800; z-index: 100;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ── glass, borrowed from studio.html ─────────────────────────────────────── */
.glass {
  background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 60%, rgba(255,255,255,0.06) 100%);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 16px 48px rgba(0,0,0,0.5);
}

.gold {
  background: linear-gradient(160deg, #F7E6A8 0%, #E3C46C 30%, #D9B45B 45%, #8C6A2F 65%, #EBD188 88%, #C9A54A 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ── top bar ──────────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 50; padding: 0.75rem 1rem 0; }

.topbar-inner {
  max-width: 78rem; margin: 0 auto; border-radius: 9999px;
  min-height: 3.5rem; padding: 0.4rem 0.6rem 0.4rem 1.25rem;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}

.brand {
  font-weight: 900; text-transform: uppercase; letter-spacing: 0.02em;
  font-size: 1.05rem; color: var(--ink); flex: none;
}
.brand:hover { text-decoration: none; }

.mainnav { display: flex; gap: 0.15rem; flex-wrap: wrap; }
.mainnav a {
  color: var(--ink-2); font-size: 0.88rem; font-weight: 700;
  padding: 0.45rem 0.85rem; border-radius: 9999px;
  transition: color 180ms ease, background 180ms ease;
}
.mainnav a:hover { color: var(--ink); background: rgba(255,255,255,0.05); text-decoration: none; }
.mainnav a.on { color: var(--ink); background: rgba(255,255,255,0.10); }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

.who { display: none; line-height: 1.15; text-align: right; }
.who-name { display: block; font-size: 0.82rem; font-weight: 800; }
.who-client { display: block; font-size: 0.72rem; color: var(--ink-2); }
@media (min-width: 640px) { .who { display: block; } }

.signout { margin: 0; }

/* ── buttons ──────────────────────────────────────────────────────────────── */
.btn-gold, .btn-ghost {
  font-family: inherit; font-weight: 800; font-size: 0.85rem;
  border-radius: 9999px; padding: 0.6rem 1.15rem; cursor: pointer;
  border: 1px solid transparent; transition: transform 160ms var(--ease), background 200ms ease;
}
.btn-gold:active, .btn-ghost:active { transform: scale(0.97); }

.btn-gold {
  color: var(--night);
  background: linear-gradient(150deg, #F7E6A8 0%, #DDBA5F 28%, #A8842F 52%, #EBD188 76%, #C9A54A 100%);
  background-size: 200% 200%; background-position: 0 0;
  border-color: rgba(255,246,214,0.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 6px 22px rgba(217,180,91,0.3);
  transition: background-position 500ms var(--ease), transform 160ms var(--ease);
}
.btn-gold:hover { background-position: 90% 90%; }

.btn-ghost {
  color: var(--ink-2); background: rgba(255,255,255,0.06);
  border-color: var(--line-2);
}
.btn-ghost:hover { color: var(--ink); background: rgba(255,255,255,0.12); }

/* ── layout ───────────────────────────────────────────────────────────────── */
.wrap { max-width: 78rem; margin: 0 auto; padding: 2rem 1rem 4rem; }

.pagehead { margin-bottom: 1.75rem; }
.pagehead h1 {
  font-size: clamp(1.9rem, 5vw, 2.9rem); font-weight: 900;
  text-transform: uppercase; letter-spacing: -0.03em; margin: 0 0 0.35rem;
}
.pagehead p { margin: 0; color: var(--ink-2); font-weight: 700; font-size: 0.95rem; }

.eyebrow {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gold); margin: 0 0 0.4rem;
}

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem;
}

.panel-title {
  font-weight: 800; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-2); margin: 0 0 0.9rem;
}

/* ── filter row — one row, above everything it scopes ─────────────────────── */
.filters {
  display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.filters .flabel {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-3); margin-right: 0.35rem;
}
.chipbtn {
  font-family: inherit; font-size: 0.8rem; font-weight: 700;
  color: var(--ink-2); background: rgba(255,255,255,0.04);
  border: 1px solid var(--line); border-radius: 9999px;
  padding: 0.4rem 0.85rem; cursor: pointer;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}
.chipbtn:hover { color: var(--ink); background: rgba(255,255,255,0.09); }
.chipbtn[aria-pressed="true"] {
  color: var(--night); border-color: rgba(255,246,214,0.5);
  background: linear-gradient(150deg, #F7E6A8 0%, #DDBA5F 35%, #A8842F 100%);
}

/* ── KPI row of stat tiles ────────────────────────────────────────────────── */
.kpis {
  display: grid; gap: 0.85rem; margin-bottom: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
}

.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.15rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.15rem;
  text-align: left; width: 100%; font-family: inherit; cursor: pointer;
  transition: border-color 200ms ease, transform 200ms var(--ease);
}
.tile:hover { border-color: var(--line-2); transform: translateY(-2px); }
.tile[aria-pressed="true"] { border-color: rgba(217,180,91,0.55); background: var(--panel-2); }

.tile-label {
  font-size: 0.78rem; font-weight: 800; color: var(--ink-2);
  letter-spacing: 0.01em;
}
/* Proportional figures: tabular-nums makes a large standalone number look
 * loose. Tabular is for the columns further down the page. */
.tile-value {
  font-size: 1.85rem; font-weight: 900; letter-spacing: -0.02em;
  line-height: 1.1; margin-top: 0.15rem;
}
.tile-foot { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 0.1rem; }
.tile-delta { font-size: 0.78rem; font-weight: 800; }
.tile-delta.up { color: var(--good); }
.tile-delta.down { color: var(--crit); }
.tile-delta.flat { color: var(--ink-3); }
.tile-caption { font-size: 0.72rem; color: var(--ink-3); font-weight: 700; }
.tile-spark { margin-top: 0.6rem; display: block; width: 100%; height: 34px; }

/* ── the chart ────────────────────────────────────────────────────────────── */
.chartcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }

.charthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
.charthead h2 { margin: 0; font-size: 1.05rem; font-weight: 900; letter-spacing: -0.01em; }
.charthead p { margin: 0.15rem 0 0; font-size: 0.78rem; color: var(--ink-3); font-weight: 700; }

.chartbox { position: relative; margin-top: 0.75rem; }
.chartbox.loading { opacity: 0.45; }          /* refetch keeps the frame */
.chartbox svg { display: block; width: 100%; height: auto; touch-action: pan-y; }

/* Axis text wears text tokens — never the series color. */
.axis { fill: var(--ink-3); font-size: 11px; font-weight: 700; }
.axis-tabular { font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.mark-line { fill: none; stroke: var(--mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.mark-area { fill: var(--mark-soft); }
.mark-dot { fill: var(--mark); stroke: var(--panel); stroke-width: 2; }  /* 2px surface ring */
.mark-label { fill: var(--ink); font-size: 12px; font-weight: 800; }
.crosshair { stroke: var(--line-2); stroke-width: 1; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 0.6rem; padding: 0.5rem 0.7rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  transform: translate(-50%, -115%); white-space: nowrap;
  transition: opacity 120ms ease;
}
.tooltip[hidden] { display: none; }
.tt-value { font-size: 0.95rem; font-weight: 900; display: flex; align-items: center; gap: 0.4rem; }
.tt-key { width: 12px; height: 2px; background: var(--mark); border-radius: 2px; flex: none; }
.tt-date { font-size: 0.72rem; color: var(--ink-2); font-weight: 700; margin-top: 0.1rem; }

.tabletoggle { margin-top: 0.9rem; }
.datatable { width: 100%; border-collapse: collapse; margin-top: 0.75rem; font-size: 0.82rem; }
.datatable th, .datatable td {
  text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line);
}
.datatable th { color: var(--ink-3); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.datatable td:last-child, .datatable th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.tablescroll { max-height: 20rem; overflow: auto; }

/* ── builder ──────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#preview {
  display: block; width: 100%; height: 34rem; margin-top: 0.75rem;
  border: 1px solid var(--line); border-radius: 0.75rem;
  background: #fff;   /* generated pages assume a page ground of their own */
}
#preview[hidden] { display: none; }

/* The live document as it streams in. Monospace, and scrolled to the tail so
 * the newest lines stay in view without the reader chasing them. */
.codeblock {
  margin: 0; padding: 0.9rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem; line-height: 1.55; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
}

.buildbar {
  margin-top: 0.75rem; height: 2px; border-radius: 2px;
  background: rgba(255,255,255,0.08); overflow: hidden;
}
.buildbar span {
  display: block; height: 100%; width: 30%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: build-sweep 1.4s ease-in-out infinite;
}
@keyframes build-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(430%); }
}

/* ── lists: requests, invoices, files ─────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.row {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.15rem;
}
.row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.row-title { margin: 0; font-size: 1rem; font-weight: 900; letter-spacing: -0.01em; }
.row-meta { font-size: 0.75rem; color: var(--ink-3); font-weight: 700; }
.row-body { margin: 0.5rem 0 0; color: var(--ink-2); font-size: 0.88rem; font-weight: 700; line-height: 1.55; white-space: pre-wrap; }

/* Status pills carry an icon and a word, never color alone. */
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.25rem 0.6rem; border-radius: 9999px;
  border: 1px solid currentColor; white-space: nowrap;
}
.pill-open        { color: var(--ink-2); }
.pill-in_progress { color: var(--gold); }
.pill-blocked     { color: var(--crit); }
.pill-done        { color: var(--good); }
.pill-paid        { color: var(--good); }
.pill-sent        { color: var(--gold); }
.pill-overdue     { color: var(--crit); }
.pill-draft, .pill-void { color: var(--ink-3); }

.comments { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.75rem; display: flex; flex-direction: column; gap: 0.6rem; }
.comment { font-size: 0.85rem; font-weight: 700; line-height: 1.5; }
.comment-who { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); display: block; margin-bottom: 0.15rem; }
.comment.staff .comment-who { color: var(--gold); }

.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius);
  padding: 2.5rem 1.25rem; text-align: center; color: var(--ink-2); font-weight: 700;
}

/* ── forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); }

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  font-family: inherit; font-size: 0.92rem; font-weight: 700; color: var(--ink);
  background: rgba(0,0,0,0.35); border: 1px solid var(--line-2);
  border-radius: 0.65rem; padding: 0.7rem 0.85rem; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); outline: none; }
textarea { min-height: 7rem; resize: vertical; line-height: 1.55; }
select { appearance: none; }

.hint { font-size: 0.75rem; color: var(--ink-3); font-weight: 700; margin: 0.1rem 0 0; }

.alert {
  background: rgba(224, 108, 108, 0.12); border: 1px solid var(--crit);
  color: #F3C7C7; border-radius: 0.65rem; padding: 0.7rem 0.9rem;
  font-size: 0.85rem; font-weight: 700; margin: 0 0 1rem;
}
.notice {
  background: var(--gold-lo); border: 1px solid rgba(217,180,91,0.45);
  color: #F0DFAF; border-radius: 0.65rem; padding: 0.7rem 0.9rem;
  font-size: 0.85rem; font-weight: 700; margin: 0 0 1rem;
}

/* ── signed-out screens ───────────────────────────────────────────────────── */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1.5rem; }
.authwrap { width: 100%; max-width: 25rem; }
.authcard { border-radius: 1.5rem; padding: 2rem 1.75rem; }
.authbrand { display: block; font-size: 1.15rem; margin-bottom: 1.5rem; }
.authtitle { font-size: 1.6rem; font-weight: 900; text-transform: uppercase; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.authsub { margin: 0 0 1.35rem; color: var(--ink-2); font-size: 0.88rem; font-weight: 700; line-height: 1.5; }
.authform label { display: block; margin-bottom: 0.35rem; }
.authform input { margin-bottom: 0.9rem; }
.authform .hint { margin: -0.6rem 0 0.9rem; }
.authform .btn-gold { width: 100%; margin-top: 0.35rem; padding: 0.8rem 1rem; }
.authnote { margin: 1.25rem 0 0; font-size: 0.78rem; color: var(--ink-3); font-weight: 700; line-height: 1.55; }

/* ── footer ───────────────────────────────────────────────────────────────── */
.foot { border-top: 1px solid var(--line); padding: 1.5rem 1rem; text-align: center; }
.foot p { margin: 0; font-size: 0.78rem; color: var(--ink-3); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
