:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --sunken: #ebe8e2;
  --hover: #f0ede7;
  --line: #e0dbd2;
  --ink: #16202e;
  --ink-2: #4b5565;
  --muted: #858b96;
  --accent: #c4621f;
  --accent-ink: #a14f16;
  --accent-soft: #f7e6d8;
  --navy: #13223a;
  --inbox: #7a8291; --next: #3767c4; --doing: #d0691f; --waiting: #b38a12; --done: #2f8a55;
  --danger: #c23b3b; --danger-soft: #f8e1e1;
  --ok-soft: #dff0e5; --warn-soft: #f6ecc8; --info-soft: #e0e9f8;
  --shadow: 0 1px 2px rgba(20, 24, 34, .06), 0 0 0 1px var(--line);
  --shadow-lg: 0 20px 50px -12px rgba(20, 24, 34, .28), 0 0 0 1px var(--line);
  --sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --panel: #161d28; --sunken: #111721; --hover: #1c2431; --line: #263142;
    --ink: #eceff4; --ink-2: #b4bccb; --muted: #7f8898;
    --accent: #ec8a4a; --accent-ink: #f3a26d; --accent-soft: #3a2616;
    --inbox: #8d96a6; --next: #6f9cf0; --doing: #ee8a45; --waiting: #dcb445; --done: #58c285;
    --danger: #ef7070; --danger-soft: #3a1c1c; --ok-soft: #173327; --warn-soft: #332b12; --info-soft: #172a45;
    --shadow: 0 0 0 1px var(--line);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .6), 0 0 0 1px var(--line);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); background: var(--sunken); }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 16px; font-weight: 600; }
.brand svg { width: 26px; height: 26px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--hover); }
.nav a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav .count.hot { color: var(--accent-ink); font-weight: 600; }
.side .grow { flex: 1; }
.side .hint { font-size: 11.5px; color: var(--muted); padding: 8px 10px; line-height: 1.6; }
kbd { font: 500 11px var(--sans); padding: 1px 5px; border-radius: 4px; background: var(--panel); box-shadow: var(--shadow); color: var(--ink-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 420px; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; background: none; outline: 0; min-width: 0; }
.search svg { width: 15px; height: 15px; color: var(--muted); }
.top .spacer { flex: 1; }
.page { padding: 26px 28px 60px; max-width: 1180px; width: 100%; }
.page.wide { max-width: none; }
h1.title { font: 600 28px/1.15 var(--serif); letter-spacing: -.015em; margin: 0 0 4px; text-wrap: balance; }
.sub { color: var(--ink-2); margin: 0 0 22px; }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; border: 0; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--navy); color: #fff; box-shadow: none; }
.btn.primary:hover { background: #1f3354; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--accent); color: #1a0f06; } .btn.primary:hover { background: var(--accent-ink); } }
.btn.done { background: var(--done); color: #fff; box-shadow: none; }
.btn.ghost { background: none; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.input, select.input, textarea.input { width: 100%; padding: 7px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); outline: 0; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- chips & rows ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 500; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.chip.due.over { background: var(--danger-soft); color: var(--danger); }
.chip.due.today { background: var(--accent-soft); color: var(--accent-ink); }
.chip.wait { background: var(--warn-soft); color: var(--waiting); }
.chip.pri-now { background: var(--danger-soft); color: var(--danger); }
.chip.pri-later { opacity: .7; }
.chip.bill { background: var(--ok-soft); color: var(--done); }
.chip.st { text-transform: capitalize; }
.chip.who { background: var(--info-soft); color: var(--next); }
.s-inbox { background: var(--inbox); } .s-next { background: var(--next); } .s-doing { background: var(--doing); } .s-waiting { background: var(--waiting); } .s-done { background: var(--done); }

.list { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); cursor: pointer; min-width: 0; }
.row:hover { background: var(--hover); }
.row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row .quick { opacity: 0; transition: opacity .1s; display: flex; gap: 4px; }
.row:hover .quick, .row:focus-within .quick { opacity: 1; }
.empty { padding: 16px; color: var(--muted); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- today ---------- */
.today-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1000px) { .today-grid { grid-template-columns: 1fr; } }
.section { margin-bottom: 22px; }
.section h2 { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 8px; }
.section h2 .n { font-variant-numeric: tabular-nums; }
.section h2.alert { color: var(--danger); }
.stat { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px; }
.stat b { display: block; font: 600 26px/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); }
.stat .btn { margin-top: 10px; }
.headline { font: 500 16px/1.4 var(--sans); color: var(--ink-2); margin: 0 0 24px; }

/* ---------- board ---------- */
.board-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--sunken); border-radius: 12px; padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; font-weight: 600; }
.col-head .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.col-head .lim { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.col-head .lim.over { color: var(--danger); }
.col-desc { font-size: 11.5px; color: var(--muted); padding: 0 4px; margin-top: -6px; }
.col-add { display: flex; }
.col-add input { flex: 1; padding: 7px 9px; border-radius: 8px; border: 1px dashed var(--line); background: transparent; outline: 0; min-width: 0; }
.col-add input:focus { border-style: solid; border-color: var(--accent); background: var(--panel); }
.card { background: var(--panel); border-radius: 9px; box-shadow: var(--shadow); padding: 9px 11px 10px; cursor: grab; }
.card:hover { box-shadow: 0 0 0 1px var(--accent), 0 2px 6px rgba(0,0,0,.06); }
.card.dragging { opacity: .45; }
.card .t { font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.card .cl { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }
.card .progress { height: 3px; border-radius: 2px; background: var(--sunken); margin-top: 8px; overflow: hidden; }
.card .progress i { display: block; height: 100%; background: var(--done); }
.drop-line { height: 3px; border-radius: 2px; background: var(--accent); margin: -3px 0; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 20, .28); z-index: 20; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); z-index: 21; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.d-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.d-body { flex: 1; overflow: auto; padding: 18px 20px 28px; display: grid; gap: 18px; align-content: start; }
.d-title { font: 600 21px/1.25 var(--serif); border: 0; outline: 0; background: none; width: 100%; resize: none; padding: 0; overflow: hidden; }
.moves { display: flex; gap: 4px; flex-wrap: wrap; }
.moves button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12.5px; font-weight: 500; }
.moves button.on { border-color: transparent; color: #fff; }
.moves button.on.b-inbox { background: var(--inbox); } .moves button.on.b-next { background: var(--next); } .moves button.on.b-doing { background: var(--doing); } .moves button.on.b-waiting { background: var(--waiting); } .moves button.on.b-done { background: var(--done); }
.moves kbd { font-size: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.box { border-radius: var(--radius); padding: 12px 14px; background: var(--sunken); display: grid; gap: 10px; }
.box h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.checklist { display: grid; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--done); }
.check .ct { flex: 1; }
.check.done .ct { text-decoration: line-through; color: var(--muted); }
.check button { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); }
.check:hover button { opacity: 1; }
.activity { display: grid; gap: 8px; font-size: 12.5px; }
.activity .a { display: flex; gap: 8px; color: var(--ink-2); }
.activity .a time { color: var(--muted); white-space: nowrap; margin-left: auto; font-variant-numeric: tabular-nums; }
.who-claude { color: var(--accent-ink); font-weight: 600; }
.warn { padding: 9px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--ink); font-size: 13px; }

/* ---------- modal ---------- */
.modal { position: fixed; z-index: 30; left: 50%; top: 14vh; transform: translateX(-50%); width: min(620px, calc(100vw - 32px)); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .15s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -6px) scale(.98); } }
.modal .qa { width: 100%; border: 0; outline: 0; padding: 18px 20px; font-size: 17px; background: none; }
.modal .preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 14px; min-height: 26px; }
.modal .foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 20px; border-top: 1px solid var(--line); background: var(--sunken); font-size: 12px; color: var(--muted); }
.modal .foot .spacer { flex: 1; }
.suggest { border-top: 1px solid var(--line); max-height: 220px; overflow: auto; }
.suggest button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 20px; border: 0; background: none; text-align: left; cursor: pointer; }
.suggest button.on, .suggest button:hover { background: var(--hover); }
.modal form { padding: 18px 20px; display: grid; gap: 12px; }
.modal h2 { margin: 0; font: 600 19px var(--serif); }

/* ---------- clients ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.ccard { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: inherit; display: grid; gap: 6px; }
.ccard:hover { box-shadow: 0 0 0 1px var(--accent); }
.ccard h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.ccard p { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.ccard .past { opacity: .6; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--sunken); }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(80% 60% at 80% 0%, rgba(196, 98, 31, .18), transparent 60%), var(--bg); }
.login form { width: min(360px, 100%); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; display: grid; gap: 14px; }
.login h1 { margin: 0; font: 600 26px var(--serif); display: flex; align-items: center; gap: 10px; }
.login h1 svg { width: 32px; height: 32px; }
.login p { margin: 0; color: var(--ink-2); }
.err { color: var(--danger); font-size: 13px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40; display: grid; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 9px 14px; border-radius: 10px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); display: flex; gap: 12px; align-items: center; animation: pop2 .2s; font-weight: 500; }
.toast button { background: none; border: 0; color: #f3a26d; font-weight: 600; cursor: pointer; }
.toast.bad { background: var(--danger); }
@keyframes pop2 { from { opacity: 0; transform: translateY(8px); } }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 6; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand small, .side .hint, .side .grow { display: none; }
  .brand { padding: 4px 8px; }
  .nav { display: flex; gap: 2px; }
  .nav a span.lbl { display: none; }
  .top { top: 52px; padding: 10px 14px; }
  .page { padding: 18px 14px 60px; }
  .row .meta { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
