/* Afttr Work Suite — grayscale UI (same tokens as Afttr Sales Suite: f8f9fa e9ecef dee2e6 ced4da adb5bd 6c757d 495057 343a40 212529) */
:root {
  --g0: #f8f9fa; --g1: #e9ecef; --g2: #dee2e6; --g3: #ced4da; --g4: #adb5bd; --g5: #6c757d; --g6: #495057; --g7: #343a40; --g8: #212529;
  --bg: #ffffff; --side: var(--g0); --surface: var(--g0); --hover: var(--g1); --line: var(--g2); --line2: var(--g1);
  --ink: var(--g8); --ink2: var(--g6); --mut: var(--g5); --faint: var(--g4);
  --btn: var(--g8); --btnInk: #fff; --btnHover: var(--g7);
  --ok: #2b8a3e; --warn: #d9480f; --bad: #c92a2a; --info: var(--g6);
  --r: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #1a1d20; --side: var(--g8); --surface: var(--g8); --hover: var(--g7); --line: var(--g7); --line2: #2b3035;
  --ink: var(--g0); --ink2: var(--g3); --mut: var(--g4); --faint: var(--g6);
  --btn: var(--g0); --btnInk: var(--g8); --btnHover: var(--g2);
  --ok: #51cf66; --warn: #ff922b; --bad: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13.5px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
a { color: inherit; }
b, strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.mut { color: var(--mut); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 224px 1fr; height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 14px; }
.side-brand b { font-size: 15px; letter-spacing: -.01em; }
.side-brand small { display: block; color: var(--mut); font-size: 11.5px; margin-top: -3px; }
.mark { width: 28px; height: 28px; border-radius: 7px; background: var(--g8); color: var(--g0); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
:root[data-theme="dark"] .mark { background: var(--g0); color: var(--g8); }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r); text-decoration: none; color: var(--ink2); margin-bottom: 1px; }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.on { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.nav svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; font-size: 11.5px; color: var(--mut); font-variant-numeric: tabular-nums; }
.nav .count.hot { color: var(--btnInk); background: var(--btn); border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 10px; }
.acct { display: flex; gap: 9px; align-items: center; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--g2); color: var(--g6); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; object-fit: cover; }
.acct .nm { font-weight: 600; font-size: 13px; }
.acct .st { font-size: 11.5px; color: var(--mut); display: flex; align-items: center; gap: 5px; }
.run { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink2); }

.main { overflow-y: auto; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 22px 32px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.015em; font-weight: 650; }
.page-head p { margin: 2px 0 0; color: var(--mut); }
.crumb { color: var(--mut); text-decoration: none; font-size: 12.5px; }
.crumb:hover { color: var(--ink); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 550; font-size: 13px; padding: 6px 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; line-height: 1.4; }
.btn:hover { background: var(--hover); }
.btn.pri { background: var(--btn); color: var(--btnInk); border-color: var(--btn); }
.btn.pri:hover { background: var(--btnHover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=password], input[type=url], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 9px; width: 100%; }
textarea { resize: vertical; line-height: 1.5; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=password], input[type=url], input[type=search], select { height: 32px; }
.grid3 > .check, .grid2 > .check { align-self: center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--g5); box-shadow: 0 0 0 3px color-mix(in srgb, var(--g4) 25%, transparent); }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink2); }
.field small, .help { color: var(--mut); font-size: 12px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--g8); width: 15px; height: 15px; margin: 0; }
:root[data-theme="dark"] .check input { accent-color: var(--g2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); padding: 2px; gap: 2px; background: var(--surface); }
.seg button { font: inherit; font-size: 12.5px; border: 0; background: transparent; color: var(--ink2); padding: 4px 11px; border-radius: 4px; cursor: pointer; }
.seg button.on { background: var(--bg); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.switch { position: relative; width: 32px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--g3); border-radius: 99px; transition: .15s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + i { background: var(--g8); }
:root[data-theme="dark"] .switch input:checked + i { background: var(--g2); }
:root[data-theme="dark"] .switch input:checked + i::after { background: var(--g8); }
.switch input:checked + i::after { transform: translateX(14px); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { border: 1px solid var(--line); border-radius: var(--r); padding: 4px 10px; cursor: pointer; font-size: 12.5px; user-select: none; }
.days input { display: none; }
.days label:has(input:checked) { background: var(--btn); color: var(--btnInk); border-color: var(--btn); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.chip { font: inherit; font-size: 11.5px; font-family: var(--mono); background: var(--surface); border: 1px solid var(--line); color: var(--ink2); padding: 1px 7px; border-radius: 4px; cursor: pointer; }
.chip:hover { color: var(--ink); border-color: var(--g4); }
.counter { margin-left: auto; font-size: 12px; color: var(--mut); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 600; }

/* ---------- blocks ---------- */
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.panel-h h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.panel-b { padding: 14px; }
.panel-b.flush { padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.kpi { padding: 12px 14px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .k { font-size: 12px; color: var(--mut); }
.kpi .v { font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 1px; }
.kpi .v small { font-size: 13px; color: var(--mut); font-weight: 500; }
.kpi .s { font-size: 11.5px; color: var(--mut); }
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.statusbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; background: var(--surface); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--g4); flex: none; display: inline-block; }
.dot.on, .dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.idle { background: var(--g5); } .dot.off { background: var(--g4); }
.statusbar .txt { flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 14px; border-bottom: 1px solid var(--line2); }
.list li:last-child { border-bottom: 0; }
.list .t { color: var(--mut); font-size: 12px; white-space: nowrap; min-width: 92px; font-variant-numeric: tabular-nums; }
.list .grow { flex: 1; min-width: 0; }
.empty { text-align: center; color: var(--mut); padding: 34px 16px; }
.empty b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.callout { border: 1px solid var(--line); border-left: 3px solid var(--g6); background: var(--surface); padding: 10px 12px; border-radius: var(--r); font-size: 12.5px; color: var(--ink2); margin-bottom: 14px; }
.callout.warn { border-left-color: var(--warn); }
.callout.bad { border-left-color: var(--bad); }

/* ---------- table ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 550; color: var(--mut); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.tbl .sub { color: var(--mut); font-size: 12px; }
.tbl .r { text-align: right; }
.tbl a.rowlink { text-decoration: none; font-weight: 600; }
.tbl a.rowlink:hover { text-decoration: underline; }
.tbl-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 150px; }
.toolbar .sp { flex: 1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink2); white-space: nowrap; background: var(--bg); }
.tag.solid { background: var(--btn); color: var(--btnInk); border-color: var(--btn); }
.bar { height: 4px; background: var(--g1); border-radius: 99px; overflow: hidden; min-width: 60px; }
:root[data-theme="dark"] .bar { background: var(--g7); }
.bar i { display: block; height: 100%; background: var(--g7); }
:root[data-theme="dark"] .bar i { background: var(--g2); }
.score { display: inline-flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; font-weight: 600; }
.score .bar { width: 48px; min-width: 48px; }

/* ---------- approvals ---------- */
.appr { display: grid; grid-template-columns: 280px 1fr; border-bottom: 1px solid var(--line); }
.appr:last-child { border-bottom: 0; }
.appr .who { padding: 14px; border-right: 1px solid var(--line2); background: var(--surface); min-width: 0; }
.appr .who .nm { font-weight: 600; }
.appr .who .ctx { font-size: 12px; color: var(--mut); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.appr .edit { padding: 14px; display: grid; gap: 8px; }
.appr textarea { min-height: 88px; }
.appr .row { display: flex; gap: 8px; align-items: center; }
.err { color: var(--bad); font-size: 12px; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--mut); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.funnel { display: grid; gap: 8px; }
.funnel .fr { display: grid; grid-template-columns: 130px 1fr 90px; gap: 12px; align-items: center; font-size: 13px; }
.funnel .fb { height: 22px; background: var(--g1); border-radius: 4px; overflow: hidden; }
:root[data-theme="dark"] .funnel .fb { background: var(--g7); }
.funnel .fb i { display: block; height: 100%; background: var(--g6); }
:root[data-theme="dark"] .funnel .fb i { background: var(--g3); }

/* ---------- steps (sequence editor) ---------- */
.steps { display: grid; gap: 0; }
.step { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--bg); position: relative; }
.step-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step-h b { font-size: 13px; }
.step-link { width: 1px; height: 16px; background: var(--line); margin-left: 22px; }
.wait { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink2); }
.wait input { width: 58px; padding: 3px 6px; }

/* ---------- drawer / onboarding ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-bg { position: absolute; inset: 0; background: rgba(33, 37, 41, .35); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--bg); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(0,0,0,.08); animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer-b { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); }
.sec { margin-bottom: 22px; }
.sec-h { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.sec-h::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.preview { border: 1px dashed var(--g3); border-radius: var(--r); padding: 10px 12px; font-size: 13px; background: var(--surface); white-space: pre-wrap; }
.onboard { position: fixed; inset: 0; background: var(--surface); z-index: 40; overflow-y: auto; }
.ob { max-width: 620px; margin: 6vh auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.ob-top { display: flex; align-items: center; gap: 10px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.ob-steps { display: flex; gap: 6px; margin-left: auto; }
.ob-steps i { width: 22px; height: 3px; border-radius: 2px; background: var(--g2); }
.ob-steps i.on { background: var(--g8); }
:root[data-theme="dark"] .ob-steps i.on { background: var(--g0); }
.ob-b { padding: 24px; }
.ob-b h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.ob-b > p { margin: 0 0 18px; color: var(--mut); }
.ob-f { display: flex; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--line); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--mut); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-color: var(--ink); font-weight: 600; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--btn); color: var(--btnInk); padding: 8px 14px;
  border-radius: var(--r); font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 80vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
details.more > summary { cursor: pointer; color: var(--ink2); font-weight: 550; list-style: none; }
details.more > summary::before { content: '▸ '; color: var(--mut); }
details.more[open] > summary::before { content: '▾ '; }
kbd { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); }
.guide ol { padding-left: 18px; margin: 6px 0 0; } .guide li { margin-bottom: 6px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .side { display: none; }
  .cols, .grid2, .grid3, .grid4, .appr { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
.appr .who .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

/* ---------- pipeline + timeline ---------- */
.pipe { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--g1); gap: 1px; }
.pipe i { display: block; height: 100%; min-width: 3px; }
.pipe-l { display: flex; flex-wrap: wrap; gap: 3px 6px; margin-top: 7px; font-size: 12px; color: var(--ink2); align-items: center; }
.pipe-l span b { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.pipe-l strong { font-variant-numeric: tabular-nums; }
.pipe-l .arr { color: var(--faint); }
.when { font-size: 12px; color: var(--mut); font-variant-numeric: tabular-nums; }
.tl { padding: 4px 0; }
.tl-day { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); padding: 12px 14px 4px; }
.tl-row { display: grid; grid-template-columns: 78px 150px 1fr auto; gap: 10px; align-items: start; padding: 7px 14px; border-top: 1px solid var(--line2); }
.tl-t { font-variant-numeric: tabular-nums; color: var(--ink2); font-size: 12.5px; padding-top: 1px; }
.tl-k { font-size: 12.5px; color: var(--ink2); padding-top: 1px; }
.tl-w { min-width: 0; }
@media (max-width: 900px) { .tl-row { grid-template-columns: 64px 1fr auto; } .tl-k { display: none; } }

.upc-sums { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.upc-sum { flex: 1; padding: 10px 14px; border-right: 1px solid var(--line2); min-width: 0; }
.upc-sum:last-child { border-right: 0; }
.upc-sum b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); font-weight: 600; }
.upc-sum span { font-size: 13px; }
.tl-day { cursor: pointer; user-select: none; }
.tl-day .caret { display: inline-block; width: 14px; color: var(--faint); }
.tl-row.proj .tl-t, .tl-row.proj .tl-k { color: var(--mut); }
.then { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--mut); }
.tl-more { padding: 6px 14px 10px 102px; font-size: 12.5px; }
