/* Salt Media Studio — same identity as saltmedia.co.za: white, black, grey; Bodoni display, Hanken body, Plex Mono labels */
:root {
  --ground: #fbfbfa; --surface: #ffffff; --sunk: #f1f1ef; --ink: #0b0b0b; --muted: #6a6a67; --faint: #9a9a96;
  --line: rgba(11,11,11,.12); --on-ink: #fbfbfa;
  --good: #2f6b45; --warn: #9a6a12; --bad: #a3392e;
  --show-light: block; --show-dark: none;
  --display: "Bodoni Moda", Didot, Georgia, serif;
  --body: "Hanken Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0a0a0a; --surface: #131313; --sunk: #1b1b1b; --ink: #f2f2f0; --muted: #a0a09c; --faint: #6f6f6b;
    --line: rgba(242,242,240,.13); --on-ink: #0a0a0a;
    --good: #7cc495; --warn: #e2b459; --bad: #ef8a7e;
    --show-light: none; --show-dark: block; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 400 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }
.label { font: 600 .66rem/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.boot { padding: 40px; color: var(--muted); }

/* Logo */
.logo { display: inline-flex; line-height: 0; }
.logo img { height: 40px; width: auto; }
.logo .l-light { display: var(--show-light); mix-blend-mode: multiply; }
.logo .l-dark { display: var(--show-dark); mix-blend-mode: screen; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--on-ink);
  padding: 10px 16px; font: 600 .74rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; text-decoration: none; border-radius: 0; white-space: nowrap; }
.btn:hover { opacity: .85; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.btn.small { padding: 7px 11px; font-size: .68rem; }
.btn.danger { background: transparent; color: var(--bad); border-color: currentColor; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.auth-card { width: min(400px, 100%); display: grid; gap: 22px; }
.auth-card .logo img { height: 64px; }
.auth-card form { display: grid; gap: 16px; }
.notice { padding: 12px 14px; background: var(--sunk); border-left: 2px solid var(--ink); font-size: .92rem; }
.notice.bad { border-color: var(--bad); }

/* Fields */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font: 600 .66rem/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); padding: 10px 12px; border-radius: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
textarea { min-height: 84px; resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); padding: 6px 10px; font-size: .86rem; cursor: pointer; }
.checks input { accent-color: var(--ink); }
.checkline { display: flex; gap: 8px; align-items: center; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 24px 18px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.side nav { display: grid; gap: 2px; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-decoration: none; color: var(--muted); font-weight: 500; }
.navlink svg { width: 18px; height: 18px; flex: none; }
.navlink:hover { color: var(--ink); background: var(--sunk); }
.navlink.on { color: var(--ink); background: var(--sunk); box-shadow: inset 2px 0 0 var(--ink); }
.side .who { margin-top: auto; display: grid; gap: 8px; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
main#view { padding: 32px max(20px, env(safe-area-inset-right)) 96px max(20px, env(safe-area-inset-left)); max-width: 1180px; width: 100%; min-width: 0; }
.tabs { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main#view { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tabs { display: grid; grid-template-columns: repeat(var(--n, 4), 1fr); position: fixed; inset: auto 0 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right)); z-index: 20; }
  .tabs a { display: grid; justify-items: center; gap: 3px; padding: 6px 2px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 500; }
  .tabs a svg { width: 20px; height: 20px; }
  .tabs a.on { color: var(--ink); }
}

/* Page */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--ink); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); margin-bottom: 32px; background: var(--surface); }
.stat { padding: 18px 20px; border-right: 1px solid var(--line); display: grid; gap: 6px; }
.stat:last-child { border-right: 0; }
.stat strong { font: 600 1.9rem/1 var(--display); font-variant-numeric: lining-nums tabular-nums; }
.stat strong.bad { color: var(--bad); }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr 1fr; } .stat:nth-child(2) { border-right: 0; } .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }

/* Panels & lists */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); padding: 20px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.empty { color: var(--muted); font-size: .92rem; padding: 6px 0; }
.list { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row .t { font-weight: 500; overflow-wrap: anywhere; }
.row .s { color: var(--muted); font-size: .86rem; }
a.row { text-decoration: none; }
a.row:hover .t { text-decoration: underline; text-underline-offset: 3px; }

/* Client table */
.ctable { background: var(--surface); border: 1px solid var(--line); }
.crow { display: grid; grid-template-columns: 2fr 1.2fr 1fr .8fr; gap: 16px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); text-decoration: none; }
.crow:first-child { border-top: 0; }
.crow.headrow { padding-block: 10px; }
.crow:not(.headrow):hover { background: var(--sunk); }
.crow .name { font-weight: 600; overflow-wrap: anywhere; }
.crow .num { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .crow { grid-template-columns: 1fr auto; } .crow > :nth-child(2), .crow > :nth-child(3) { display: none; } }

/* Pills */
.pill { display: inline-block; font: 600 .62rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 5px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.active, .pill.won { color: var(--good); border-color: currentColor; }
.pill.paused, .pill.pitched { color: var(--warn); border-color: currentColor; }
.pill.ended, .pill.lost, .pill.high { color: var(--bad); border-color: currentColor; }
.pill.contacted { color: var(--ink); border-color: var(--ink); }

/* Detail */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 24px; }
.fact { display: grid; gap: 4px; min-width: 0; }
.fact .v { overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .8rem; border: 1px solid var(--line); padding: 3px 8px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Leads board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--sunk); padding: 12px; display: grid; gap: 10px; align-content: start; min-height: 120px; }
.col-head { display: flex; justify-content: space-between; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); padding: 12px; display: grid; gap: 6px; cursor: pointer; text-align: left; width: 100%; }
.card:hover { border-color: var(--ink); }
.card .t { font-weight: 600; }
.card .s { color: var(--muted); font-size: .84rem; }
.card .due { font-size: .8rem; }
.card .due.late { color: var(--bad); font-weight: 600; }

/* Tasks */
.quickadd { display: grid; grid-template-columns: 2fr 1fr 150px auto; gap: 8px; margin-bottom: 24px; }
@media (max-width: 720px) { .quickadd { grid-template-columns: 1fr 1fr; } .quickadd input[name=title] { grid-column: 1 / -1; } }
.taskgroup { margin-bottom: 26px; }
.taskgroup > .label { display: block; margin-bottom: 8px; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 11px 0; border-top: 1px solid var(--line); }
.task input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ink); cursor: pointer; }
.task .t { font-weight: 500; overflow-wrap: anywhere; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .s { color: var(--muted); font-size: .84rem; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.task .s .late { color: var(--bad); font-weight: 600; }

/* Brief builder */
.brief { display: grid; gap: 12px; }
.brief .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.brief .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Dialog */
dialog { border: 1px solid var(--line); padding: 0; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 16px; padding: 22px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head button { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.dlg-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.dlg-foot .right { display: flex; gap: 8px; margin-left: auto; }

/* Toast */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--on-ink); padding: 11px 18px; z-index: 50; font-size: .9rem; max-width: calc(100vw - 32px); }
#toast.bad { background: var(--bad); color: #fff; }
@media (min-width: 821px) { #toast { bottom: 24px; } }

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