/* ===== Tokens ===== */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f0efec;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --danger: #d03b3b;
  --danger-soft: #fbeaea;
  --ok: #0a8a0a;

  --pri-urgent: #d03b3b;
  --pri-high: #ec835a;
  --pri-medium: #2a78d6;
  --pri-low: #9a9893;
  --pri-urgent-soft: #fbe7e7;
  --pri-high-soft: #fdeee7;
  --pri-medium-soft: #e6f0fc;
  --pri-low-soft: #f0efec;

  --st-todo: #898781;
  --st-in_progress: #2a78d6;
  --st-blocked: #d03b3b;
  --st-done: #0ca30c;

  --av1: #2a78d6; --av2: #eb6834; --av3: #1baf7a; --av4: #c98500;
  --av5: #d55181; --av6: #008300; --av7: #6250d6; --av8: #e34948;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);
  --radius: 10px;
  --radius-sm: 7px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dark colours. Applied when the theme switch is on "Dark", or on "Auto" when the device is in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #20201e;
    --surface-3: #2a2a28;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8d86;
    --accent: #3987e5;
    --accent-soft: #1c2b3f;
    --danger: #e66767;
    --danger-soft: #3a1f1f;
    --ok: #0ca30c;
    --pri-urgent: #e66767;
    --pri-high: #ec835a;
    --pri-medium: #3987e5;
    --pri-low: #8f8d86;
    --pri-urgent-soft: #3a1f1f;
    --pri-high-soft: #3a2a20;
    --pri-medium-soft: #1c2b3f;
    --pri-low-soft: #2a2a28;
    --st-in_progress: #3987e5;
    --st-blocked: #e66767;
    --av1: #3987e5; --av2: #d95926; --av3: #199e70; --av4: #c98500;
    --av5: #d55181; --av6: #008300; --av7: #9085e9; --av8: #e66767;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0e;
  --surface: #1a1a19;
  --surface-2: #20201e;
  --surface-3: #2a2a28;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8d86;
  --accent: #3987e5;
  --accent-soft: #1c2b3f;
  --danger: #e66767;
  --danger-soft: #3a1f1f;
  --ok: #0ca30c;
  --pri-urgent: #e66767;
  --pri-high: #ec835a;
  --pri-medium: #3987e5;
  --pri-low: #8f8d86;
  --pri-urgent-soft: #3a1f1f;
  --pri-high-soft: #3a2a20;
  --pri-medium-soft: #1c2b3f;
  --pri-low-soft: #2a2a28;
  --st-in_progress: #3987e5;
  --st-blocked: #e66767;
  --av1: #3987e5; --av2: #d95926; --av3: #199e70; --av4: #c98500;
  --av5: #d55181; --av6: #008300; --av7: #9085e9; --av8: #e66767;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px ui-monospace, Consolas, monospace; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Form controls ===== */
input:not([type=checkbox]):not([type=file]), select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; flex-shrink: 0; }
.input-sm, .select-sm { padding: 5px 8px !important; font-size: 13px; }
.select-sm { width: auto !important; max-width: 220px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  width: 32px; height: 32px;
  border: none; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.xs { width: 24px; height: 24px; }
.icon-btn.with-count { width: auto; padding: 0 6px; font-size: 12px; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; gap: 2px; flex-shrink: 0; }
.segmented button {
  display: inline-flex; align-items: center; gap: 5px;
  border: none; background: transparent; padding: 5px 10px; border-radius: 6px;
  cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span:first-child { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }

/* ===== Pills, dots, avatars ===== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill .dot, .chip .dot, .segmented .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pri-urgent { --pc: var(--pri-urgent); --ps: var(--pri-urgent-soft); }
.pri-high { --pc: var(--pri-high); --ps: var(--pri-high-soft); }
.pri-medium { --pc: var(--pri-medium); --ps: var(--pri-medium-soft); }
.pri-low { --pc: var(--pri-low); --ps: var(--pri-low-soft); }
.pill[class*="pri-"] { background: var(--ps); color: var(--text); }
.pill[class*="pri-"] .dot { background: var(--pc); }
.segmented button[class*="pri-"] .dot { background: var(--pc); }
.pill[class*="st-"] { background: var(--surface-3); color: var(--text); }
.pill-muted { background: var(--surface-3); color: var(--muted); font-weight: 500; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.st-todo { background: var(--st-todo); }
.status-dot.st-in_progress { background: var(--st-in_progress); }
.status-dot.st-blocked { background: var(--st-blocked); }
.status-dot.st-done { background: var(--st-done); }

.select-pill {
  width: auto !important; padding: 3px 24px 3px 9px !important;
  border-radius: 999px !important; font-size: 12.5px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent !important;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 8px center !important;
}
.select-pill[class*="pri-"] { background-color: var(--ps); box-shadow: inset 3px 0 0 var(--pc); }
.select-pill.st-todo { background-color: var(--surface-3); }
.select-pill.st-in_progress { background-color: var(--pri-medium-soft); }
.select-pill.st-blocked { background-color: var(--pri-urgent-soft); }
.select-pill.st-done { background-color: color-mix(in srgb, var(--st-done) 16%, var(--surface)); }
.select-pill:hover { border-color: var(--border-strong) !important; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0;
  background: var(--av1);
  letter-spacing: .02em;
}
.av-xs { width: 20px; height: 20px; font-size: 9px; }
.av-sm { width: 24px; height: 24px; font-size: 10px; }
.av-md { width: 30px; height: 30px; font-size: 12px; }
.av-c1 { background: var(--av1); } .av-c2 { background: var(--av2); } .av-c3 { background: var(--av3); } .av-c4 { background: var(--av4); }
.av-c5 { background: var(--av5); } .av-c6 { background: var(--av6); } .av-c7 { background: var(--av7); } .av-c8 { background: var(--av8); }
.av-more { background: var(--surface-3); color: var(--text-2); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

.project-tag {
  display: inline-block; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--text-2);
  background: var(--surface-3); padding: 1px 7px; border-radius: 5px;
}
.task-id { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-right: 6px; font-weight: 500; }
.badge { background: var(--surface-3); color: var(--text-2); font-size: 11.5px; padding: 0 7px; border-radius: 999px; margin-left: 8px; font-weight: 600; }

.progress { display: block; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--st-done); border-radius: 99px; transition: width .25s; }
.progress.thin { height: 4px; }

/* ===== Auth ===== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.auth-card h1 { font-size: 20px; margin-top: 8px; }

/* ===== Shell ===== */
.shell { display: flex; height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; padding: 2px 8px 14px; }
.brand-lg { font-size: 17px; padding: 0; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-section {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 16px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.muted { color: var(--muted); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-empty { font-size: 12.5px; color: var(--muted); padding: 4px 8px; }
.nav-archived summary { font-size: 12.5px; color: var(--muted); padding: 6px 8px; cursor: pointer; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.me-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.theme-switch { display: flex; background: var(--surface-3); border-radius: 8px; padding: 2px; gap: 2px; margin: 2px 4px; }
.theme-switch button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: none; background: transparent; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 12px; font-weight: 500; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.me-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.toolbar-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-block { min-width: 0; }
.title-block h1 { font-size: 19px; }
.title-block p { font-size: 12.5px; }
.toolbar-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 8px; color: var(--muted); min-width: 200px; flex: 0 1 280px; }
.search input { border: none !important; box-shadow: none !important; padding: 6px 0 !important; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.chip .dot { background: var(--pc); }
.chip.on { background: var(--ps); border-color: var(--pc); color: var(--text); font-weight: 600; }
.menu-btn { display: none; }
.content { flex: 1; overflow: auto; padding: 18px 20px; }
.scrim { display: none; }

.loading, .empty { padding: 40px; text-align: center; color: var(--muted); }
.empty.big { padding: 80px 20px; font-size: 15px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ===== Board ===== */
.board { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)) minmax(160px, 200px); gap: 14px; align-items: start; min-height: 100%; }
.board:not(:has(.collapsed)) { grid-template-columns: repeat(4, minmax(250px, 1fr)); }
.board.board-done { grid-template-columns: 1fr; }
.board.board-done .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 160px; transition: background .1s, border-color .1s; }
.column.drop-over { background: var(--accent-soft); border-color: var(--accent); }
.column-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; padding: 2px 4px 10px; }
.column-head .count { color: var(--muted); font-weight: 600; margin-left: auto; font-variant-numeric: tabular-nums; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.column-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 18px 0; }
.done-drop { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 6px; border: 1.5px dashed var(--border-strong); border-radius: 9px; }
.done-drop .icon { color: var(--st-done); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 11px; cursor: pointer; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 7px;
  border-left: 3px solid var(--pc, var(--border));
  transition: box-shadow .12s, transform .12s;
}
.card:hover { box-shadow: var(--shadow); }
.card.dragging { opacity: .45; }
.card[draggable="true"] { cursor: grab; }
.pri-border-urgent { --pc: var(--pri-urgent); }
.pri-border-high { --pc: var(--pri-high); }
.pri-border-medium { --pc: var(--pri-medium); }
.pri-border-low { --pc: var(--pri-low); }
.card-top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.card-title { font-weight: 600; line-height: 1.35; word-break: break-word; }
.card-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card .age { font-variant-numeric: tabular-nums; }
.meta-ic { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.comment-btn { border: none; background: transparent; cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.comment-btn:hover { background: var(--surface-3); color: var(--text); }

/* ===== List ===== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; }
.task-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.th-btn { border: none; background: transparent; padding: 9px 10px; color: inherit; font-weight: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.th-btn:hover { color: var(--text); }
.sort-ind { font-size: 9px; }
.task-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.task-row { cursor: pointer; }
.task-row:hover { background: var(--surface-2); }
.task-row.open { background: var(--accent-soft); }
.task-row.is-done .row-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.col-caret { width: 34px; padding-right: 0 !important; }
.caret .icon { transition: transform .15s; }
.caret[aria-expanded="true"] .icon { transform: rotate(90deg); }
.col-title { min-width: 260px; }
.row-title { font-weight: 600; }
.row-sub { display: flex; align-items: center; gap: 4px; font-size: 12px; max-width: 420px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-top: 2px; }
.col-age, .col-by { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions > * { vertical-align: middle; }
.assignee-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; background: transparent; padding: 3px 6px; border-radius: var(--radius-sm); cursor: pointer; max-width: 230px; }
.assignee-btn:hover { border-color: var(--border-strong); }
.assignee-btn.static { cursor: default; }
.assignee-btn .names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.mini-progress { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mini-progress .progress { width: 46px; }
.detail-row > td { padding: 0 !important; background: var(--surface-2); }
.detail-row .task-detail { border-left: 3px solid var(--accent); }
.table-foot { margin-top: 8px; font-size: 12.5px; }

/* ===== Task detail ===== */
.task-detail { background: var(--surface); }
.td-head { display: flex; align-items: flex-start; gap: 8px; padding: 16px 18px 10px; border-bottom: 1px solid var(--border); }
.td-head .task-id { padding-top: 7px; }
.title-input, .title-text { flex: 1; font-size: 18px; font-weight: 700; border: 1px solid transparent !important; background: transparent !important; padding: 3px 6px !important; resize: none; overflow: hidden; line-height: 1.35; }
.title-input:hover { border-color: var(--border-strong) !important; }
.title-input:focus { background: var(--surface) !important; border-color: var(--accent) !important; }
.td-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.td-main { padding: 16px 18px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.td-side { padding: 16px 18px; border-left: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.meta-grid { display: grid; grid-template-columns: 100px 1fr; gap: 9px 12px; align-items: center; }
.meta-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.meta-grid > select { justify-self: start; min-width: 140px; }
.age-text { color: var(--text-2); }
.assignee-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.person-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-3); padding: 2px 9px 2px 3px; border-radius: 999px; font-size: 13px; }
.td-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; }
.td-section .progress { margin-bottom: 8px; }
.desc-text { white-space: pre-wrap; word-break: break-word; }
.desc-input { min-height: 72px; }
.td-section .row-end { margin-top: 8px; }
.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; }
.checklist li:hover { background: var(--surface-2); }
.checklist label { display: flex; align-items: center; gap: 9px; flex: 1; cursor: pointer; min-width: 0; }
.ci-text { word-break: break-word; }
.checklist li.done .ci-text { color: var(--muted); text-decoration: line-through; }
.ci-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.hover-show { opacity: 0; }
li:hover .hover-show, .hover-show:focus-visible { opacity: 1; }
.files { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 4px; }
.files li { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; background: var(--surface-2); min-width: 0; }
.files li > a:not(.icon-btn) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-meta { font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 12px; color: var(--muted); font-size: 13px; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.comments { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 12px; }
.comments li { display: flex; gap: 9px; }
.c-body { flex: 1; min-width: 0; }
.c-head { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.c-head .muted { font-size: 12px; }
.c-text { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment-box { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.history summary { cursor: pointer; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.history ul { list-style: none; padding: 0; margin: 8px 0 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.h-detail { color: var(--text-2); }
.td-danger { border-top: 1px solid var(--border); padding-top: 12px; }

/* ===== Drawer ===== */
.drawer { position: fixed; inset: 0; background: rgba(0, 0, 0, 0); z-index: 40; display: flex; justify-content: flex-end; transition: background .18s; }
.drawer.open { background: rgba(0, 0, 0, 0.25); }
.drawer-panel { width: min(920px, 100%); height: 100%; background: var(--surface); box-shadow: var(--shadow-lg); overflow-y: auto; transform: translateX(30px); opacity: 0; transition: transform .18s, opacity .18s; }
.drawer.open .drawer-panel { transform: none; opacity: 1; }
.drawer-panel .td-body { min-height: calc(100% - 64px); }

/* ===== Modal, popover, toast, tooltip ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); }
.popover { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px; min-width: 220px; max-height: 70vh; overflow-y: auto; }
.popover-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.people-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.popover .people-pick { grid-template-columns: 1fr; }
.person-opt { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); }
.person-opt:hover { background: var(--surface-2); }
.person-opt:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #222; color: #fff; padding: 9px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; transition: opacity .3s, transform .3s; max-width: 90vw; }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
#tooltip { position: fixed; z-index: 95; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 7px 10px; border-radius: 8px; font-size: 12.5px; opacity: 0; transition: opacity .08s; }
#tooltip.show { opacity: 1; }
#tooltip .swatch { margin-right: 6px; }

/* ===== Summary ===== */
.summary { display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.tile-label { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tile.pri-urgent { box-shadow: inset 3px 0 0 var(--pri-urgent); }
.tile.st-blocked { box-shadow: inset 3px 0 0 var(--st-blocked); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h3 { font-size: 14px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-left: auto; }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 10px; padding: 2px 4px; border-radius: 6px; }
.bar-row.clickable { cursor: pointer; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 16px; display: flex; align-items: center; }
.bar-fill { height: 16px; border-radius: 0 4px 4px 0; min-width: 4px; }
.bar-stack { display: flex; gap: 2px; height: 16px; min-width: 4px; }
.bar-stack .seg { height: 100%; min-width: 3px; }
.bar-stack .seg:last-child { border-radius: 0 4px 4px 0; }
.bar-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.fill-urgent { background: var(--pri-urgent); }
.fill-high { background: var(--pri-high); }
.fill-medium { background: var(--pri-medium); }
.fill-low { background: var(--pri-low); }
.fill-neutral { background: var(--accent); }
.oldest, .recent { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.oldest li, .recent li { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.oldest li:hover, .recent li:hover { background: var(--surface-2); }
.recent li { align-items: flex-start; font-size: 13px; }
.recent li > .muted { white-space: nowrap; font-size: 12px; min-width: 104px; }
.recent li > div { min-width: 0; }
.age-badge { font-size: 12px; font-weight: 700; background: var(--surface-3); border-radius: 6px; padding: 3px 8px; white-space: nowrap; min-width: 64px; text-align: center; }
.oldest-main { flex: 1; min-width: 0; }
.oldest-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oldest-main .muted { font-size: 12px; }

/* ===== Admin ===== */
.admin .panel { max-width: 1100px; }
.perm-table { width: 100%; border-collapse: collapse; }
.perm-table th { font-size: 12px; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.perm-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.perm-table .tick { text-align: center; }
.perm-table td.tick input { width: 18px; height: 18px; }
.perm-table tr.inactive td { opacity: .55; }
.perm-table .row-actions { text-align: right; white-space: nowrap; }
.perm-table .row-actions > span { display: inline-flex; align-items: center; gap: 6px; }
.perm-table .input-sm { max-width: 180px; }
.help { margin-top: 16px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border-radius: 9px; padding: 12px 14px; }
.help ul { margin: 0; padding-left: 18px; }

/* ===== Long text never breaks the layout ===== */
.card-title { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.row-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.col-title { max-width: 520px; }
.title-input, .title-text { overflow-wrap: anywhere; }
.title-input { max-height: 40vh; overflow-y: auto !important; }
.desc-text, .c-text, .ci-text, .h-detail, .oldest-title, .recent li > div { overflow-wrap: anywhere; }
.project-tag { overflow-wrap: normal; }

/* ===== Unsaved / misc states ===== */
.unsaved-bar { align-items: center; }
.unsaved-note { margin-right: auto; font-size: 12.5px; }
.unsaved-copy { margin-top: 12px; text-align: left; }
.unsaved-copy textarea { margin-top: 6px; }
.empty .btn { margin-top: 12px; }
.person-opt.inactive { opacity: .75; }
.filter-toggle { display: none; }
@media (hover: none) { .hover-show { opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .td-body { grid-template-columns: 1fr; }
  .td-side { border-left: none; border-top: 1px solid var(--border); }
  .board { grid-template-columns: repeat(4, minmax(250px, 1fr)) !important; overflow-x: auto; }
  .board.board-done { grid-template-columns: 1fr !important; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 45; }
  .menu-btn { display: inline-flex; }
  .toolbar, .content { padding-left: 16px; padding-right: 16px; }
  .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .search { flex: 1 1 100%; }
  .meta-grid { grid-template-columns: 90px 1fr; }
}
@media (max-width: 860px) {
  .filter-toggle { display: inline-flex; }
  .toolbar-filters { display: none; }
  body.filters-open .toolbar-filters { display: flex; }
  .title-block p { display: none; }
  .toolbar { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
}
@media (max-width: 700px) {
  /* List: each task becomes a compact two-line block instead of a wide table row. */
  .task-table thead { display: none; }
  .task-table, .task-table tbody { display: block; }
  .table-wrap { overflow-x: visible; }
  .task-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 8px; border-bottom: 1px solid var(--border); }
  .task-row > td { display: block; border: none !important; padding: 0 !important; }
  .task-row .col-caret { order: 0; width: auto; }
  .task-row .col-title { order: 1; flex: 1 1 calc(100% - 44px); min-width: 0; max-width: none; }
  .task-row .col-priority { order: 2; margin-left: 32px; }
  .task-row .col-status { order: 3; }
  .task-row .col-assignees { order: 4; }
  .task-row .col-age { order: 5; font-size: 12px; }
  .task-row .col-actions { order: 6; margin-left: auto; }
  .task-row .col-project, .task-row .col-by, .task-row .col-progress { display: none; }
  .assignee-btn .names { display: none; }
  .detail-row, .detail-row > td { display: block; }
  .row-sub { max-width: 100%; }
}
