/* ============================================================
   Kaalateral creator payouts.

   A payout statement, not a metrics dashboard: the page opens by answering
   "what am I owed for this period" in words, and everything below is evidence
   for that number.

   Palette — copper reads as currency and, unlike a green, does not collide with
   the up/down semantics the figures need. Neutrals are biased indigo on dark and
   warm on light so neither ground reads as default grey.
   ============================================================ */

:root {
  --paper:      #FAF8F4;
  --surface:    #FFFFFF;
  --surface-2:  #F2EEE7;
  --line:       #E3DCD1;
  --line-2:     #D2C8B8;
  --ink:        #23201C;
  --ink-soft:   #5E574E;
  --ink-faint:  #8C8378;

  --copper:     #A8672A;
  --copper-2:   #C07C39;
  --copper-wash:#F6EADC;

  --jade:       #3F7F65;
  --rust:       #B24A3D;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(35 32 28 / .05), 0 8px 24px -16px rgb(35 32 28 / .25);

  --sans: "Segoe UI Variable Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --display: "Segoe UI Variable Display", "Segoe UI Semibold", var(--sans);
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #14161D;
    --surface:    #1A1D26;
    --surface-2:  #21242F;
    --line:       #2A2E3A;
    --line-2:     #3A3F4E;
    --ink:        #ECEAE6;
    --ink-soft:   #A7A79F;
    --ink-faint:  #767A85;

    --copper:     #E3A55E;
    --copper-2:   #C98944;
    --copper-wash:#2A2318;

    --jade:       #62B08D;
    --rust:       #DB7A69;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -20px rgb(0 0 0 / .8);
  }
}

/* The viewer's explicit toggle must beat the OS preference in both directions. */
:root[data-theme="dark"] {
  --paper: #14161D; --surface: #1A1D26; --surface-2: #21242F;
  --line: #2A2E3A; --line-2: #3A3F4E;
  --ink: #ECEAE6; --ink-soft: #A7A79F; --ink-faint: #767A85;
  --copper: #E3A55E; --copper-2: #C98944; --copper-wash: #2A2318;
  --jade: #62B08D; --rust: #DB7A69;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -20px rgb(0 0 0 / .8);
}
:root[data-theme="light"] {
  --paper: #FAF8F4; --surface: #FFFFFF; --surface-2: #F2EEE7;
  --line: #E3DCD1; --line-2: #D2C8B8;
  --ink: #23201C; --ink-soft: #5E574E; --ink-faint: #8C8378;
  --copper: #A8672A; --copper-2: #C07C39; --copper-wash: #F6EADC;
  --jade: #3F7F65; --rust: #B24A3D;
  --shadow: 0 1px 2px rgb(35 32 28 / .05), 0 8px 24px -16px rgb(35 32 28 / .25);
}

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

html, body { overflow-x: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient moving background: two big, soft, blurred glows that slowly drift
   behind everything. Their bright centres sit off-screen, so only the faint
   halo bleeds into the page's gaps and gutters — panels stay opaque, so text
   is never over the motion. GPU-composited (transform only); frozen under
   prefers-reduced-motion by the global rule at the end of this file. */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  border-radius: 50%; filter: blur(64px); opacity: .7; will-change: transform;
}
body::before {
  width: 58vmax; height: 58vmax; left: -10vmax; top: -12vmax;
  background: radial-gradient(circle, color-mix(in srgb, var(--copper) 34%, transparent), transparent 70%);
  animation: drift-a 18s ease-in-out infinite alternate;
}
body::after {
  width: 54vmax; height: 54vmax; right: -12vmax; bottom: -14vmax;
  background: radial-gradient(circle, color-mix(in srgb, #5b79d6 30%, transparent), transparent 70%);
  animation: drift-b 24s ease-in-out infinite alternate;
}
@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(22vmax, 14vmax, 0) scale(1.28); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to   { transform: translate3d(-20vmax, -12vmax, 0) scale(1.32); }
}

.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); font-size: .86em; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 4px; }

.loading { min-height: 100vh; display: grid; place-items: center; color: var(--ink-faint); }

/* ---------- sign in ---------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: -.01em; }
/* Animated world GIF shown as-is (full colour + motion), not a mask. */
.brand-logo {
  width: 30px; height: 30px; flex: 0 0 auto; display: inline-block;
  background: url("/world.gif?v=1") center / contain no-repeat;
}
.brand-word { font-weight: 600; letter-spacing: -.01em; }
.signin-card .brand-logo { width: 36px; height: 36px; }
.signin-card h1 { font-family: var(--display); font-size: 25px; font-weight: 600; letter-spacing: -.022em; text-wrap: balance; }
.lede { color: var(--ink-soft); font-size: 14px; max-width: 34ch; }
.foot { color: var(--ink-faint); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid transparent; border-radius: 9px;
  padding: 11px 16px; font: inherit; font-weight: 550; font-size: 14px;
  cursor: pointer; text-decoration: none; transition: filter .12s, background .12s;
}
.btn-discord { background: #5865F2; color: #fff; }
.btn-discord:hover { filter: brightness(1.08); }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }

.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.rail .brand { padding: 2px 8px 0; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav button {
  text-align: left; background: none; border: none; font: inherit; font-size: 14px;
  color: var(--ink-soft); padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.rail nav button:hover { background: var(--surface-2); color: var(--ink); }
.rail nav button[aria-current="true"] { background: var(--copper-wash); color: var(--copper); font-weight: 600; }

.rail-refresh { display: flex; flex-direction: column; gap: 5px; padding: 0 4px; }
.refresh-btn {
  background: var(--copper-wash); color: var(--copper);
  border: 1px solid color-mix(in srgb, var(--copper) 30%, transparent);
  font: inherit; font-size: 13px; font-weight: 550;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background .12s, filter .12s;
}
.refresh-btn:hover { filter: brightness(1.04); background: color-mix(in srgb, var(--copper) 16%, transparent); }
.refresh-btn:disabled { opacity: .6; cursor: default; }
.sync-line { font-size: 11px; color: var(--ink-faint); text-align: center; }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; }
.who .av {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  object-fit: cover;
}
.who .nm { font-size: 13.5px; font-weight: 550; line-height: 1.2; }
.who .rl { font-size: 11.5px; color: var(--ink-faint); }
.linkish {
  background: none; border: 1px solid var(--line-2); color: var(--ink-soft);
  font: inherit; font-size: 12.5px; padding: 7px; border-radius: 8px; cursor: pointer; width: 100%;
}
.linkish:hover { border-color: var(--ink-faint); color: var(--ink); }
/* Quiet footer social links: borderless, muted, divider above. */
.rail-icons { display: flex; gap: 16px; justify-content: center; padding-top: 14px; margin-top: 2px; border-top: 1px solid var(--line); }
.icon-link {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-faint); text-decoration: none; transition: color .12s;
}
.icon-link:hover { color: var(--copper); }
.icon-link svg { display: block; }

/* Centred in the content column and wider, so it fills the page on big screens
   instead of hugging the left edge with a large empty gutter on the right. */
.main { padding: 30px 44px 72px; max-width: 1360px; margin: 0 auto; width: 100%; }

/* ---------- statement head ---------- */

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.head h1 { font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.head .sub { color: var(--ink-soft); font-size: 13.5px; margin-top: 3px; }

.period { display: flex; align-items: center; gap: 8px; }
.period select {
  font: inherit; font-size: 13.5px; padding: 8px 11px; border-radius: 9px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); cursor: pointer;
}

.statement {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 26px; align-items: end;
}
.statement .lbl { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.statement .owed { font-family: var(--display); font-size: 40px; font-weight: 600; letter-spacing: -.035em; line-height: 1; }
.statement .fig { font-family: var(--display); font-size: 23px; font-weight: 600; letter-spacing: -.025em; }
.statement .note { font-size: 12.5px; color: var(--ink-faint); margin-top: 7px; }

.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.delta.up { color: var(--jade); background: color-mix(in srgb, var(--jade) 12%, transparent); }
.delta.dn { color: var(--rust); background: color-mix(in srgb, var(--rust) 12%, transparent); }

/* ---------- panels ---------- */

.grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.panel h2 { font-family: var(--display); font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.panel .sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; margin-bottom: 20px; }
.empty { color: var(--ink-faint); font-size: 13.5px; padding: 20px 0; }

/* chart */
.chart { height: 200px; }
.chart svg { width: 100%; height: 100%; overflow: visible; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-faint); font-size: 10.5px; }
.chart rect.bar { fill: var(--surface-2); transition: fill .12s; }
.chart g:hover rect.bar { fill: var(--line-2); }
.chart g.sel rect.bar { fill: var(--copper); }
.chart .cap { fill: var(--ink-faint); font-size: 10.5px; text-anchor: middle; }
.chart g.sel .cap { fill: var(--copper); font-weight: 600; }

/* package list */
.pkg { display: flex; flex-direction: column; gap: 15px; }
.pkg-row .top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pkg-row .nm { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pkg-row .ct { font-size: 11.5px; color: var(--ink-faint); }
.pkg-row .amt { font-size: 13.5px; font-weight: 600; }
.meter { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--copper); border-radius: 3px; }

/* tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 0 10px 11px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
th.r, td.r { text-align: right; padding-right: 0; }
td.soft { color: var(--ink-soft); }
td.amt { font-weight: 600; }

.chip {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 5px; background: var(--surface-2); color: var(--ink-soft);
}
.chip.warn { background: color-mix(in srgb, var(--rust) 13%, transparent); color: var(--rust); }

/* assign screen */
.search-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.search {
  flex: 1; min-width: 0; font: inherit; font-size: 14px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 10px 13px;
  transition: border-color .12s, box-shadow .12s;
}
.search::placeholder { color: var(--ink-faint); }
.search:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px color-mix(in srgb, var(--copper) 18%, transparent); }
.search-count { font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.filter-sel {
  flex: 0 0 auto; min-width: 190px; font: inherit; font-size: 13.5px; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s;
}
.filter-sel:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px color-mix(in srgb, var(--copper) 18%, transparent); }
@media (max-width: 640px) { .search-bar { flex-wrap: wrap; } .filter-sel { min-width: 0; flex: 1 1 100%; } }

/* calculator */
.cal-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.cal-field { display: flex; flex-direction: column; gap: 6px; }
.cal-field label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.cal-date, .cal-dev {
  font: inherit; font-size: 14px; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 12px;
}
.cal-date { color-scheme: light dark; }
.cal-dev { min-width: 200px; cursor: pointer; }
.cal-date:focus, .cal-dev:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 3px color-mix(in srgb, var(--copper) 18%, transparent); }
.btn-accent { background: var(--copper); color: #fff; border-radius: 9px; padding: 10px 18px; }
.btn-accent:hover { filter: brightness(1.06); }
.cal-go { align-self: flex-end; }
.cal-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.quick-lbl { font-size: 12px; color: var(--ink-faint); margin-right: 2px; }
.chip-btn {
  font: inherit; font-size: 12.5px; cursor: pointer;
  background: var(--surface-2); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; transition: .12s;
}
.chip-btn:hover { border-color: var(--copper); color: var(--copper); }
.chip-btn:disabled { opacity: .4; cursor: default; border-color: var(--line); color: var(--ink-faint); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.pager-info { font-size: 12.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; min-width: 130px; text-align: right; }

/* team + payouts */
.who.inline { gap: 10px; }
.av.sm { width: 26px; height: 26px; border-radius: 7px; font-size: 10.5px; }
.who .nm { font-size: 13.5px; font-weight: 550; line-height: 1.2; }
.who .ct { font-size: 11.5px; color: var(--ink-faint); }
td.amt.due { color: var(--copper); }

.paidbox { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.paidbox input { width: 15px; height: 15px; accent-color: var(--copper); cursor: pointer; }
.paidbox.on { color: var(--jade); }
.paidbox.on input { cursor: default; }
.paycell { white-space: nowrap; }

/* team dropdown */
.team-row .expandable { cursor: pointer; }
.caret { display: inline-block; width: 12px; color: var(--ink-faint); font-size: 10px; transition: color .12s; }
.team-row:hover .caret { color: var(--copper); }
.team-row.expanded { background: var(--surface-2); }
.team-row.expanded .caret { color: var(--copper); }
.team-detail-cell { padding: 0 0 4px 34px; background: var(--surface-2); }
.pack-detail { padding: 4px 0 10px; }
.subtable { width: 100%; border-collapse: collapse; }
.subtable th { font-size: 10.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.subtable td { font-size: 12.5px; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); }
.subtable tr:last-child td { border-bottom: none; }
.subtable tr.nosale td { color: var(--ink-faint); }
.subtable tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: none; padding-top: 9px; color: var(--ink-soft); }
.subtable .pname { font-weight: 500; }

.payout-panel { margin-bottom: 16px; }
.balance { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: stretch; margin-bottom: 8px; }
.owed-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.owed-box.due { border-color: color-mix(in srgb, var(--copper) 45%, var(--line)); background: var(--copper-wash); }
.owed-box .lbl { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.owed-box .owed { font-family: var(--display); font-size: 38px; font-weight: 600; letter-spacing: -.035em; line-height: 1; }
.owed-box.due .owed { color: var(--copper); }
.owed-box .note { font-size: 12.5px; color: var(--ink-faint); margin-top: 8px; }
.balance-side { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.bstat { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.balance-side .bstat:last-child { border-bottom: none; padding-bottom: 0; }
.bstat .lbl { font-size: 12.5px; color: var(--ink-soft); }
.bstat .v { font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.pay-h3 { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin: 18px 0 10px; }
.paylist { display: flex; flex-direction: column; }
.payrow { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.payrow:last-child { border-bottom: none; }
.payamt { font-weight: 600; }
@media (max-width: 640px) { .balance { grid-template-columns: 1fr; } }

.assign-row.unassigned { background: linear-gradient(90deg, color-mix(in srgb, var(--rust) 6%, transparent), transparent 55%); }
.assign-row.unassigned .pname::before { content: "●"; color: var(--rust); font-size: 8px; vertical-align: middle; margin-right: 7px; }
.pname { font-weight: 500; }
select.sel, input.split {
  font: inherit; font-size: 13px; background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px;
}
select.sel { width: 100%; cursor: pointer; }
input.split { width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
.saved { color: var(--jade); font-weight: 700; }
.banner {
  border-radius: var(--radius); padding: 11px 14px; font-size: 13px; margin-bottom: 16px;
  border: 1px solid; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.banner.demo { background: var(--copper-wash); border-color: color-mix(in srgb, var(--copper) 35%, transparent); color: var(--copper); }
.banner.err { background: color-mix(in srgb, var(--rust) 10%, transparent); border-color: color-mix(in srgb, var(--rust) 35%, transparent); color: var(--rust); }
.banner select { font: inherit; font-size: 12.5px; background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 6px; padding: 3px 6px; }

.note-foot { margin-top: 24px; font-size: 12.5px; color: var(--ink-faint); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; }
  .rail-foot { margin-top: 0; flex-direction: row; align-items: center; }
  .rail-foot .linkish { width: auto; }
  .main { padding: 22px 18px 60px; }
  .statement { grid-template-columns: 1fr; gap: 18px; }
  .grid { grid-template-columns: 1fr; }
}

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