/* ==================================================================
   Partner Hub — "Hard border" skin
   2px borders, no radius, no shadows, one soft lime accent.

   Both themes are defined here. Everything downstream uses the tokens,
   so nothing below this block ever needs a dark-mode rule of its own.
   Deliberately kept off pure black and pure white: the paper is warm,
   the ink is charcoal, and the accent is a muted citron rather than a
   fluorescent one — easier to sit in front of for an hour.
   ================================================================== */

:root {
  color-scheme: light;

  --paper:      #f4f3ee;   /* page */
  --fill:       #fbfaf7;   /* panels, inputs */
  --fill-soft:  #eae8e0;   /* panel headers, table headers */
  --ink:        #23231f;   /* body text — charcoal, not black */
  --ink-soft:   #63625b;   /* labels, meta */
  --ink-faint:  #8f8e86;   /* placeholders */
  --line:       #33332d;   /* the 2px borders */
  --rule:       #d8d5c9;   /* hairlines inside tables */
  --lime:       #cbe07a;   /* accent */
  --lime-soft:  #e2ecbe;   /* accent, quieter — chips, tags */
  --lime-ink:   #2c3708;   /* text on the accent */
  --danger:     #b3524f;
  --danger-bg:  #f6e6e4;
  --danger-ink: #6d2a28;
  --ok-bg:      #e6eed6;
  --hover:      #f0eee5;   /* table row hover */

  /* The header bar. In light it is the accent; in dark a big block of
     accent would glare, so it becomes a quiet panel instead. */
  --bar:        #cbe07a;
  --bar-ink:    #2c3708;
  --nav-on-bg:  #33332d;
  --nav-on-ink: #cbe07a;

  --bw:     2px;
  --gap:    16px;
  --sans:   ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:   ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* One dark palette, applied either by the system setting or by the
   toggle in the header. The two selectors carry identical values. */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --paper:      #15161a;
    --fill:       #1d1f24;
    --fill-soft:  #262930;
    --ink:        #e7e6e0;
    --ink-soft:   #a09f98;
    --ink-faint:  #77766f;
    --line:       #565a63;
    --rule:       #343841;
    --lime:       #9cba55;
    --lime-soft:  #2f3a1c;
    --lime-ink:   #10160a;
    --danger:     #d08a86;
    --danger-bg:  #3a2725;
    --danger-ink: #f0cecb;
    --ok-bg:      #29331b;
    --hover:      #23262c;

    --bar:        #202329;
    --bar-ink:    #e7e6e0;
    --nav-on-bg:  #9cba55;
    --nav-on-ink: #10160a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --paper:      #15161a;
  --fill:       #1d1f24;
  --fill-soft:  #262930;
  --ink:        #e7e6e0;
  --ink-soft:   #a09f98;
  --ink-faint:  #77766f;
  --line:       #565a63;
  --rule:       #343841;
  --lime:       #9cba55;
  --lime-soft:  #2f3a1c;
  --lime-ink:   #10160a;
  --danger:     #d08a86;
  --danger-bg:  #3a2725;
  --danger-ink: #f0cecb;
  --ok-bg:      #29331b;
  --hover:      #23262c;

  --bar:        #202329;
  --bar-ink:    #e7e6e0;
  --nav-on-bg:  #9cba55;
  --nav-on-ink: #10160a;
}

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

html { -webkit-text-size-adjust: 100%; background: var(--paper); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { background: var(--lime); color: var(--lime-ink); }

img { max-width: 100%; display: block; }

h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.2; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}
.wrap-narrow { max-width: 560px; }

.stack   { display: flex; flex-direction: column; gap: var(--gap); }
.row     { display: flex; align-items: center; gap: 10px; }
.row-wrap{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* A full-width input inside a wrapping row would claim the whole line and
   push the button below it — let it flex instead. */
.row-wrap > input, .row-wrap > .grow { flex: 1 1 220px; width: auto; }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }

/* ------------------------------------------------------------------
   Top bar
   ------------------------------------------------------------------ */

.topbar {
  background: var(--bar);
  border-bottom: var(--bw) solid var(--line);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px 13px 0;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--bar-ink);
  text-decoration: none;
}
.brand:hover { background: transparent; color: var(--bar-ink); }
.brand-mark {
  width: 20px; height: 20px;
  border: var(--bw) solid var(--bar-ink);
  background: var(--lime);
  flex: none;
}

.nav { display: flex; align-items: stretch; margin-left: auto; }
.nav a, .nav button {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bar-ink);
  text-decoration: none;
  border-left: var(--bw) solid var(--line);
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}
.nav a:hover, .nav button:hover { background: var(--nav-on-bg); color: var(--nav-on-ink); }
.nav a[aria-current="page"] { background: var(--nav-on-bg); color: var(--nav-on-ink); }

.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-left: var(--bw) solid var(--line);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bar-ink);
}

/* ------------------------------------------------------------------
   Panels
   ------------------------------------------------------------------ */

.panel {
  background: var(--fill);
  border: var(--bw) solid var(--line);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: var(--bw) solid var(--line);
  background: var(--fill-soft);
}
.panel-head h2 {
  font-size: 13px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.panel-body { padding: 16px; }
.panel-body + .panel-body { border-top: var(--bw) solid var(--line); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head .sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: var(--bw) solid var(--line);
  border-radius: 0;
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translate(1px, 1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--fill); color: var(--ink); }

.btn-primary { background: var(--lime); color: var(--lime-ink); }
.btn-primary:hover { background: var(--ink); color: var(--lime); }

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 9px; font-size: 11px; letter-spacing: 0.05em; }
.btn-block { width: 100%; }

/* <details> used as a disclosure — the summary is styled as a button, so the
   default triangle has to go in every browser. */
summary { cursor: pointer; }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ""; }
details[open] > summary.btn { background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------------
   Forms
   ------------------------------------------------------------------ */

.field { display: block; margin-bottom: 14px; }
.field > .label,
.label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.hint { margin: 5px 0 0; font-size: 12px; color: var(--ink-soft); }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="date"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: var(--bw) solid var(--line);
  border-radius: 0;
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: none; padding-right: 11px; }

input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--lime);
  outline-offset: 0;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }

input[type="color"] {
  width: 46px; height: 38px; padding: 3px;
  border: var(--bw) solid var(--line); background: var(--fill); cursor: pointer;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 180px; margin-bottom: 14px; }
.field-row > .field.grow { flex: 3 1 280px; }

.check {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
  font-size: 14px;
  cursor: pointer;
}
.check:hover { background: var(--fill-soft); }
.check input { flex: none; }

/* ------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.grid th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--fill-soft);
  border-bottom: var(--bw) solid var(--line);
  white-space: nowrap;
}
table.grid td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--hover); }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------
   Chips, badges, swatches
   ------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}
.chip .pct { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-me { background: var(--lime); color: var(--lime-ink); border-color: var(--lime-ink); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag-published { border-color: var(--ink-soft); color: var(--ink); background: var(--fill-soft); }
.tag-scheduled { border-color: var(--line); color: var(--ink); background: var(--lime-soft); }
.tag-pending   { border-color: var(--lime-ink); color: var(--lime-ink); background: var(--lime); }
:root[data-theme="dark"] .tag-pending { color: var(--lime-ink); }

.swatch {
  width: 12px; height: 12px;
  border: 1px solid var(--ink);
  flex: none;
}
.channel-cell { display: flex; align-items: center; gap: 7px; }

.avatar {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: var(--bw) solid var(--line);
  background: var(--fill-soft);
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  flex: none;
}

/* ------------------------------------------------------------------
   Video rows
   ------------------------------------------------------------------ */

.thumb-cell {
  width: 104px; height: 58px;
  border: var(--bw) solid var(--line);
  background: var(--fill-soft);
  object-fit: cover;
  flex: none;
}
.vtitle { font-weight: 700; text-decoration: none; }
.vtitle:hover { background: var(--lime); }
.vmeta { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

.count-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--ink-soft);
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
}

/* ------------------------------------------------------------------
   Thumbnail gallery
   ------------------------------------------------------------------ */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.thumb {
  border: var(--bw) solid var(--line);
  background: var(--fill);
  display: flex;
  flex-direction: column;
}
.thumb.is-final { outline: 3px solid var(--lime-ink); outline-offset: 3px; }
.thumb.is-final .thumb-bar { background: var(--lime); color: var(--lime-ink); }
.thumb-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--fill-soft);
  border-bottom: var(--bw) solid var(--line);
}
.thumb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 6px 8px;
  font-size: 11px; color: var(--ink-soft);
  font-family: var(--mono);
}
.thumb-actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--rule);
}
.thumb-actions > form { display: flex; flex: 1 1 auto; }
.thumb-actions .btn {
  flex: 1 1 auto;
  border: 0;
  border-right: 1px solid var(--rule);
  padding: 7px 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.thumb-actions > *:last-child .btn,
.thumb-actions > .btn:last-child { border-right: 0; }
/* Second row: the fiddly controls get their own line so nothing is 12px wide. */
.thumb-actions-minor .btn { font-size: 12px; padding: 5px 4px; }
.thumb-actions-minor > form { flex: 1 1 0; }
.final-flag {
  padding: 1px 6px;
  background: var(--lime); color: var(--lime-ink);
  border: 1px solid var(--lime-ink);
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}

.dropzone {
  border: var(--bw) dashed var(--line);
  background: var(--fill-soft);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over { background: var(--lime); color: var(--lime-ink); }
.dropzone:hover .eyebrow, .dropzone.over .eyebrow { color: var(--lime-ink); }
.dropzone p { margin: 0; font-size: 13px; }
.dropzone .eyebrow { margin-bottom: 4px; }

.bar {
  height: 12px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--lime); width: 0; }

/* ------------------------------------------------------------------
   Splits editor
   ------------------------------------------------------------------ */

.split-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
}
.split-row + .split-row { border-top: 0; }
.split-row .name { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 14px; }
.split-row input[type="number"] { width: 88px; text-align: right; font-family: var(--mono); }
.split-total {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border: var(--bw) solid var(--line);
  border-top: 0;
  background: var(--fill-soft);
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
}
.split-total .amount { font-family: var(--mono); font-size: 15px; letter-spacing: 0; }
.split-total.bad { background: var(--danger-bg); color: var(--danger); }
.split-total.good { background: var(--lime); color: var(--lime-ink); }

/* ------------------------------------------------------------------
   Messages
   ------------------------------------------------------------------ */

.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border: var(--bw) solid var(--line);
  background: var(--ok-bg);
  font-size: 14px;
  margin-bottom: var(--gap);
}
.flash-err { background: var(--danger-bg); border-color: var(--danger); color: var(--danger-ink); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.empty h3 { margin-bottom: 6px; color: var(--ink); }
.empty p { margin: 0 0 14px; font-size: 14px; }

.divider { height: var(--bw); background: var(--line); border: 0; margin: 0; }

/* ------------------------------------------------------------------
   Summary tiles
   ------------------------------------------------------------------ */

/* Flex rather than grid: the last row stretches to fill, so a wrapped row
   never leaves a hole, and the -2px margins collapse neighbouring borders. */
.tiles { display: flex; flex-wrap: wrap; }
.tile {
  flex: 1 1 150px;
  background: var(--fill);
  border: var(--bw) solid var(--line);
  margin: 0 -2px -2px 0;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
}
a.tile:hover { background: var(--lime); }
.tile .k {
  display: block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-soft);
}
.tile .v {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 22px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tile .n { display: block; font-size: 11px; color: var(--ink-soft); }
.tile-accent { background: var(--lime); color: var(--lime-ink); }
.tile-accent .k, .tile-accent .n, .tile-accent .v { color: var(--lime-ink); }

/* ------------------------------------------------------------------
   Title options
   ------------------------------------------------------------------ */

.opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
}
.opt + .opt { border-top: 0; }
.opt.is-chosen { background: var(--lime); color: var(--lime-ink); }
.opt.is-chosen .len { color: var(--lime-ink); border-color: var(--lime-ink); }
.opt .txt { flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }
.opt .by { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; color: var(--ink-soft); letter-spacing: 0.03em; }
.opt.is-chosen .by { color: var(--lime-ink); }
.opt .len {
  font-family: var(--mono); font-size: 11px; color: var(--ink-soft);
  border: 1px solid var(--rule); padding: 1px 5px; white-space: nowrap;
}
.opt .len.over { border-color: var(--danger); color: var(--danger); }
.opt-actions { display: flex; gap: 6px; flex: none; }

.linkline {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border: var(--bw) solid var(--line);
  background: var(--fill);
  font-size: 13px;
  word-break: break-all;
}
.linkline + .linkline { border-top: 0; }
.linkline .k {
  flex: none; width: 78px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-soft);
}

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
}
.filters .field { margin-bottom: 0; flex: 1 1 150px; }
.filters .field-search { flex: 2 1 220px; }

/* ------------------------------------------------------------------
   Login
   ------------------------------------------------------------------ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-mark {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--bar);
  border-bottom: var(--bw) solid var(--line);
  font-weight: 700; font-size: 15px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--bar-ink);
}

/* ------------------------------------------------------------------
   Mobile — tables become stacked cards
   ------------------------------------------------------------------ */

@media (max-width: 720px) {
  .wrap { padding: 16px 14px 56px; }

  .topbar-inner { padding: 0 14px; }
  .brand { padding-right: 10px; }
  .nav { width: 100%; margin-left: 0; flex-wrap: wrap; border-top: var(--bw) solid var(--line); }
  .nav a {
    flex: 1 1 40%;
    justify-content: center;
    padding: 11px 6px;
    font-size: 11px;
    letter-spacing: 0.05em;
    border-left: 0;
    border-right: var(--bw) solid var(--line);
    border-bottom: var(--bw) solid var(--line);
    margin-bottom: -2px;
  }
  .nav a:last-child { border-right: 0; }
  .whoami { margin-left: auto; border-left: 0; padding: 8px 0 8px 12px; }

  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid thead { display: none; }
  table.grid tr {
    border: var(--bw) solid var(--line);
    background: var(--fill);
    margin-bottom: 12px;
  }
  table.grid tr:last-child { margin-bottom: 0; }
  table.grid td {
    border-bottom: 1px solid var(--rule);
    padding: 9px 12px;
  }
  table.grid td:last-child { border-bottom: 0; }
  table.grid td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--ink-faint);
  }
  table.grid td.num { text-align: left; }
  table.grid tbody tr:hover td { background: transparent; }

  .thumb-cell { width: 170px; max-width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .thumbs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media print {
  .topbar, .btn, .filters { display: none !important; }
  body { background: #fff; }
}
