:root {
  color-scheme: dark;
  /* Thread palette: #575757 #ffffff #442c5f #d7cbba #343235 #666666 #a78b70 #de8f94 #73a1be #95c483 */
  --bg: #2a292b;
  --side: #222123;
  --panel: #343235;
  --raised: #3d3b3f;
  --line: #414043;
  --line-strong: #575757;
  --text: #f5f5f6;
  --text-2: #c9c8cc;
  --muted: #939196;
  --accent: #73a1be;
  --accent-ink: #1d1c1e;
  --accent-soft: #442c5f;
  --pink: #de8f94;
  --s-inv: #d7cbba;
  --s-quo: #73a1be;
  --good: #95c483;
  --warn: #d7cbba;
  --bad: #de8f94;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side {
  background: var(--side); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font: 500 21px/1.2 var(--serif); padding: 4px 10px 16px; letter-spacing: -.01em; }
.brand small { display: block; font: 400 12px/1.4 var(--sans); color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.side-search {
  display: flex; align-items: center; gap: 8px; margin: 0 2px 12px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md); color: var(--muted); background: transparent;
  cursor: text; text-align: left;
}
.side-search:hover { border-color: var(--line-strong); color: var(--text-2); }
.side-search kbd { margin-left: auto; font: 11px var(--sans); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text-2);
}
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a.on { background: var(--raised); color: var(--text); }
.nav a .n { margin-left: auto; color: var(--muted); font-size: 12px; }
.nav a.flag .n { color: var(--warn); }
.nav-gap { height: 14px; }
.side-foot { margin-top: auto; padding: 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.side-foot .who { color: var(--text-2); }

.main { min-width: 0; }
.page { max-width: 1120px; margin: 0 auto; padding: 36px 40px 80px; }
.topbar { display: none; }

/* ---------- type ---------- */
h1 { font: 400 34px/1.15 var(--serif); letter-spacing: -.015em; margin: 0 0 6px; }
h2 { font: 400 22px/1.25 var(--serif); margin: 0 0 14px; letter-spacing: -.01em; }
h3 { font: 600 13px/1.3 var(--sans); color: var(--text-2); margin: 0 0 10px; }
.sub { color: var(--text-2); margin: 0 0 26px; }
.muted { color: var(--muted); }
.money { white-space: nowrap; }
section { margin-top: 44px; }
section:first-child { margin-top: 0; }

/* ---------- hero search ---------- */
.hero { text-align: center; padding: 64px 0 40px; }
.hero h1 { font-size: 44px; margin-bottom: 26px; }
.hero h1 .mark { color: var(--pink); }
.logo-h { margin: 0 0 10px; line-height: 0; }
.logo-big { height: 72px; width: auto; }
.hero-sub { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand-logo { display: block; height: 26px; width: auto; }
.fact-h { color: var(--text); font-weight: 500; font-size: 12.5px; margin: 26px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--line-strong); }
.fact-h:first-of-type { margin-top: 4px; }
.cap-note { color: var(--muted); font-size: 13px; margin: -6px 0 10px; }
.pdf { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: 12.5px; white-space: nowrap; }
.pdf:hover { color: var(--text); }
.pdf svg { flex: none; }

.composer {
  max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: 0 8px 40px rgba(0,0,0,.25); transition: border-color .15s;
}
.composer:focus-within { border-color: #6b6760; }
.composer svg { flex: none; color: var(--muted); }
.composer input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 17px; }
.composer input::placeholder { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 14px; }
.hint button { background: none; border: 0; color: var(--text-2); padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.hint button:hover { color: var(--accent); }

.searchbar {
  display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 28px;
}
.searchbar input { flex: 1; background: none; border: 0; outline: none; font-size: 15px; min-width: 0; }

/* ---------- headline numbers ---------- */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fig { padding: 20px 18px 18px 0; }
.fig + .fig { padding-left: 18px; border-left: 1px solid var(--line); }
.fig .v { font: 400 30px/1.1 var(--serif); letter-spacing: -.01em; }
.fig .l { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---------- facts ---------- */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.fact { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.fact .k { color: var(--muted); }
.fact .v { color: var(--text); }
.fact .v a { border-bottom: 1px solid var(--line-strong); }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 18px 10px; position: relative; }
.chart.wide { grid-column: 1 / -1; }
.chart h3 { color: var(--text); font-weight: 500; font-size: 14px; }
.chart .cap { color: var(--muted); font-size: 12px; margin: -6px 0 10px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font: 11px var(--sans); }
.chart .lbl { fill: var(--text-2); font: 11px var(--sans); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hit { fill: transparent; cursor: pointer; }
.hit:hover + .bar, .bar.hov { opacity: .8; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--raised); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.35);
  opacity: 0; transition: opacity .08s; max-width: 260px;
}
.tip b { font-weight: 600; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
details.data { margin: 6px 0 4px; font-size: 12px; color: var(--muted); }
details.data summary { cursor: pointer; width: max-content; }
details.data table { margin-top: 8px; }

/* ---------- tables ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.filter {
  display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 10px; min-width: 240px;
}
.filter input { background: none; border: 0; outline: none; flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 11px; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--raised); color: var(--text); }
select.pick { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; }
.count { color: var(--muted); font-size: 13px; }

table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap; user-select: none;
}
.t th.sort { cursor: pointer; }
.t th.sort:hover { color: var(--text); }
.t th .ar { color: var(--accent); margin-left: 4px; }
.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr.go { cursor: pointer; }
.t tr.go:hover td { background: rgba(255,255,255,.025); }
.t .r { text-align: right; }
.t .nowrap { white-space: nowrap; }
.t .clip { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { margin: 16px auto 0; display: block; }
.empty { padding: 40px 0; color: var(--muted); text-align: center; }

/* ---------- badges & buttons ---------- */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.st.paid::before { background: var(--good); }
.st.open::before { background: var(--warn); }
.st.void::before { background: var(--muted); }
.st.quote::before { background: var(--s-quo); }
.st.off::before { background: var(--bad); }
.tag { font-size: 11px; color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.btn {
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 7px 12px; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #6b6760; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.btn.primary:hover { filter: brightness(1.06); color: var(--accent-ink); }
.btn.quiet { background: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- detail pages ---------- */
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.crumb a:hover { color: var(--accent); }
.head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 260px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); margin-top: 6px; }
.meta a { border-bottom: 1px solid var(--line-strong); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 28px; margin-top: 26px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kv .k { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.kv .v a { border-bottom: 1px solid var(--line-strong); }
.big { font: 400 32px/1.1 var(--serif); text-align: right; }
.big small { display: block; font: 12px var(--sans); color: var(--muted); margin-top: 6px; }
.lines .line { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.lines .name { font-weight: 500; }
.lines .desc { grid-column: 1 / -1; color: var(--text-2); white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; max-width: 78ch; }
.lines .calc { text-align: right; white-space: nowrap; }
.lines .calc .q { color: var(--muted); font-size: 12px; }
.totals { margin-left: auto; width: min(340px, 100%); margin-top: 10px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-2); }
.totals .grand { color: var(--text); font: 400 20px var(--serif); border-top: 1px solid var(--line-strong); padding-top: 10px; margin-top: 4px; }
.addr { color: var(--text-2); }
.prose { color: var(--text-2); white-space: pre-wrap; max-width: 78ch; line-height: 1.65; }
.mini { display: flex; align-items: flex-end; gap: 3px; height: 56px; margin-top: 10px; }
.mini span { flex: 1; background: var(--s-inv); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.mini-x { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ---------- status actions ---------- */
.marked { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin-top: 22px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.marked .grow { flex: 1; min-width: 200px; color: var(--text-2); }
.yr { color: var(--muted); font-size: 12px; padding: 22px 10px 6px; border-bottom: 1px solid var(--line-strong); }
.acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  padding: 24px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(10,10,9,.6); }
dialog h2 { margin-bottom: 6px; }
dialog label { display: block; color: var(--muted); font-size: 12px; margin: 16px 0 6px; }
dialog input, dialog textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; outline: none;
}
dialog input:focus, dialog textarea:focus { border-color: var(--accent); }
dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 10px 16px;
  transition: .2s; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- search results ---------- */
.group { margin-top: 30px; }
.group:first-child { margin-top: 0; }
.group h3 { display: flex; gap: 10px; align-items: baseline; }
.group h3 a { margin-left: auto; color: var(--muted); font-weight: 400; }
.group h3 a:hover { color: var(--accent); }
.hitrow { display: flex; gap: 14px; align-items: baseline; padding: 10px 12px; border-radius: var(--r-sm); }
.hitrow:hover, .hitrow.sel { background: var(--raised); color: var(--text); }
.hitrow .a { flex: none; min-width: 0; }
.hitrow .b { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.hitrow .c { margin-left: auto; color: var(--text-2); font-size: 13px; white-space: nowrap; }
mark { background: var(--accent-soft); color: #fff; border-radius: 2px; padding: 0 1px; }

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); font: 400 18px var(--serif); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 30; }
  .topbar .brand { padding: 0; font-size: 18px; }
  .page { padding: 24px 16px 60px; }
  .hero { padding: 28px 0 24px; }
  .hero h1 { font-size: 32px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .fig:nth-child(3) { padding-left: 0; border-left: 0; }
  .fig:nth-child(n+3) { border-top: 1px solid var(--line); }
  .facts, .charts { grid-template-columns: 1fr; }
  .fact { grid-template-columns: 120px 1fr; }
  .t .hide-sm { display: none; }
  .filter { min-width: 0; flex: 1; }
  .big { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- additions: editing, review, currency ---------- */
.side-cur { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 14px; color: var(--muted); font-size: 12px; }
.side-cur .seg button { padding: 4px 9px; font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap; }
.chip.warn { border-color: rgba(215,203,186,.5); color: #d7cbba; }
.chip.good { border-color: rgba(149,196,131,.45); color: #95c483; }
.chip.edit { border-color: rgba(115,161,190,.5); color: #73a1be; }
.conf { font-size: 11px; color: var(--muted); }
.conf.high { color: #95c483; } .conf.medium { color: #d7cbba; } .conf.low { color: var(--muted); }
.conv { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bar-track { height: 6px; background: var(--raised); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar-fill { height: 100%; background: var(--good); border-radius: 99px; }
.why { color: var(--text-2); font-size: 13px; margin-top: 3px; max-width: 46ch; }
.eq { color: var(--muted); font-size: 12px; margin-top: 2px; }
.rowacts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin-top: 22px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.panel .grow { flex: 1; min-width: 220px; color: var(--text-2); }
.panel.warn { border-color: rgba(215,203,186,.4); }
.panel b { color: var(--text); font-weight: 500; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.note { background: var(--panel); border-left: 2px solid var(--pink); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 12px 14px; white-space: pre-wrap; color: var(--text); max-width: 78ch; }
.note .by { color: var(--muted); font-size: 12px; margin-top: 8px; white-space: normal; }
.hist { font-size: 13px; }
.hist td { color: var(--text-2); }
.hist .arrow { color: var(--muted); padding: 0 6px; }
.hist .old { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
dialog.wide { width: min(560px, calc(100vw - 32px)); }
dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
dialog select { width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 8px 10px; outline: none; }
dialog .help { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.45; }
dialog .help button { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; font-size: 12px; }
dialog .err { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 1em; }
dialog .rate { display: flex; align-items: center; gap: 8px; }
dialog .rate span { color: var(--text-2); white-space: nowrap; }
.kbd-hint { color: var(--muted); font-size: 12px; }
.tw { overflow-x: auto; }
@media (max-width: 900px) {
  dialog .grid2 { grid-template-columns: 1fr; }
  .tw table.t { min-width: 640px; }
  .seg { flex-wrap: wrap; }
}

/* ================================================================ Thread app additions */
.side .new { margin: 0 2px 14px; display: flex; gap: 6px; }
.side .new .btn { flex: 1; justify-content: center; padding: 7px 8px; }
.nav a.due .n { color: var(--accent); }

/* stages */
.stage {
  appearance: none; -webkit-appearance: none; border: 1px solid transparent; border-radius: 999px;
  padding: 2px 24px 2px 10px; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap;
  background: var(--raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23939196' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: var(--sc, var(--text-2)); border-color: color-mix(in srgb, var(--sc, #939196) 45%, transparent);
}
.stage:hover { border-color: var(--sc, #939196); }
.stage option { background: var(--panel); color: var(--text); }
.stage-dot { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text-2); font-size: 12.5px; }
.stage-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sc, #939196); }
.more-proj { color: var(--muted); font-size: 11.5px; margin-left: 6px; }
.pipe { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.pipe a { background: var(--panel); padding: 14px 14px 12px; display: block; }
.pipe a:hover { background: var(--raised); color: var(--text); }
.pipe .s { font-size: 12px; color: var(--sc); font-weight: 500; }
.pipe .c { font: 400 24px/1.2 var(--serif); margin-top: 4px; }
.pipe .v { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* status chips for documents */
.st.draft::before { background: var(--muted); }
.st.sched::before { background: var(--accent); }
.st.sent::before { background: var(--s-quo); }
.st.agreed::before { background: var(--good); }
.st.over { color: var(--bad); }
.st.over::before { background: var(--bad); }
.due-soon { color: var(--accent); }
.late { color: var(--bad); }

/* forms */
.field label, .flabel { display: block; color: var(--muted); font-size: 12px; margin: 0 0 5px; }
.inp, .field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 8px 10px; outline: none; color: var(--text);
}
.inp:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; line-height: 1.55; }
.fgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 16px; }
.fgrid .w2 { grid-column: span 2; }
.fgrid .w4 { grid-column: 1 / -1; }
.chk { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.chk input { width: auto; accent-color: var(--accent); }

/* document editor */
.editor { margin-top: 26px; }
.ed-head { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.ed-head .grow { flex: 1; min-width: 260px; }
.ed-title { width: 100%; background: none; border: 0; border-bottom: 1px solid transparent; outline: none; font: 400 34px/1.15 var(--serif); letter-spacing: -.015em; padding: 0 0 4px; color: var(--text); }
.ed-title:hover { border-bottom-color: var(--line-strong); }
.ed-title:focus { border-bottom-color: var(--accent); }
.ed-title::placeholder { color: var(--muted); }
.ed-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; margin-top: 18px; }
.lines-ed { margin-top: 26px; }
.lrow { display: grid; grid-template-columns: 28px 1fr 84px 128px 120px 130px 34px; gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lrow.head { padding: 0 0 8px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; align-items: end; }
.lrow.head > div { padding: 0 2px; }
.lrow .num { text-align: right; }
.lrow .amt { text-align: right; padding-top: 8px; white-space: nowrap; }
.lrow .amt small { display: block; color: var(--muted); font-size: 11px; }
.lrow input, .lrow textarea, .lrow select {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); padding: 7px 8px; outline: none; color: var(--text);
}
.lrow input:hover, .lrow textarea:hover, .lrow select:hover { border-color: var(--line); }
.lrow input:focus, .lrow textarea:focus, .lrow select:focus { border-color: var(--accent); background: var(--bg); }
.lrow select { background: transparent; }
.lrow select option { background: var(--panel); }
.lrow .ltitle { font-weight: 500; }
.lrow textarea { resize: none; overflow: hidden; color: var(--text-2); font-size: 13.5px; line-height: 1.55; min-height: 34px; }
.lrow .grip { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.lrow .grip button, .lrow .lmenu { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 1px 4px; border-radius: 4px; line-height: 1; }
.lrow .grip button:hover, .lrow .lmenu:hover { color: var(--text); background: var(--raised); }
.lrow.text .ltitle { font-weight: 400; font-style: italic; color: var(--text-2); }
.lrow .kindtag { font-size: 11px; color: var(--muted); padding: 0 8px; }
.pct { display: flex; align-items: center; gap: 4px; }
.pct input { text-align: right; }
.add-lines { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.ed-foot { display: grid; grid-template-columns: 1fr 340px; gap: 30px; margin-top: 18px; align-items: start; }
.savebar {
  position: sticky; bottom: 0; z-index: 20; margin: 30px -40px -80px; padding: 12px 40px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.savebar .grow { flex: 1; }
.savebar .state { color: var(--muted); font-size: 13px; }
.savebar .state.dirty { color: var(--warn); }

/* type-ahead */
.ta { position: absolute; z-index: 45; background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: 0 14px 40px rgba(0,0,0,.45); max-height: 420px; overflow-y: auto; width: min(640px, calc(100vw - 32px)); padding: 6px; }
.ta .opt { padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; }
.ta .opt.sel, .ta .opt:hover { background: var(--line); }
.ta .opt .t { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta .opt .p { text-align: right; white-space: nowrap; color: var(--text-2); }
.ta .opt .d { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ta .opt .m { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }
.ta .star { color: var(--warn); }
.ta .hd { color: var(--muted); font-size: 11.5px; padding: 6px 10px 4px; }
.ta .none { color: var(--muted); padding: 10px; font-size: 13px; }

/* picker (client / project search box) */
.pick-wrap { position: relative; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 30px 28px; }

.login h1 { font-size: 26px; margin-bottom: 4px; }
.login .field { margin-top: 16px; }
.login .btn { width: 100%; justify-content: center; margin-top: 22px; padding: 10px; }
.login .err { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 1.2em; }

/* settings */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; cursor: pointer; }
.card:hover { border-color: var(--line-strong); }
.card h3 { color: var(--text); font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.card .muted { font-size: 13px; }
.taxrow { display: grid; grid-template-columns: 1fr 110px 34px; gap: 8px; margin-bottom: 8px; }

/* fireworks */
#fw { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.paid-msg { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(.9); z-index: 69; pointer-events: none;
  font: 400 48px/1.1 var(--serif); text-align: center; opacity: 0; transition: opacity .35s, transform .35s;
  background: color-mix(in srgb, var(--side) 88%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: 28px 44px 26px; box-shadow: 0 24px 80px rgba(0,0,0,.55); }
.paid-msg small { display: block; font: 15px var(--sans); color: var(--text-2); margin-top: 10px; }
.paid-msg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

dialog.xwide { width: min(760px, calc(100vw - 32px)); }
.sched { width: 100%; border-collapse: collapse; margin-top: 12px; }
.sched td, .sched th { padding: 5px 4px; text-align: left; font-weight: 400; }
.sched th { color: var(--muted); font-size: 12px; }
.sched input { padding: 6px 8px !important; }
.sched .r { text-align: right; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.presets button { background: var(--bg); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.presets button:hover, .presets button.on { border-color: var(--accent); color: var(--text); }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.empty-state .btn { margin-top: 12px; }
.sumrow td { border-bottom: 0; color: var(--text); font-weight: 500; padding-top: 12px; }

@media (max-width: 900px) {
  .fgrid { grid-template-columns: 1fr 1fr; }
  .lrow { grid-template-columns: 24px 1fr 90px 34px; }
  .lrow .c-qty, .lrow .c-tax { display: none; }
  .lrow.head .c-qty, .lrow.head .c-tax { display: none; }
  .ed-foot { grid-template-columns: 1fr; }
  .savebar { margin: 24px -16px -60px; padding: 12px 16px; }
  .pipe { grid-template-columns: repeat(3, 1fr); }
}

/* Thread Workshop lockup */
.lockup { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 6px 0 20px; color: var(--text); }
.lockup:hover { color: var(--text); }
.lockup img { height: 34px; width: auto; display: block; }
.lockup span { font: 600 10px/1 var(--sans); letter-spacing: .42em; text-transform: uppercase; margin-right: -.42em; }
.lockup.small { flex-direction: row; gap: 10px; padding: 0; }
.lockup.small img { height: 20px; }
.lockup.small span { font-size: 8.5px; letter-spacing: .32em; }
.lockup.big { padding: 4px 0 26px; }
.lockup.big img { height: 46px; margin: 0; }
.lockup.big span { font-size: 11px; }
.ref { color: var(--text-2); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
