/* HQ — one hand-written stylesheet, no build step. */
:root {
    --bg: #f6f5f2; --panel: #ffffff; --ink: #1c1b19; --muted: #6f6c66; --line: #e4e1da;
    --accent: #2f5fd0; --accent-ink: #ffffff; --soft: #efede8;
    --ok: #1f7a4d; --ok-bg: #e3f3ea; --warn: #9a6200; --warn-bg: #fbf0d9;
    --err: #b3261e; --err-bg: #fbe5e3; --info: #2f5fd0; --info-bg: #e6ecfb;
    --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141413; --panel: #1d1d1b; --ink: #ecebe7; --muted: #9c9992; --line: #2e2d2a;
        --accent: #7fa2f5; --accent-ink: #10131c; --soft: #262624;
        --ok: #6fcf9b; --ok-bg: #173325; --warn: #e6b455; --warn-bg: #3a2c10;
        --err: #f08a82; --err-bg: #3d1a17; --info: #9db8f7; --info-bg: #1b2540;
        --shadow: none;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 6px; font-weight: 650; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .center { text-align: center; justify-content: center; }
.nowrap { white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 750; font-size: 18px; color: var(--ink); padding: 0 8px; letter-spacing: -.02em; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side nav a { padding: 7px 10px; border-radius: 8px; color: var(--ink); }
.side nav a:hover { background: var(--soft); text-decoration: none; }
.side nav a.on { background: var(--soft); font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 8px 0; font-size: 13px; }
.side-foot .who { font-weight: 600; margin-bottom: 4px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Building blocks */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; } .grid > .card + .card { margin-top: 0; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stat { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
button.link { background: none; border: 0; padding: 0; margin-right: 10px; color: var(--muted); font: inherit; cursor: pointer; }
button.link:hover, button.link.on { color: var(--ink); }
button.link.on { font-weight: 650; }
form.inline { display: inline-flex; align-items: center; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.fields .wide { grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--info); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.empty { color: var(--muted); padding: 18px; text-align: center; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }

details.new > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.new > summary::-webkit-details-marker { display: none; }
details.new[open] > summary { margin-bottom: 12px; }

.prose { overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin: 16px 0 6px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose pre { background: var(--soft); padding: 10px; border-radius: 8px; overflow-x: auto; }
.prose blockquote { border-left: 3px solid var(--line); margin: 0; padding-left: 12px; color: var(--muted); }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.col { background: var(--soft); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.over { outline: 2px dashed var(--accent); }
.col h3 { display: flex; justify-content: space-between; padding: 2px 4px 8px; }
.tcard { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; color: var(--ink); }
.tcard:hover { text-decoration: none; border-color: var(--accent); }
.tcard.dragging { opacity: .4; }
.tcard .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.tcard.high { border-left: 3px solid var(--err); }
.late { color: var(--err); font-weight: 600; }

/* Timeline of stages */
.stages { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel); }
.stage.active { border-color: var(--accent); }
.stage.done { opacity: .7; }
.stage .n { font-size: 12px; color: var(--muted); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal .dow { background: var(--panel); padding: 6px 8px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.cal .day { background: var(--panel); min-height: 104px; padding: 6px; font-size: 12px; }
.cal .day.out { background: var(--bg); color: var(--muted); }
.cal .day.today .d { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 6px; }
.cal .d { font-weight: 600; display: inline-block; margin-bottom: 4px; }
.cal .ev { display: block; border-radius: 5px; padding: 1px 5px; margin-bottom: 2px; background: var(--info-bg); color: var(--info); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.task { background: var(--warn-bg); color: var(--warn); }
.cal .ev.stage { background: var(--ok-bg); color: var(--ok); }

/* Conversation */
.msg { padding: 8px 12px; border-radius: 10px; background: var(--soft); margin-bottom: 8px; max-width: 720px; }
.msg.mine { background: var(--info-bg); margin-left: auto; }
.msg .by { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

/* Guest pages */
body.guest { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.guest-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.guest-card .brand { padding: 0; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
    .side nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; }
    .side nav a { white-space: nowrap; }
    .side-foot { border: 0; padding: 0; margin-left: auto; display: flex; gap: 8px; align-items: center; }
    .side-foot .who { display: none; }
    .main { padding: 16px; }
    .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
    .cal .day { min-height: 70px; }
}
@media print {
    .side, .actions, .tabs, .no-print { display: none !important; }
    .shell { display: block; } .main { padding: 0; }
    body { background: #fff; color: #000; }
    .card { border: 0; box-shadow: none; padding: 0; }
}
