/* Sprintboard prototype — one stylesheet, tokens first. */

/* ================= TOKENS ================= */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --col-bg: #ebedf1;
  --border: #dfe2e8;
  --border-strong: #c3c8d1;
  --text: #172030;
  --text-2: #3f4a5c;
  --muted: #687385;
  --accent: #0e6b66;
  --accent-hover: #0b5a56;
  --accent-ink: #ffffff;
  --accent-soft: #e1f2ef;
  --accent-text: #0b5f5a;
  --focus: #2563eb;

  --danger: #b42318;
  --danger-soft: #fdeceb;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --ok: #17784a;
  --ok-soft: #e2f4ea;

  --sev-critical: #c62828; --sev-critical-soft: #fde7e7; --sev-critical-ink: #9b1414;
  --sev-high: #ef6c00;     --sev-high-soft: #feeddc;     --sev-high-ink: #9a3c05;
  --sev-medium: #f9a825;   --sev-medium-soft: #fdf3cf;   --sev-medium-ink: #7a5a00;
  --sev-low: #757575;      --sev-low-soft: #edf0f4;      --sev-low-ink: #475467;

  --l-green: #1f9254; --l-amber: #c98a06; --l-blue: #2f6fdb; --l-violet: #7b4fd6; --l-teal: #0f8a83; --l-red: #d0362f; --l-slate: #5d6b7e;
  --av-teal: #0e6b66; --av-rose: #be3a5f; --av-indigo: #4a4fc4; --av-amber: #a5620a; --av-slate: #56657a;

  --shadow-1: 0 1px 1px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 4px 10px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-3: 0 20px 48px rgba(16, 24, 40, .22), 0 4px 12px rgba(16, 24, 40, .1);
  --r: 10px;
  --r-sm: 6px;
  --gutter: 24px;
  --tl-label: 280px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1318; --surface: #171c23; --surface-2: #1c222a; --surface-3: #252c36; --col-bg: #141920;
    --border: #2a323d; --border-strong: #3a4452; --text: #e7ebf0; --text-2: #c2c9d3; --muted: #8d97a5;
    --accent: #2bb3a7; --accent-hover: #3cc4b8; --accent-ink: #062320; --accent-soft: #10302d; --accent-text: #5fd3c8; --focus: #6ea2ff;
    --danger: #f2655a; --danger-soft: #3a1714; --warn: #f0b847; --warn-soft: #33270c; --ok: #4cc98a; --ok-soft: #10301f;
    --sev-critical: #f05252; --sev-critical-soft: #3d1517; --sev-critical-ink: #ff9a9a;
    --sev-high: #f5813a;     --sev-high-soft: #3a2010;     --sev-high-ink: #ffb07e;
    --sev-medium: #e6b52e;   --sev-medium-soft: #352a0b;   --sev-medium-ink: #f3cf68;
    --sev-low: #8b99ad;      --sev-low-soft: #222a35;      --sev-low-ink: #b3bfcf;
    --l-green: #3fbf7a; --l-amber: #e5ae32; --l-blue: #6b9cf5; --l-violet: #a586f0; --l-teal: #34b8ae; --l-red: #f06a62; --l-slate: #94a3b8;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 12px rgba(0, 0, 0, .45); --shadow-3: 0 24px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1318; --surface: #171c23; --surface-2: #1c222a; --surface-3: #252c36; --col-bg: #141920;
  --border: #2a323d; --border-strong: #3a4452; --text: #e7ebf0; --text-2: #c2c9d3; --muted: #8d97a5;
  --accent: #2bb3a7; --accent-hover: #3cc4b8; --accent-ink: #062320; --accent-soft: #10302d; --accent-text: #5fd3c8; --focus: #6ea2ff;
  --danger: #f2655a; --danger-soft: #3a1714; --warn: #f0b847; --warn-soft: #33270c; --ok: #4cc98a; --ok-soft: #10301f;
  --sev-critical: #f05252; --sev-critical-soft: #3d1517; --sev-critical-ink: #ff9a9a;
  --sev-high: #f5813a;     --sev-high-soft: #3a2010;     --sev-high-ink: #ffb07e;
  --sev-medium: #e6b52e;   --sev-medium-soft: #352a0b;   --sev-medium-ink: #f3cf68;
  --sev-low: #8b99ad;      --sev-low-soft: #222a35;      --sev-low-ink: #b3bfcf;
  --l-green: #3fbf7a; --l-amber: #e5ae32; --l-blue: #6b9cf5; --l-violet: #a586f0; --l-teal: #34b8ae; --l-red: #f06a62; --l-slate: #94a3b8;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 12px rgba(0, 0, 0, .45); --shadow-3: 0 24px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ================= BASE ================= */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
kbd { font: 11px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--surface); }
ul, ol { margin: 0; padding: 0; list-style: none; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -40px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; box-shadow: var(--shadow-2); }
.skip:focus { top: 8px; }
.ic { width: 16px; height: 16px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.w-full { width: 100%; }
.row-between { display: flex; justify-content: space-between; gap: 8px; }
.warn-text { color: var(--warn); font-weight: 600; }
.danger-text { color: var(--danger); font-weight: 600; }
.ok-text { color: var(--ok); }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }
.h1 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.h2 { font-size: 18px; font-weight: 700; }
.h3 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; }

/* ================= BUTTONS ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent; font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 42px; font-size: 15px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0605; }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-soft); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.icon-btn-sm { width: 24px; height: 24px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-align: left; font-weight: 500; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; }

/* ================= FORMS ================= */
.input, .select { width: 100%; min-height: 34px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); transition: border-color .12s, box-shadow .12s; }
.input:hover, .select:hover { border-color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
textarea.input { resize: vertical; line-height: 1.5; }
.input-lg { min-height: 42px; font-size: 15px; }
.input-sm { min-height: 28px; padding: 3px 6px; font-size: 12.5px; }
.input-flat { border-color: transparent; background: transparent; padding-left: 4px; font-weight: 550; }
.input-flat:hover { border-color: var(--border); }
.select { appearance: none; padding-right: 30px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select-sm { min-height: 30px; font-size: 13px; width: auto; }
.select-strong { font-weight: 700; font-size: 15px; width: auto; min-height: 36px; }
.select-bare { width: auto; border-color: transparent; background-color: transparent; font-weight: inherit; font-size: inherit; padding-left: 6px; }
.select-bare:hover { background-color: var(--surface-3); border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .field > legend, .field-label { font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.field > label { margin-bottom: 0; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 550; }
.hint-text { color: var(--muted); font-size: 12px; }
.radio-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 0 8px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--border); white-space: nowrap; cursor: pointer; }
.radio-chip:has(input:checked) { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 8px; cursor: pointer; }
.radio-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-row input { margin-top: 3px; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.inline-add { display: flex; gap: 8px; margin-top: 8px; }
.inline-add .input, .inline-add .select { flex: 1; min-width: 0; }

/* ================= SMALL COMPONENTS ================= */
.av { --c: var(--av-slate); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-xs { width: 20px; height: 20px; font-size: 8.5px; }
.av-teal { --c: var(--av-teal); } .av-rose { --c: var(--av-rose); } .av-indigo { --c: var(--av-indigo); } .av-amber { --c: var(--av-amber); } .av-slate { --c: var(--av-slate); }
.av-none { background: transparent; color: var(--muted); border: 1.5px dashed var(--border-strong); box-shadow: none; }
.av-stack { display: flex; }
.av-stack .av + .av { margin-left: -6px; }

.sev { --s: var(--sev-low); display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px 0 6px; border-radius: 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; background: var(--sev-soft); color: var(--sev-ink); }
.sev i { width: 7px; height: 7px; border-radius: 2px; background: var(--s); }
.sev-critical { --s: var(--sev-critical); --sev-soft: var(--sev-critical-soft); --sev-ink: var(--sev-critical-ink); }
.sev-critical i { transform: rotate(45deg); }
.sev-high { --s: var(--sev-high); --sev-soft: var(--sev-high-soft); --sev-ink: var(--sev-high-ink); }
.sev-high i { border-radius: 50% 50% 2px 2px; }
.sev-medium { --s: var(--sev-medium); --sev-soft: var(--sev-medium-soft); --sev-ink: var(--sev-medium-ink); }
.sev-medium i { border-radius: 50%; }
.sev-low { --s: var(--sev-low); --sev-soft: var(--sev-low-soft); --sev-ink: var(--sev-low-ink); }
.sev-low i { height: 3px; }
.sev-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--s); flex: none; }
.sevbar-critical, .sevbg-critical { --s: var(--sev-critical); --sev-soft: var(--sev-critical-soft); --sev-ink: var(--sev-critical-ink); }
.sevbar-high, .sevbg-high { --s: var(--sev-high); --sev-soft: var(--sev-high-soft); --sev-ink: var(--sev-high-ink); }
.sevbar-medium, .sevbg-medium { --s: var(--sev-medium); --sev-soft: var(--sev-medium-soft); --sev-ink: var(--sev-medium-ink); }
.sevbar-low, .sevbg-low { --s: var(--sev-low); --sev-soft: var(--sev-low-soft); --sev-ink: var(--sev-low-ink); }

.lbl { --l: var(--l-slate); display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--l) 14%, transparent); color: color-mix(in srgb, var(--l) 70%, var(--text)); white-space: nowrap; }
.lbl[data-l] { --l: attr(data-l type(<color>), var(--l-slate)); }
.lbl i { width: 6px; height: 6px; border-radius: 50%; background: var(--l); }
.lbl-green { --l: var(--l-green); } .lbl-amber { --l: var(--l-amber); } .lbl-blue { --l: var(--l-blue); } .lbl-violet { --l: var(--l-violet); } .lbl-teal { --l: var(--l-teal); } .lbl-red { --l: var(--l-red); } .lbl-slate { --l: var(--l-slate); }
.lbl-toggle { border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); cursor: pointer; height: 26px; padding: 0 10px; border-radius: 13px; }
.lbl-toggle[aria-pressed="true"] { border: 1px solid var(--l); background: color-mix(in srgb, var(--l) 16%, transparent); color: color-mix(in srgb, var(--l) 70%, var(--text)); }
.lbl-toggle:hover { border-color: var(--l); }

.kc-key { font: 600 11px var(--mono); color: var(--muted); letter-spacing: .02em; }
.bar-lg { display: block; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-lg > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; width: attr(data-w type(<percentage>), 0%); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; margin: 10px 0; border: 1px solid; }
.alert > .ic { margin-top: 2px; }
.alert-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--text); }
.alert-error > .ic { color: var(--danger); }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-ok > .ic { color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); }
.alert-warn > .ic { color: var(--warn); }
.alert .icon-btn { margin: -6px -6px 0 auto; width: 28px; height: 28px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.lg-today { width: 2px; height: 14px; background: var(--danger); }
.lg-fill { width: 18px; height: 8px; border-radius: 2px; background: linear-gradient(90deg, color-mix(in srgb, var(--text) 22%, transparent) 60%, var(--surface-3) 60%); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; height: 28px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 650; }
.hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .ic { width: 28px; height: 28px; }
.empty.big { padding: 80px 16px; }
.empty.big .ic { width: 40px; height: 40px; }
.empty.big .h2 { color: var(--text); }

/* ================= TOAST ================= */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: var(--r-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow-3); font-size: 13.5px; animation: toastIn .18s ease-out; transition: opacity .25s, transform .25s; }
.toast .btn-ghost { color: var(--bg); text-decoration: underline; }
.toast .btn-ghost:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); }
.toast-ok { border-left: 4px solid var(--ok); }
.toast-error { border-left: 4px solid var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ================= MODAL ================= */
.modal { padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: hidden; }
.modal::backdrop { background: rgba(10, 15, 25, .55); }
.modal[open] { display: flex; flex-direction: column; animation: modalIn .16s ease-out; }
@keyframes modalIn { from { transform: translateY(10px) scale(.99); } }
.modal-sm { width: min(520px, calc(100vw - 32px)); }
.modal-lg { width: min(1000px, calc(100vw - 32px)); }
.modal-inner { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--border); }
.modal-head .h2, .modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 22px 22px; overflow-y: auto; overflow-x: hidden; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ================= SHELL ================= */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 var(--gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); font-weight: 750; font-size: 15.5px; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; flex-shrink: 1; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 4px; }
.crumbs a:hover { background: var(--surface-3); color: var(--text); }
.crumbs .current { color: var(--text); font-weight: 650; }
.crumb-sep { color: var(--border-strong); }
.crumb-select { color: var(--text); font-weight: 650; max-width: 260px; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top-link { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--text-2); font-weight: 550; font-size: 13.5px; }
.top-link:hover { background: var(--surface-3); color: var(--text); }
.top-link.on { color: var(--accent-text); background: var(--accent-soft); }
.menu { position: relative; }
.menu-btn { list-style: none; display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 20px; cursor: pointer; }
.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover { background: var(--surface-3); }
.menu-name { font-weight: 600; font-size: 13.5px; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-3); padding: 6px; z-index: 30; }
.menu-pop a, .menu-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); text-decoration: none; color: var(--text); cursor: pointer; text-align: left; font-size: 13.5px; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); }
.menu-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.role { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; text-transform: uppercase; letter-spacing: .04em; }
.role-admin { background: var(--accent-soft); color: var(--accent-text); }
.role-member { background: var(--surface-3); color: var(--text-2); }

.tabs { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 56px; z-index: 15; }
.tabs-inner { display: flex; gap: 2px; padding: 0 calc(var(--gutter) - 10px); overflow-x: auto; scrollbar-width: none; }
.tabs-inner::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; height: 44px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab.on .ic { color: var(--accent-text); }
.tab-count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 0 6px; border-radius: 9px; line-height: 18px; }

.view { padding: 22px var(--gutter) 48px; outline: none; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head .muted { margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs-inline { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs-inline button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs-inline button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ================= LOGIN ================= */
.view-login { min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr); }
.login-side { background: var(--accent); color: var(--accent-ink); padding: 48px; display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.login-side .brand-mark rect:first-child { fill: var(--accent-ink); }
.login-side .brand-mark rect:not(:first-child) { fill: var(--accent); }
.brand-lg { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 750; }
.brand-lg .brand-mark { width: 36px; height: 36px; }
.login-tag { font-size: 17px; opacity: .85; max-width: 26ch; }
.login-preview { margin-top: auto; display: flex; gap: 12px; opacity: .9; }
.lp-col { flex: 1; max-width: 140px; background: color-mix(in srgb, var(--accent-ink) 12%, transparent); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.lp-col i { display: block; height: 40px; border-radius: 6px; background: color-mix(in srgb, var(--accent-ink) 85%, transparent); box-shadow: inset 3px 0 0 var(--sev-low); }
.lp-col i.crit { box-shadow: inset 3px 0 0 var(--sev-critical); }
.lp-col i.high { box-shadow: inset 3px 0 0 var(--sev-high); }
.lp-col i.low { height: 28px; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; }
.login-card .h1 { font-size: 26px; }
.login-card > .muted { margin: 6px 0 20px; }
.proto-note { display: flex; gap: 8px; margin-top: 20px; padding: 10px 12px; background: var(--surface-3); border-radius: var(--r-sm); font-size: 12.5px; color: var(--text-2); }
.proto-note .ic { margin-top: 1px; color: var(--muted); }

/* ================= PROJECTS ================= */
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.proj-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); text-decoration: none; color: var(--text); box-shadow: var(--shadow-1); transition: border-color .12s, box-shadow .12s, transform .12s; }
.proj-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.proj-top { display: flex; justify-content: space-between; align-items: center; }
.proj-key { font: 700 11.5px var(--mono); background: var(--accent-soft); color: var(--accent-text); padding: 2px 8px; border-radius: 4px; }
.proj-name { font-size: 17px; font-weight: 700; }
.proj-desc { min-height: 2.9em; }
.proj-sprint { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.proj-stats { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
#new-project { margin-top: 20px; max-width: 560px; }
.print-only { display: none; }
.stat-crit { color: var(--sev-critical-ink); }
.stat-over { color: var(--danger); }

/* ================= BOARD ================= */
.view-board { padding-top: 16px; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 16px; }
.sprint-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.sprint-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.sprint-goal { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); max-width: 52ch; }
.board-tools { display: flex; align-items: center; gap: 10px; }
.progress-pill { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 0 12px; height: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: 17px; }
.progress-pill .bar { width: 80px; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress-pill .bar span { display: block; height: 100%; background: var(--ok); width: attr(data-w type(<percentage>), 0%); }

.board { --cols: 1; display: grid; grid-template-columns: repeat(var(--cols), minmax(272px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; width: 100%; min-width: 0; max-width: 100%; }
.board[data-cols] { --cols: attr(data-cols type(<number>), 1); }
.col { background: var(--col-bg); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 120px; scroll-snap-align: start; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.col-head h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.col-done .col-head h2::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 7px; vertical-align: 1px; }
.count { font-size: 12px; font-weight: 650; color: var(--muted); background: color-mix(in srgb, var(--text) 8%, transparent); padding: 0 7px; border-radius: 9px; line-height: 19px; }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 4px; overflow-y: auto; min-height: 48px; border-radius: 8px; transition: background .12s; }
.col-body.over { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.col-empty { display: none; border: 1.5px dashed var(--border-strong); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.col-body > .col-empty:first-child { display: block; }
.board.is-dragging .col-empty { display: block; padding: 8px; opacity: .7; }
.col-foot { padding: 6px 8px 8px; }
.btn-add { width: 100%; justify-content: flex-start; color: var(--muted); }
.add-form { display: flex; flex-direction: column; background: var(--surface); padding: 8px; border-radius: 8px; box-shadow: var(--shadow-1); }
.add-form .add-row { margin-top: 6px; }

.kcard { position: relative; background: var(--surface); border-radius: 8px; padding: 10px 12px 10px 14px; box-shadow: var(--shadow-1); cursor: grab; display: flex; flex-direction: column; gap: 6px; border: 1px solid transparent; transition: box-shadow .12s, border-color .12s; }
.kcard::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--s, var(--sev-low)); }
.edge-critical { --s: var(--sev-critical); } .edge-high { --s: var(--sev-high); } .edge-medium { --s: var(--sev-medium); } .edge-low { --s: var(--sev-low); }
.kcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.kcard:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.kcard.dragging { opacity: .35; box-shadow: none; border: 1.5px dashed var(--border-strong); }
.kcard:active { cursor: grabbing; }
.kc-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.kc-labels .lbl { height: 18px; font-size: 10.5px; padding: 0 6px; }
.kc-title { font-size: 14px; font-weight: 600; line-height: 1.35; margin-top: -2px; }
.kcard.is-done .kc-title { color: var(--text-2); }
.kcard .kc-key { margin-bottom: -4px; }
.kc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.due .ic { width: 13px; height: 13px; color: var(--muted); }
.due-tag { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; margin-left: 2px; }
.due-overdue { color: var(--danger); }
.due-overdue .ic { color: var(--danger); }
.due-overdue .due-tag, .due-tag.due-overdue { background: var(--danger-soft); color: var(--danger); }
.due-soon .due-tag { background: var(--warn-soft); color: var(--warn); }
.due-done { color: var(--ok); }
.due-done .ic { color: var(--ok); }
.kc-foot { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); min-height: 24px; }
.kc-stat { display: inline-flex; align-items: center; gap: 4px; }
.kc-stat .ic { width: 13px; height: 13px; }
.kc-stat.all { color: var(--ok); }
.mini { display: inline-block; width: 26px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-left: 2px; }
.mini span { display: block; height: 100%; background: var(--ok); width: attr(data-w type(<percentage>), 0%); }
.kc-av { margin-left: auto; }

/* columns editor */
.settings-stack { display: flex; flex-direction: column; gap: 20px; max-width: 760px; min-width: 0; }
.label-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.label-presets button { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); padding: 0; cursor: pointer; background: attr(data-preset type(<color>), var(--surface-3)); }
#labelList input[type="color"], #addLabel input[type="color"] { width: 36px; height: 32px; padding: 0; border: 1px solid var(--border-strong); background: transparent; flex: 0 0 auto; }
.col-edit { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; overflow-x: auto; max-width: 100%; }
.col-edit li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.col-edit .input { flex: 1; min-width: 0; }
.col-pos { width: 22px; text-align: center; font: 600 12px var(--mono); color: var(--muted); }

/* ================= CARD DIALOG ================= */
.card-crumb { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.title-input { width: 100%; border: 1px solid transparent; background: transparent; font-size: 21px; font-weight: 700; line-height: 1.3; padding: 4px 6px; margin: -4px -6px 14px; border-radius: var(--r-sm); resize: none; overflow: hidden; letter-spacing: -.01em; }
.title-input:hover { background: var(--surface-2); }
.title-input:focus { outline: none; background: var(--surface); border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.card-grid { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 28px; }
.card-side { display: flex; flex-direction: column; padding-left: 24px; border-left: 1px solid var(--border); }
.sev-preview { margin-top: 2px; }
.label-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.sec { margin-bottom: 26px; }
.sec-h { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.sec-h .ic { color: var(--muted); }
.sec-h .muted { font-weight: 500; margin-left: 2px; }
.sec .bar-lg { margin-bottom: 10px; }
.details { display: flex; flex-direction: column; }
.detail { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); }
.detail:first-child { border-top: 0; }
.detail > input[type="checkbox"] { margin-top: 9px; }
.detail-body { flex: 1; min-width: 0; }
.detail.done .input-flat { text-decoration: line-through; color: var(--muted); }
.detail-dates { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.detail-dates label { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.detail-dates .input-sm { width: auto; }
.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.file > div { flex: 1; min-width: 0; }
.file a { font-weight: 600; text-decoration: none; word-break: break-all; }
.file a:hover { text-decoration: underline; }
.file-ic { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--muted); flex: none; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 18px; margin-top: 10px; border: 1.5px dashed var(--border-strong); border-radius: var(--r); text-align: center; color: var(--text-2); cursor: pointer; transition: background .12s, border-color .12s; }
.dropzone .ic { width: 22px; height: 22px; color: var(--muted); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone .bar-lg { width: 100%; max-width: 240px; }
.dropzone .bar-lg > span { width: attr(data-w type(<percentage>), 0%); }
.dz-sm { flex-direction: row; gap: 10px; padding: 12px; margin: 0 0 14px; }
.comment-new { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.comment-new .btn { margin-top: 8px; }
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; }
.comment-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.comment-text { margin-top: 4px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 var(--r) var(--r) var(--r); white-space: pre-wrap; }
.comment .link-btn { font-size: 12px; color: var(--muted); margin-top: 4px; text-decoration: underline; }
.history { display: flex; flex-direction: column; }
.history li { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-top: 1px dashed var(--border); }
.history li:first-child { border-top: 0; }
.history li.muted { display: block; }
.related { display: flex; flex-direction: column; gap: 4px; }
.related li { display: flex; align-items: flex-start; gap: 4px; font-size: 13px; }
.related .link-btn { flex: 1; line-height: 1.35; padding: 3px 0; }
.side-actions { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

/* ================= TIMELINE ================= */
#timelineApp { max-width: 100%; overflow-x: hidden; }
.tl-scroll, .timeline-scroll { position: relative; overflow: auto; max-width: 100%; max-height: calc(100vh - 230px); min-height: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-1); overscroll-behavior-x: contain; }
.tl { position: relative; min-width: 100%; --day: 32px; }
.tl[data-days] { width: calc(var(--tl-label) + (var(--days) * var(--day))); }
.tl-month[data-span] { width: calc(var(--span) * var(--day)); }
.tl-bg[data-days] { width: calc(var(--days) * var(--day)); }
.tl-we[data-i] { left: calc(var(--i) * var(--day)); width: var(--day); }
.tl-today[data-x] { left: calc(var(--x) * var(--day)); }
.tl-sprint[data-x], .tl-bar[data-x], .tl-thin[data-x] { left: calc(var(--x) * var(--day)); width: calc(var(--w) * var(--day)); }
.tl-head { position: sticky; top: 0; z-index: 6; display: flex; background: var(--surface); border-bottom: 1px solid var(--border); }
.tl-corner { position: sticky; left: 0; z-index: 7; width: var(--tl-label); flex: none; display: flex; align-items: flex-end; padding: 0 14px 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface); border-right: 1px solid var(--border); }
.tl-months, .tl-days { display: flex; }
.tl-month { flex: none; padding: 6px 8px 2px; font-size: 12px; font-weight: 700; color: var(--text-2); border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.tl-day { flex: none; width: var(--day); display: flex; flex-direction: column; align-items: center; padding: 2px 0 6px; font-size: 11px; color: var(--muted); line-height: 1.2; }
.tl-day b { font-weight: 600; color: var(--text-2); }
.tl-day.we { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.tl-day.today b { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 5px; }
.tl-body { position: relative; }
.tl-bg { position: absolute; top: 0; bottom: 0; left: var(--tl-label); pointer-events: none; background-image: repeating-linear-gradient(to right, color-mix(in srgb, var(--border) 60%, transparent) 0 1px, transparent 1px var(--day)); }
.tl-we { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--text) 3.5%, transparent); pointer-events: none; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 0; margin-left: -1px; border-left: 2px dashed var(--danger); background: none; z-index: 4; pointer-events: none; }
.tl-today span { position: sticky; top: 0; display: block; transform: translateX(-50%); margin-left: 1px; width: max-content; font-size: 10px; font-weight: 700; color: #fff; background: var(--danger); padding: 1px 6px; border-radius: 0 0 4px 4px; }
.tl-row { display: flex; position: relative; }
.tl-label { position: sticky; left: 0; z-index: 5; width: var(--tl-label); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 14px; background: var(--surface); border-right: 1px solid var(--border); min-height: 36px; }
.tl-track { position: relative; flex: 1; min-height: 36px; }
.tl-group { border-top: 1px solid var(--border); }
.tl-group:first-of-type { border-top: 0; }
.tl-group .tl-label { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; padding-top: 10px; padding-bottom: 8px; background: var(--surface-2); min-height: 52px; }
.tl-group .tl-track { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tl-sprint { position: absolute; top: 12px; height: 26px; border-radius: 6px; border: 1.5px solid color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 9%, transparent); display: flex; align-items: center; padding: 0 10px; overflow: hidden; }
.tl-sprint span { font-size: 12px; color: var(--accent-text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; background: none; border: 0; padding: 4px 0; cursor: pointer; text-align: left; }
.tl-name:hover .tl-title { color: var(--accent-text); text-decoration: underline; }
.tl-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name .kc-key { margin: 0; flex: none; }
.tl-card .tl-label, .tl-card .tl-track { min-height: 38px; }
.tl-bar { position: absolute; top: 7px; height: 24px; display: flex; align-items: center; border: 0; padding: 0; min-width: 0; border-radius: 5px; background: var(--sev-soft); color: var(--sev-ink); box-shadow: inset 3px 0 0 var(--s), inset 0 0 0 1px color-mix(in srgb, var(--s) 45%, transparent); cursor: pointer; overflow: hidden; z-index: 2; font-size: 12px; font-weight: 600; text-align: left; transition: transform .1s, box-shadow .1s; }
.tl-bar:hover { box-shadow: inset 3px 0 0 var(--s), inset 0 0 0 1.5px var(--s), var(--shadow-2); }
.tl-fill { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--s) 22%, transparent); pointer-events: none; }
.tl-bar-text { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-bar-text .ic { width: 13px; height: 13px; }
.tl-bar.done { background: var(--surface-3); color: var(--muted); box-shadow: inset 3px 0 0 var(--ok), inset 0 0 0 1px var(--border-strong); }
.tl-bar.done .tl-fill { background: transparent; }
.tl-bar.overdue { box-shadow: inset 3px 0 0 var(--s), inset 0 0 0 1.5px var(--danger); outline: 2px solid var(--danger); }
.tl-flag { position: absolute; top: 11px; font-size: 10.5px; font-weight: 700; color: var(--danger); background: var(--danger-soft); padding: 1px 6px; border-radius: 4px; z-index: 2; white-space: nowrap; }
.tl-detail .tl-label, .tl-detail .tl-track { min-height: 24px; }
.tl-sub { display: flex; align-items: center; gap: 7px; padding-left: 16px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-sub.done { color: var(--muted); text-decoration: line-through; }
.tl-sub .ic { width: 12px; height: 12px; color: var(--ok); flex: none; }
.tl-sub-dot { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; margin: 0 3px; }
.tl-thin { position: absolute; top: 9px; height: 6px; border: 0; padding: 0; min-width: 0; border-radius: 4px; background: color-mix(in srgb, var(--s) 70%, transparent); cursor: pointer; z-index: 2; }
.tl-thin:hover { background: var(--s); }
.tl-thin:focus-visible { outline-offset: 3px; }
.tl-thin.done { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--s) 60%, transparent); }
.tl-thin.overdue { box-shadow: 0 0 0 1.5px var(--danger); outline: 2px solid var(--danger); }

/* ================= CALENDAR ================= */
.cal-title { font-size: 16px; font-weight: 700; min-width: 140px; text-align: center; }
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-dow div { padding: 8px 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-cell { min-height: 118px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-cell.we { background: color-mix(in srgb, var(--text) 2%, transparent); }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-num { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.cal-num { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 2px 4px; align-self: flex-start; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell.today .cal-num { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 1px 7px; }
.cal-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-item { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; border: 0; padding: 2px 6px; border-radius: 4px; font-size: 11.5px; text-align: left; cursor: pointer; background: none; color: var(--text-2); }
.cal-item > span:not(.sr):not(.sev-dot) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-due { background: var(--sev-soft); color: var(--sev-ink); box-shadow: inset 3px 0 0 var(--s); font-weight: 600; padding-left: 8px; flex-wrap: nowrap; }
.cal-due:hover { box-shadow: inset 3px 0 0 var(--s), inset 0 0 0 1px var(--s); }
.cal-due.done { background: var(--surface-3); color: var(--muted); box-shadow: inset 3px 0 0 var(--ok); }
.cal-due.overdue { box-shadow: inset 3px 0 0 var(--s), inset 0 0 0 1.5px var(--danger); }
.cal-time { font-weight: 500; opacity: .8; flex: none; }
.cal-t { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.cal-t .ic { width: 12px; height: 12px; }
.cal-detail:hover, .cal-start:hover { background: var(--surface-3); }
.cal-detail.done { text-decoration: line-through; color: var(--muted); }
.cal-start { color: var(--muted); border: 1px dashed var(--border-strong); }
.cal-start .ic { width: 10px; height: 10px; }
.cal-item.lg { display: inline-flex; width: auto; cursor: default; }
.agenda { display: none; }
.ag-day { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.ag-date { width: 44px; flex: none; display: flex; flex-direction: column; align-items: center; }
.ag-date b { font-size: 20px; line-height: 1.1; }
.ag-date span { font-size: 11.5px; color: var(--muted); }
.ag-day.today .ag-date b { color: var(--accent-text); }
.ag-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ag-items .cal-item { font-size: 13px; padding: 5px 8px; }

/* ================= REPORTS ================= */
.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-1); padding: 28px 32px 32px; max-width: 980px; }
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid var(--text); margin-bottom: 20px; }
.paper-head .h2 { font-size: 24px; margin: 2px 0 4px -6px; }
.paper-head .h2 .select-bare { font-size: 24px; font-weight: 750; }
.eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-text); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); }
.stat-n { font-size: 28px; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .bar-lg { margin-top: 6px; }
.stats-sm .stat-n { font-size: 22px; }
.stats-sm { margin: 12px 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.table tbody th { font-weight: 500; }
.table tfoot th, .table tfoot td { border-bottom: 0; border-top: 2px solid var(--border-strong); font-weight: 650; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; width: 80px; }
.table .w-bar { width: 36%; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.split { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
.split-done { background: var(--ok); }
.split-open { background: var(--s); opacity: .85; }
.key-done, .key-open { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--ok); margin: 0 4px 0 8px; vertical-align: -1px; }
.key-open { background: var(--sev-high); }
.done-list { display: flex; flex-direction: column; gap: 6px; }
.done-list li { display: flex; align-items: center; gap: 8px; }
.done-list .ic { color: var(--ok); }
.workload { display: flex; flex-direction: column; gap: 22px; }
.wl-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.wl-bar { width: 160px; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.wl-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.wl-n { font-size: 20px; font-weight: 750; width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* ================= ARCHIVE ================= */
.arch-list { display: flex; flex-direction: column; gap: 10px; max-width: 980px; }
.arch { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.arch.confirming { border-color: var(--danger); }
.arch-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.arch-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.arch-actions { display: flex; gap: 8px; }
.confirm { grid-column: 1 / -1; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; background: var(--danger-soft); border-radius: var(--r-sm); }
.confirm > .ic { color: var(--danger); margin-top: 2px; }
.confirm p { margin-top: 2px; color: var(--text-2); }
.confirm-actions { display: flex; gap: 8px; margin-left: auto; align-self: center; }
.view-archive .sec { max-width: 980px; margin-top: 28px; }

/* ================= ADMIN / IMPORT ================= */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-1); }
.panel > .h3:first-child { margin-top: 0; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.row-muted td { color: var(--muted); }
.row-muted .av { opacity: .5; }
.status-on, .status-off { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.status-on::before, .status-off::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-off { color: var(--muted); }
.status-off::before { background: var(--border-strong); }
.import-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.import-grid textarea { font-size: 12.5px; }
.result-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 280px; text-align: center; color: var(--text-2); border-style: dashed; box-shadow: none; }
.result-empty .ic { width: 28px; height: 28px; color: var(--muted); }
.result > .h3 { margin-top: 0; }
.warn-list { display: flex; flex-direction: column; gap: 8px; }
.warn-list li { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-soft); font-size: 13px; }
.warn-list .ic { color: var(--warn); margin-top: 2px; }
.raw { margin-top: 14px; }
.raw summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); }
.raw pre { background: var(--surface-3); padding: 12px; border-radius: var(--r-sm); overflow-x: auto; margin: 8px 0 0; }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .admin-grid, .import-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .card-side { padding-left: 0; border-left: 0; border-top: 1px solid var(--border); padding-top: 18px; order: -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px; }
  .card-side > fieldset, .card-side > .field:nth-last-child(2), .card-side .side-actions { grid-column: 1 / -1; }
  .card-main { order: 0; padding-top: 10px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { padding: 22px 20px; }
  .login-tag, .login-preview { display: none; }
}
@media (max-width: 767px) {
  :root { --tl-label: 140px; }
  .tl { --day: 22px; }
  .board { grid-template-columns: repeat(var(--cols), 85vw); scroll-snap-type: x mandatory; }
  .proj-grid { grid-template-columns: minmax(0, 1fr); }
  .col, .kcard, .board-head, .sprint-switch, .board-tools { min-width: 0; max-width: 100%; }
  #card-dialog.modal { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .cal { display: none; }
  .agenda { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 0 12px; }
  .ag-day:first-child { border-top: 0; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --tl-label: 140px; }
  body { font-size: 14.5px; }
  .topbar { gap: 8px; height: 52px; }
  .tabs { top: 52px; }
  .brand-name, .menu-name, .top-link, .crumbs > a, .crumbs .crumb-sep { display: none; }
  .crumbs { flex: 1; }
  .crumb-select { max-width: 100%; min-width: 0; text-overflow: ellipsis; }
  .crumbs .current { padding-left: 4px; }
  .top-link { padding: 0 8px; }
  .tab { padding: 0 10px; height: 42px; }
  .view { padding-top: 16px; }
  .h1 { font-size: 20px; }
  .view-head { align-items: flex-start; }
  .board-head { flex-direction: column; align-items: stretch; }
  .board-tools { justify-content: space-between; }
  .sprint-goal { display: none; }
  .board { grid-template-columns: repeat(var(--cols), 85vw); scroll-snap-type: x mandatory; }
  .col { max-height: none; }
  .hint kbd, .hint { font-size: 12px; }
  .modal { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .modal-sm { height: auto; max-height: 92dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  .modal-inner { max-height: 100dvh; }
  .modal-body { padding: 16px; }
  .modal-head { padding: 12px 10px 10px 16px; }
  .card-side { grid-template-columns: minmax(0, 1fr); }
  .title-input { font-size: 19px; }
  .detail-dates { flex-direction: column; align-items: stretch; gap: 4px; }
  .detail-dates label { justify-content: space-between; }
  .paper { padding: 18px 16px; }
  .paper-head .h2 .select-bare { font-size: 20px; }
  .table .w-bar { display: none; }
  .table .num { width: auto; }
  .paper .table { font-size: 13px; }
  .paper .table th, .paper .table td { padding: 8px 6px; }
  .paper .table:not(.sev-table) thead { display: none; }
  .paper .table:not(.sev-table) tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .paper .table:not(.sev-table) td { border: 0; padding: 0; }
  .paper .table:not(.sev-table) td:first-child { grid-column: 1 / -1; }
  .wl-bar { width: 60px; }
  .arch { grid-template-columns: 1fr; }
  .arch-actions { flex-wrap: wrap; }
  .confirm-actions { margin-left: 0; width: 100%; }
  .confirm-actions .btn { flex: 1; }
  .toolbar { width: 100%; }
  .view-calendar .toolbar { justify-content: space-between; }
  .cal-title { min-width: 0; flex: 1; }
  .proj-grid { grid-template-columns: 1fr; }
  .tl-scroll { max-height: calc(100vh - 260px); }
  .tl-corner { padding-left: 10px; }
  .tl-label { padding: 0 8px 0 10px; }
  .tl-name .kc-key { display: none; }
  .tl-label .av { display: none; }
  .tl-sub { padding-left: 4px; }
}

/* Report tables only. Other .paper tables keep the collapse above. */
@media (max-width: 640px) {
  .paper.report-sheet .table:not(.sev-table) tr {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .paper.report-sheet .table:not(.sev-table) th,
  .paper.report-sheet .table:not(.sev-table) td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    grid-column: auto;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .paper.report-sheet .table:not(.sev-table) td:first-child {
    grid-column: auto;
  }
  .paper.report-sheet .table:not(.sev-table) th[data-label]::before,
  .paper.report-sheet .table:not(.sev-table) td[data-label]::before {
    content: attr(data-label);
    flex: none;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
  }
}

/* ================= PRINT ================= */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; }
  .topbar, .tabs, .no-print, .toasts, .skip { display: none !important; }
  .view { padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .paper-head .select-bare { appearance: none; background: none; padding: 0; }
  .link-btn { color: #000; }
  .split, .bar-lg { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ================= SERVER-RENDERED SHELL (Task 1.3) ================= */
.main-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; height: 32px; padding: 0 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--text-2); font-weight: 550; font-size: 13.5px; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.on { color: var(--accent-text); background: var(--accent-soft); }
.nav-who { padding: 0 8px; }
.nav-logout { margin: 0; }
.nav-toggle { display: none; margin-left: auto; }
@media (max-width: 767px) {
  .nav-toggle { display: inline-grid; }
  .main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; margin: 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px var(--gutter) 12px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-2); }
  .topbar.nav-open .main-nav { display: flex; }
  .nav-link { height: 40px; }
  .nav-who { padding: 6px 10px; }
  .nav-logout .btn { width: 100%; height: 40px; }
  .brand-name { display: inline; }
}

.sprint-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 8px 10px; align-items: end; margin-bottom: 16px; max-width: 100%; }
.sprint-form .field { margin-bottom: 0; min-width: 0; }
.sprint-form .sprint-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-tabs { margin-bottom: 16px; }
.kcard { min-width: 0; }
.kc-title { overflow-wrap: anywhere; }
.sprint-meta { min-width: 0; overflow-wrap: anywhere; }
.proj-name a { color: inherit; text-decoration: none; }
.proj-name a:hover { color: var(--accent-text); }
.card-tabs { min-width: 0; max-width: 100%; overflow-x: auto; }
.detail-add { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-width: 100%; }
.detail-add .input, .detail-add .select, .detail-edit .input, .detail-edit .select { width: 100%; min-width: 0; max-width: 100%; }
.detail-title { font-weight: 600; overflow-wrap: anywhere; }
.detail.done .detail-title { text-decoration: line-through; color: var(--muted); }
.detail-dates > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.detail-dates > span b { font-weight: 600; color: var(--text-2); }
.detail-edit .add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comment-text { overflow-wrap: anywhere; }
.history li > :nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.link-results { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 6px; max-width: 100%; }
.link-results .link-btn { max-width: 100%; overflow-wrap: anywhere; }
.sev-critical, .edge-critical { --s: #c62828; }
.sev-high, .edge-high { --s: #ef6c00; }
.sev-medium, .edge-medium { --s: #f9a825; }
.sev-low, .edge-low { --s: #757575; }
