/* Studio Forma Ops — fictional agency operations system.
   Layout concept: a calm graphite workspace; ochre marks the agency, and
   status colors are reserved strictly for state. */
:root {
  --bg: #F3F2EE;
  --panel: #FFFFFF;
  --ink: #18191B;
  --muted: #5F6267;
  --line: #E0DED7;
  --soft: #EAE8E2;
  --ochre: #B26B00;
  --ochre-soft: #F5E6CC;
  --s-todo: #6B7078;
  --s-prog: #2F64C8;
  --s-rev: #8448C2;
  --s-done: #2C8155;
  --late: #BF3328;
  --soon: #A86A06;
  --sans: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315; --panel: #1B1C1F; --ink: #ECEBE7; --muted: #A3A5AA; --line: #2E3034; --soft: #25272B;
    --ochre: #E6A23C; --ochre-soft: #3A2E1A; --s-todo: #9AA0A8; --s-prog: #7EA6F2; --s-rev: #BE95EC; --s-done: #6CC79A;
    --late: #F08377; --soon: #E7B358; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121315; --panel: #1B1C1F; --ink: #ECEBE7; --muted: #A3A5AA; --line: #2E3034; --soft: #25272B;
  --ochre: #E6A23C; --ochre-soft: #3A2E1A; --s-todo: #9AA0A8; --s-prog: #7EA6F2; --s-rev: #BE95EC; --s-done: #6CC79A;
  --late: #F08377; --soon: #E7B358; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--ink); }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

.demo-bar { background: var(--ink); color: var(--bg); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.demo-bar p { flex: 1 1 380px; }
.demo-bar a, .demo-bar .linkish { color: var(--bg); font-weight: 600; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

.app { flex: 1 0 auto; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.side { border-right: 1px solid var(--line); padding: 20px 14px 20px max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 26px; height: 26px; border-radius: 50% 50% 4px 50%; background: var(--ochre); flex: none; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.tabs { display: grid; gap: 2px; }
.tabs a { text-decoration: none; padding: 9px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tabs a:hover { background: var(--soft); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.side-foot { margin-top: auto; padding: 0 6px; }
.side-foot p { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.side-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.side-foot li { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.side-foot li small { color: var(--muted); display: block; font-size: 12px; }
.av { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }

.main { padding: 24px max(16px, env(safe-area-inset-right, 0px)) 48px 28px; min-width: 0; outline: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.view-head h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 700; letter-spacing: -.01em; }
.view-head p { color: var(--muted); max-width: 64ch; margin-top: 4px; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .tabs { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 10px; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  .side-foot { display: none; }
  .main { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 9px 14px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--ochre); border-color: var(--ochre); color: #fff; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; display: grid; gap: 4px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi.alert b { color: var(--late); }
@media (max-width: 900px) { .kpis { grid-template-columns: 1fr 1fr; } }

.cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--soft); }
.pname b { display: block; }
.pname small { color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--s-done); border-radius: 99px; }
.prog { display: flex; align-items: center; gap: 10px; }
.prog span { font-size: 12px; color: var(--muted); width: 34px; font-variant-numeric: tabular-nums; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--soft); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-New { color: var(--ochre); } .st-Gettingstarted { color: var(--s-todo); } .st-Inprogress { color: var(--s-prog); } .st-Review { color: var(--s-rev); } .st-Delivered { color: var(--s-done); }
.due { font-size: 12px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.due.late { color: var(--late); } .due.soon { color: var(--soon); }

.log { list-style: none; margin: 0; padding: 6px 16px 12px; display: grid; }
.log li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.log li:last-child { border-bottom: 0; }
.log li::before { content: "\26A1"; font-size: 12px; }
.log small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.empty { padding: 18px 16px; color: var(--muted); font-size: 13px; }

/* Board */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar label { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
select.sm, input.sm { border: 1px solid var(--line); border-radius: 7px; background: var(--panel); padding: 6px 8px; font-size: 13px; max-width: 100%; }
.board-wrap { overflow-x: auto; padding-bottom: 8px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; min-width: 1000px; }
.col { background: var(--soft); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 320px; transition: background .15s, box-shadow .15s; }
.col.over { box-shadow: inset 0 0 0 2px var(--ochre); }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; font-weight: 700; font-size: 13px; }
.col-head .count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; display: grid; gap: 8px; cursor: grab; border-left: 3px solid var(--c, var(--line)); }
.card.dragging { opacity: .45; }
.card .t { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .proj { font-size: 12px; color: var(--muted); }
.card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.card select { font-size: 12px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); min-width: 0; width: 100%; }
.c-todo { --c: var(--s-todo); } .c-prog { --c: var(--s-prog); } .c-rev { --c: var(--s-rev); } .c-done { --c: var(--s-done); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* Forms */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; padding: 18px; }
.fld { display: grid; gap: 5px; min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld label { font-weight: 600; font-size: 13px; }
.fld input, .fld select, .fld textarea { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 9px 10px; width: 100%; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: none; border-color: var(--ochre); box-shadow: 0 0 0 3px var(--ochre-soft); }
.fld [aria-invalid="true"] { border-color: var(--late); }
.fld .e { color: var(--late); font-size: 12px; font-weight: 600; }
.fld .e:empty { display: none; }
.fld .h { color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .formgrid { grid-template-columns: 1fr; } }
.intake-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .intake-cols { grid-template-columns: minmax(0, 1fr); } }
.runs { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 10px; }
.runs li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 14px; align-items: start; }
.runs .ic { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 11px; }
.runs li.ok .ic { background: var(--s-done); border-color: var(--s-done); color: #fff; }
.runs li.wait { color: var(--muted); }
.runs small { display: block; color: var(--muted); font-size: 12px; }
.asana-note { margin: 4px 16px 16px; padding: 14px; border-radius: 8px; background: var(--ochre-soft); display: grid; gap: 6px; font-size: 14px; }
.asana-note a { font-weight: 600; }

/* Checklist */
.ck { list-style: none; margin: 0; padding: 6px 16px 14px; }
.ck li { border-bottom: 1px solid var(--line); }
.ck li:last-child { border-bottom: 0; }
.ck label { display: flex; gap: 12px; align-items: center; padding: 11px 0; cursor: pointer; }
.ck input { width: 18px; height: 18px; accent-color: var(--s-done); flex: none; }
.ck input:checked + span { color: var(--muted); text-decoration: line-through; }
.ck small { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ob-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }

/* Workflow */
.flow-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .flow-cols { grid-template-columns: minmax(0, 1fr); } }
.flow { list-style: none; margin: 0; padding: 16px; display: grid; gap: 0; }
.flow li { position: relative; padding: 10px 12px 10px 38px; }
.flow li::before { content: attr(data-n); position: absolute; left: 0; top: 9px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--soft); }
.flow li:not(:last-child)::after { content: ""; position: absolute; left: 11.5px; top: 35px; bottom: -8px; width: 1px; background: var(--line); }
.flow b { display: block; }
.flow .pain { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--late); font-weight: 600; }
.flow .gain { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--s-done); font-weight: 600; }
.before .panel-head h2::before { content: "Before: "; color: var(--late); }
.after .panel-head h2::before { content: "After: "; color: var(--s-done); }
.rules { list-style: none; margin: 0; padding: 0; }
.rules li { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.3fr); gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); align-items: center; font-size: 14px; }
.rules li:last-child { border-bottom: 0; }
.rules .w, .rules .t { min-width: 0; }
.rules .w small, .rules .t small { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.rules .arr { color: var(--ochre); font-weight: 700; text-align: center; }
.rules .live { font-size: 11px; font-weight: 700; color: var(--s-done); }
@media (max-width: 600px) { .rules li { grid-template-columns: 1fr; gap: 4px; } .rules .arr { text-align: left; } }

.map th:first-child, .map td:first-child { width: 34%; }
.note { border: 1px dashed var(--ochre); background: var(--ochre-soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }

/* Playbook doc */
.doc { padding: clamp(18px, 4vw, 36px); max-width: 820px; }
.doc .docid { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.doc h2 { font-size: 26px; margin: 6px 0 14px; }
.doc h3 { font-size: 16px; margin: 22px 0 8px; }
.doc p, .doc li { color: var(--ink); max-width: 68ch; }
.doc ol, .doc ul { padding-left: 20px; display: grid; gap: 6px; margin: 0; }
.doc dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.doc dt { color: var(--muted); }
.doc dd { margin: 0; }

/* Drawer */
.drawer { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(480px, 100vw); border: 0; padding: 0; background: var(--panel); color: var(--ink); box-shadow: -10px 0 40px rgba(0,0,0,.18); }
.drawer::backdrop { background: rgba(20, 20, 22, .4); }
.drawer-inner { padding: calc(20px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) 20px; display: grid; gap: 16px; }
.drawer-top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.drawer h2 { font-size: 22px; }
.drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.drawer dt { color: var(--muted); }
.drawer dd { margin: 0; }
.mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mini li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 8px 10px; background: var(--soft); border-radius: 7px; }
.x { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; line-height: 1; flex: none; }

.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; font-size: 14px; max-width: min(380px, calc(100vw - 32px)); z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast b { color: var(--ochre); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
