:root {
  --ground: #F6F6F6;
  --ink: #111111;
  --accent: #E8401C;
  --card: #FFFFFF;
  --line: #E2E2E2;
  --muted: #6B6B6B;
  --good: #1F7A4D;
  --warm: #B4570F;
  --radius: 12px;
  --head: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.45 var(--body);
  overflow-x: hidden; padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--head); font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; }
a { color: inherit; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.pad { padding: 16px 0; }
.err { color: #B3261E; min-height: 1.2em; }
.break, .pagelink, .ntext { overflow-wrap: anywhere; }
.row { display: flex; align-items: center; min-width: 0; }
.row.between { justify-content: space-between; gap: 8px; }
.row.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* shell */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: rgba(246, 246, 246, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font: 700 1.1rem var(--head); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.tabs { display: none; gap: 4px; }
.tabs a, .bottom a { text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a { padding: 8px 12px; border-radius: 999px; }
.tabs a.on { color: var(--ink); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.me #who { display: none; }
.bottom {
  position: fixed; inset: auto 0 0 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottom a { padding: 14px 2px; text-align: center; font-size: 0.78rem; border-top: 2px solid transparent; }
.bottom a.on { color: var(--ink); border-top-color: var(--accent); }
body:not(.authed) .authonly { display: none !important; }
main { max-width: 980px; margin: 0 auto; padding: 16px; }
@media (min-width: 820px) {
  body { padding-bottom: 32px; }
  .tabs { display: flex; }
  .bottom { display: none; }
  .me #who { display: inline; }
  main { padding: 24px 24px; }
}

/* controls */
input, select, textarea {
  font: inherit; color: inherit; width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid #CFCFCF; border-radius: 10px; background: var(--card);
}
textarea { resize: vertical; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .drop:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
label input, label select, label textarea { font-weight: 400; font-size: 1rem; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
label.check input { width: auto; min-height: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  font: 600 0.95rem var(--body); color: var(--ink); background: var(--card); border: 1px solid var(--ink);
  border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.link { border: 0; background: none; color: var(--muted); text-decoration: underline; min-height: 36px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; }
.btn.wide { width: 100%; }
.btn.big { min-height: 52px; padding: 12px 18px; font-size: 1rem; border-radius: 14px; justify-content: space-between; }

/* blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.newbox { min-width: 0; }
.newbox form { width: min(420px, calc(100vw - 32px)); }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar > * { flex: 1 1 200px; }
.cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.pcard { display: flex; flex-direction: column; gap: 8px; text-decoration: none; transition: border-color 0.15s; }
.pcard:hover { border-color: var(--ink); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #EFEFEF; white-space: nowrap; }
.pill.good { background: #E3F2EA; color: var(--good); }
.pill.warm { background: #FCEBDD; color: var(--warm); }
.pill.dim { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font: 600 0.85rem var(--body); cursor: pointer; color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; flex: none; }
.seg button { min-height: 40px; min-width: 44px; padding: 6px 12px; border: 0; background: var(--card); font: 600 0.9rem var(--body); cursor: pointer; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }

/* leads */
.leads { display: flex; flex-direction: column; gap: 8px; }
.lead { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.lmain { display: flex; flex-direction: column; min-width: 0; }
.lname { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.lname:hover { text-decoration: underline; }
.lctl { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lctl select { width: auto; flex: 1 1 140px; min-height: 40px; }
@media (min-width: 820px) {
  .lead { flex-direction: row; align-items: center; justify-content: space-between; }
  .lctl { flex-wrap: nowrap; }
  .lctl select { flex: 0 0 150px; }
}

/* prospect page */
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
.phead { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.phead select { width: auto; min-width: 150px; }
@media (min-width: 820px) { .phead { flex-direction: row; justify-content: space-between; align-items: flex-start; } }
.biglinks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
@media (min-width: 820px) { .biglinks { grid-template-columns: repeat(4, 1fr); } }
.biglinks .btn { min-width: 0; white-space: normal; text-align: left; line-height: 1.2; }
.sec { margin-bottom: 14px; }
details.sec summary { cursor: pointer; list-style: none; }
details.sec summary::-webkit-details-marker { display: none; }
details.sec summary h2 { display: inline; }
details.sec summary::after { content: ' +'; color: var(--muted); font-weight: 700; }
details[open].sec summary::after { content: ' −'; }
details[open].sec summary { margin-bottom: 12px; }
.films { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 820px) { .films { grid-template-columns: 1fr 1fr; } }
.film { margin: 0; min-width: 0; }
video { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 10px; }
audio { width: 100%; max-width: 420px; height: 40px; }
.film figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 8px; }
.uploader { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.uprow { display: flex; flex-direction: column; gap: 6px; }
.progress { display: flex; align-items: center; gap: 10px; }
.progress .bar { flex: 1; height: 8px; background: #ECECEC; border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.plabel { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

/* recorder + notes */
.recorder { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.mic {
  display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 22px 10px 16px; border-radius: 999px;
  border: 0; background: var(--ink); color: #fff; font: 700 1rem var(--body); cursor: pointer;
}
.mic .ic { width: 24px; height: 24px; }
.mic.rec { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.mic:disabled { opacity: 0.4; cursor: default; }
.mic .clock { font-variant-numeric: tabular-nums; font-weight: 600; opacity: 0.9; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(232, 64, 28, 0.18); } }
@media (prefers-reduced-motion: reduce) { .mic.rec { animation: none; } }
.preview { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; }
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.ntext { white-space: pre-wrap; }

/* contacts */
.contacts { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.contact { width: 100%; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.contact .btn { align-self: flex-start; }
.contact.edit { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 620px) { .contact.edit { grid-template-columns: 1fr 1fr; } .contact.edit > .row, .contact.edit > .check { grid-column: 1 / -1; } }

/* page */
.switch { flex-direction: row; align-items: center; gap: 12px; cursor: pointer; font-size: 1rem; margin-bottom: 12px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 48px; height: 28px; border-radius: 999px; background: #CFCFCF; position: relative; flex: none; transition: background 0.15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.pagelink { font-weight: 600; min-width: 0; }
.sec > label { margin-top: 12px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 4px; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 76px; padding: 8px 10px; border-radius: 10px; background: var(--ground); }
.stat b { font: 700 1.3rem var(--head); }
.stat span { font-size: 0.75rem; color: var(--muted); }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.info dt { font-weight: 600; color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }

/* uploads */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 160px; padding: 24px 16px; margin-bottom: 14px; border: 2px dashed #BDBDBD; border-radius: var(--radius);
  background: var(--card); cursor: pointer; font-weight: 500;
}
.drop .ic { width: 28px; height: 28px; color: var(--accent); }
.drop.over { border-color: var(--accent); background: #FFF6F3; }
.upcard { display: flex; flex-direction: column; gap: 10px; }
.assign { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 820px) { .assign { grid-template-columns: 2fr 1fr 2fr auto; } }

/* activity */
.act.line {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.act.line > :nth-child(3), .act.line > :nth-child(4) { grid-column: 2; }
@media (min-width: 820px) { .act.line { grid-template-columns: auto 1fr auto auto; } .act.line > :nth-child(3), .act.line > :nth-child(4) { grid-column: auto; } }
.act.form { display: flex; flex-direction: column; gap: 6px; }

/* login */
.login { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; padding: 24px; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); transition: opacity 0.4s;
}
.toast.err { background: #B3261E; }
.toast.out { opacity: 0; }
@media (min-width: 820px) { .toast { bottom: 28px; } }
