/* Task Tracker — "practice ledger" theme.
   Deep ledger-green sidebar, paper-toned work surface, serif headings,
   tabular monospace deadline column. System fonts only (offline-safe). */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #143528;          /* ledger green-ink (sidebar) */
  --ink-2: #1C4636;        /* hover / raised ink */
  --ink-text: #E9F1EA;
  --ink-muted: #8FAD9C;

  --paper: #F1F2EE;        /* work surface */
  --card: #FFFFFF;
  --line: #E0E3DC;
  --text: #22302A;
  --muted: #6C7A72;

  --accent: #1E6B47;       /* actions */
  --accent-2: #175538;

  --red: #B33636;  --red-bg: #F9ECEC;
  --amber: #96660A; --amber-bg: #FAF2E0;
  --green: #1E6B47; --green-bg: #E9F3EC;

  --serif: Cambria, Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;

  --shadow: 0 1px 2px rgba(24, 40, 32, .06), 0 2px 8px rgba(24, 40, 32, .04);
}

/* App layout: the sidebar stays put and only the main area scrolls (phones scroll the
   whole page instead; see the responsive section). */
html, body { height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--text);
  background: var(--paper);
  display: flex;
  overflow: hidden;
}

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.side :focus-visible { outline-color: var(--ink-text); }
.hidden { display: none !important; }

/* ================= sidebar ================= */
.side {
  width: 232px;
  flex-shrink: 0;
  background: var(--ink);
  color: var(--ink-text);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  height: 100%;
  overflow-y: auto; /* short screens: the sidebar scrolls on its own */
}

.wordmark { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.wordmark .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--ink-text); color: var(--ink);
  font-family: var(--serif); font-size: 20px; font-weight: 700;
  display: grid; place-items: center;
}
.wordmark .name { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.wordmark .sub { font-size: 12px; color: var(--ink-muted); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; color: var(--ink-muted);
  text-align: left; padding: 9px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: .01em;
}
.nav-item:hover { color: var(--ink-text); background: var(--ink-2); }
.nav-item.active { color: var(--ink-text); background: var(--ink-2); box-shadow: inset 2px 0 0 0 #6FBF95; }
.nav-count {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; padding: 1px 7px;
}

.side-stats {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid rgba(233, 241, 234, .12);
  padding: 16px 4px 0;
  font-size: 13px;
}
.sstat { display: flex; align-items: center; gap: 8px; color: var(--ink-muted); }
.sstat .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sstat .n { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--ink-text); }
.dot.red { background: #E06B6B; }
.dot.amber { background: #DFAE55; }
.dot.blue { background: #7FA8D9; }
.dot.plain { background: var(--ink-muted); }

.side-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.backup-link {
  background: none; border: none; color: var(--ink-muted);
  font-size: 12.5px; text-align: left; padding: 4px;
}
.backup-link:hover { color: var(--ink-text); text-decoration: underline; }

/* ================= buttons ================= */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
}
.btn:hover { border-color: #c9cec6; background: #fafbf9; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.outline { background: transparent; border-color: rgba(233, 241, 234, .35); color: var(--ink-text); }
.btn.outline:hover { border-color: rgba(233, 241, 234, .7); background: var(--ink-2); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--paper); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }

/* ================= content ================= */
.content { flex: 1; min-width: 0; height: 100%; overflow-y: auto; display: flex; flex-direction: column; }

/* title + filters stay at the top while a long list scrolls underneath. Full width so the
   background covers what scrolls under it; the padding lines its contents up with main. */
.content-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--paper);
  box-shadow: 0 8px 8px -8px rgba(24, 40, 32, .14); /* soft edge over the list scrolling underneath */
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 22px max(32px, calc((100% - 1060px) / 2 + 32px)) 12px;
  width: 100%;
  flex-shrink: 0;
}
.content-head h1 {
  font-family: var(--serif); font-size: 26px; font-weight: 700;
  letter-spacing: .005em; margin-right: auto;
}

.filterbar { display: flex; gap: 8px; flex-wrap: wrap; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 107, 71, .15);
}
#f-search { width: 230px; }
#f-client, #f-staff { max-width: 220px; } /* long client names would stretch the bar */

main {
  padding: 0 32px 70px;
  max-width: 1060px; width: 100%; margin: 0 auto;
}

/* ================= sections ================= */
.section-title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
}
.section-title::after { content: ""; flex: 1; border-top: 1px solid var(--line); align-self: center; }
.section-title .count { font-family: var(--mono); font-size: 12px; font-weight: 400; }
.sec-overdue { color: var(--red); }
.sec-week { color: var(--amber); }
.sec-later { color: var(--muted); }
.sec-done { color: var(--green); }

/* ================= task rows ================= */
.task {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 118px 108px auto;
  align-items: center; gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 16px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
.task:hover { border-color: #c6ccc3; }
.task.openable { cursor: pointer; }
.task.openable:hover { background: #FCFDFB; }
.task.overdue { box-shadow: inset 3px 0 0 0 var(--red), var(--shadow); }
.task.due-soon { box-shadow: inset 3px 0 0 0 #DFAE55, var(--shadow); }
.task.done-row { opacity: .72; }

.task .who { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task .what { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); background: var(--green-bg);
  border-radius: 5px; padding: 2px 8px; white-space: nowrap;
}
.tag.recur { color: var(--muted); background: var(--paper); font-weight: 600; letter-spacing: .03em; text-transform: none; }
.task .title { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task .date { font-family: var(--mono); font-size: 13px; text-align: right; white-space: nowrap; }

.task .left {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  text-align: right; white-space: nowrap;
}
.left.red { color: var(--red); }
.left.amber { color: var(--amber); }
.left.blue { color: var(--muted); }
.left.green { color: var(--green); }

.task .actions { display: flex; gap: 4px; justify-content: flex-end; }
.btn-done {
  border: 1px solid var(--green); color: var(--green); background: var(--card);
  border-radius: 7px; padding: 4px 11px; font-weight: 700; font-size: 12.5px;
}
.btn-done:hover { background: var(--green); color: #fff; }
.icon-btn {
  border: none; background: none; font-size: 14px;
  color: #9aa69e; padding: 4px 5px; border-radius: 6px;
}
.icon-btn:hover { background: var(--paper); color: var(--text); }
.row-del { opacity: 0; transition: opacity .15s; }
.task:hover .row-del, .task:focus-within .row-del { opacity: 1; }
.row-del:hover { color: var(--red); background: var(--red-bg); }

/* ================= clients ================= */
.client-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.client-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.client-head .name { font-family: var(--serif); font-weight: 700; font-size: 17px; flex: 1; min-width: 140px; }
.client-head .summary { color: var(--muted); font-size: 12.5px; }
.client-notes { color: var(--muted); font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.client-tasks { margin-top: 12px; }
.client-tasks .task { box-shadow: none; background: #FBFCFA; }
.client-tasks .task.overdue { box-shadow: inset 3px 0 0 0 var(--red); }
.client-tasks .task.due-soon { box-shadow: inset 3px 0 0 0 #DFAE55; }

.trash-note { color: var(--muted); font-size: 12.5px; margin-top: 16px; }

.empty { text-align: center; color: var(--muted); padding: 90px 20px; font-size: 14.5px; }
.empty .big { font-family: var(--serif); font-size: 30px; color: #B9C2BA; }

/* ================= board (kanban) ================= */
.tag.stage { text-transform: none; letter-spacing: .02em; font-weight: 600; }
.tag.stage-doing { color: #2F5E93; background: #E8EFF8; }
.tag.stage-waiting { color: var(--amber); background: var(--amber-bg); }

body.board-mode main { max-width: none; }
body.board-mode .content-head { padding-left: 32px; padding-right: 32px; }
body.board-mode main { padding-bottom: 24px; }

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 14px;
  margin-top: 18px;
  align-items: start;
  overflow-x: auto;
  padding-bottom: 6px;
}

.kcol {
  --col: var(--muted);
  background: #E7E9E3;
  border: 1px solid transparent;
  border-radius: 12px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 130px);
  transition: border-color .15s, background .15s;
}
.kcol-doing { --col: #4A7DB8; }
.kcol-waiting { --col: #C9922B; }
.kcol-done { --col: var(--green); }
.kcol.drop-target { border-color: var(--col); background: #E1E5DE; }

.kcol-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 8px 14px;
  min-height: 46px;
}
.kcol-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--col); flex-shrink: 0; }
.kcol-name { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #45524b; }
.kcol-count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.kcol-add {
  border: none; background: none; color: var(--muted);
  width: 26px; height: 26px; border-radius: 6px; font-size: 15px; line-height: 1;
}
.kcol-add:hover { background: var(--card); color: var(--text); }
.kcol-head > .kcol-add, .kcol-tools { margin-left: auto; }
.kcol-tools { display: flex; flex-shrink: 0; }
.kcol-person .kcol-tools .kcol-add[data-sact] { font-size: 13px; opacity: 0; }
.kcol-person:hover .kcol-tools .kcol-add[data-sact],
.kcol-person .kcol-tools .kcol-add[data-sact]:focus-visible { opacity: 1; }
.kcol-name.person {
  text-transform: none; letter-spacing: .01em; font-size: 14.5px; color: var(--text);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kcol-overdue {
  font-size: 11px; font-weight: 700; color: var(--red); background: var(--red-bg);
  border-radius: 99px; padding: 1px 7px; white-space: nowrap;
}

.team-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.team-bar .muted { color: var(--muted); font-size: 13px; }
.team-bar + .board { margin-top: 12px; }

/* Team view: compact 3-column grid that wraps instead of scrolling sideways */
.board.team-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-columns: auto;
  overflow-x: visible;
}
.team-grid .kcol { max-height: 440px; position: relative; }
.team-grid .kcol-head { cursor: grab; }
.team-grid .kcol-head:active { cursor: grabbing; }
.kcol-grip {
  color: var(--muted); font-size: 11px; letter-spacing: -2px; margin-left: -6px;
  opacity: .45; user-select: none;
}
.team-grid .kcol-head:hover .kcol-grip { opacity: 1; }
.kcol.col-dragging { opacity: .4; }
.kcol.col-drop-before::before, .kcol.col-drop-after::after {
  content: ''; position: absolute; top: 4px; bottom: 4px; width: 3px;
  border-radius: 3px; background: var(--green);
}
.kcol.col-drop-before::before { left: -9px; }
.kcol.col-drop-after::after { right: -9px; }
@media (max-width: 1100px) { .board.team-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 22px; height: 22px; border-radius: 50%;
  color: #fff; font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.kcol-head .avatar { width: 26px; height: 26px; font-size: 11px; }
.assignee { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.assignee .avatar { width: 18px; height: 18px; font-size: 9px; }

.kcol-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 2px 10px 12px;
  overflow-y: auto; min-height: 60px;
}
.kcol-empty {
  border: 1.5px dashed #CCD2C9; border-radius: 9px;
  color: #98A39C; font-size: 12.5px; text-align: center;
  padding: 18px 10px; min-height: 56px;
}
.kcol-foot { font-size: 12px; color: var(--muted); padding: 0 14px 12px; }

.kcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px 9px;
  box-shadow: var(--shadow);
  cursor: grab;
  display: flex; flex-direction: column; gap: 7px;
  transition: border-color .15s, box-shadow .15s, opacity .15s;
}
.kcard:hover { border-color: #c6ccc3; box-shadow: 0 2px 10px rgba(24, 40, 32, .09); }
.kcard:active { cursor: grabbing; }
.kcard.overdue { box-shadow: inset 3px 0 0 0 var(--red), var(--shadow); }
.kcard.due-soon { box-shadow: inset 3px 0 0 0 #DFAE55, var(--shadow); }
.kcard.done { opacity: .7; }
.kcard.done .kc-client { text-decoration: line-through; text-decoration-color: #b5bdb7; }
.kcard.dragging { opacity: .35; }

.kc-top { display: flex; align-items: center; gap: 6px; }
.kc-client { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-actions { display: flex; gap: 0; opacity: 0; transition: opacity .15s; }
.kcard:hover .kc-actions, .kcard:focus-within .kc-actions { opacity: 1; }
.kc-actions .icon-btn { padding: 2px 6px; font-size: 13px; }
.kc-check:hover { color: #fff; background: var(--green); }
.kc-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.kc-title { font-size: 13px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.kc-progress {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: #45524b; background: var(--paper);
  border-radius: 6px; padding: 5px 8px;
}
.kc-progress .avatar { width: 18px; height: 18px; font-size: 9px; }
.kc-progress b, .task .last-update b { font-weight: 700; color: var(--text); }
.kc-progress-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kc-progress-when { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.task .last-update {
  font-size: 12.5px; color: #45524b; max-width: 440px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kc-foot {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid #EEF0EB; padding-top: 7px;
  font-family: var(--mono); font-size: 12px;
}
.kc-date { color: var(--text); }
.kc-foot .left { font-weight: 600; margin-left: auto; }
.kc-note { color: #9aa69e; font-family: var(--sans); }

@media (hover: none) { .p-del, .kc-actions, .row-del, .kcol-person .kcol-tools .kcol-add[data-sact] { opacity: 1; } }

/* ================= modal ================= */
dialog {
  margin: auto; /* the * reset kills the UA centering — restore it */
  border: none; border-radius: 14px; padding: 0; width: min(500px, 92vw);
  max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(18, 32, 25, .35);
}
dialog::backdrop { background: rgba(18, 32, 25, .45); animation: fade .15s ease-out; }
dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 13px; }
.modal-form h2 { font-family: var(--serif); font-size: 20px; margin-bottom: 2px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-x {
  border: none; background: none; color: var(--muted);
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  font-size: 16px; line-height: 1; margin: -6px -8px -6px 0; /* no extra header height */
}
.modal-x:hover { background: var(--paper); color: var(--text); }
/* task + progress side by side: one ✕, on the right-hand panel */
.dlg-pair:has(.progress-panel:not(.hidden)) .modal-form .modal-x { display: none; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #45524b; }
.modal-form .muted { font-weight: 400; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row label { min-width: 0; }
/* task modal = two panels side by side: the form, and the progress log */
dialog.dlg-pair {
  width: fit-content; max-width: 96vw;
  background: transparent; box-shadow: none; border-radius: 0;
  overflow: visible;
}
.dlg-pair {
  display: none; gap: 16px; align-items: stretch;
}
.dlg-pair[open] { display: flex; }
.dlg-pair .panel {
  background: var(--card); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(18, 32, 25, .35);
  max-height: 92vh; overflow-y: auto;
}
.dlg-pair { --panel-w: min(440px, calc((96vw - 16px) / 2)); }
.dlg-pair .modal-form { width: var(--panel-w); flex-shrink: 0; }

.progress-panel {
  width: var(--panel-w); flex-shrink: 0;
  contain: size; /* take the form's height, scroll the log inside */
  padding: 24px 20px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.progress-top h2 { font-family: var(--serif); font-size: 20px; }
.p-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.progress-add { display: flex; flex-direction: column; gap: 6px; }
.progress-add textarea { resize: vertical; min-height: 58px; }
.progress-add-row { display: flex; gap: 6px; justify-content: flex-end; }
.progress-add-row input { flex: 1; min-width: 0; }
.progress-add-row select { flex: 1; min-width: 0; }
.progress-list {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-height: 0; overflow-y: auto;
  border-top: 1px solid var(--line); padding-top: 12px;
}
.progress-list li { background: var(--paper); border-radius: 8px; padding: 7px 10px; }
.progress-list .p-empty { color: var(--muted); font-size: 13px; background: none; padding: 2px 0; }
.p-meta { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.p-meta .avatar { width: 18px; height: 18px; font-size: 9px; }
.p-who { font-weight: 600; color: #45524b; }
.p-del { margin-left: auto; font-size: 11px; padding: 1px 4px; opacity: 0; }
.progress-list li:hover .p-del, .p-del:focus-visible { opacity: 1; }
.p-text { font-size: 13.5px; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ================= toast ================= */
#toast {
  position: fixed; bottom: 22px; right: 22px; transform: translateY(16px);
  background: var(--ink); color: var(--ink-text);
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(18, 32, 25, .35);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 100;
  max-width: min(420px, 90vw);
  display: flex; align-items: center; gap: 16px;
}
#toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#toast button {
  border: none; background: none; padding: 0; color: #8FD3AE;
  font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
#toast button:hover { text-decoration: underline; }

/* ================= responsive ================= */
@media (max-width: 860px) {
  body { flex-direction: column; overflow: visible; height: auto; }
  .content { height: auto; overflow: visible; }
  .content-head { position: static; padding: 16px 16px 8px; box-shadow: none; }
  .client-head .name { flex: 1 1 100%; } /* name on its own line, buttons together below */
  #f-search { width: 100%; }
  .filterbar { width: 100%; }
  .side {
    width: 100%; height: auto; overflow: visible;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px;
    padding: 12px 16px;
  }
  .side-stats, .wordmark .sub { display: none; }
  .nav { flex-direction: row; flex: 1 1 100%; order: 3; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-item { white-space: nowrap; flex-shrink: 0; }
  .side-actions { margin: 0 0 0 auto; flex-direction: row; }
  .btn.wide { width: auto; }
  .backup-link { display: none; }
  .content-head, main { padding-left: 16px; padding-right: 16px; }
  .task { grid-template-columns: 1fr auto; }
  .task .who { grid-column: 1 / -1; }
  .task .what { grid-column: 1 / -1; }
  .task .date, .task .left { text-align: left; }
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; max-height: none; }
  .board.team-grid { grid-template-columns: 1fr; scroll-snap-type: none; }
  .team-grid .kcol { max-height: 440px; }
  /* stack the progress panel under the form on narrow screens */
  dialog.dlg-pair { max-height: 94vh; overflow-y: auto; }
  .dlg-pair[open] { flex-direction: column; }
  .dlg-pair .panel { max-height: none; overflow: visible; }
  .dlg-pair { --panel-w: min(460px, 92vw); }
  .progress-panel { contain: none; }
  .progress-list { max-height: 50vh; }
}

@media (max-width: 480px) {
  .wordmark .name { display: none; }
  .side-actions .btn { padding: 7px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ================= sign-in ================= */
body.signed-out .side, body.signed-out .content { display: none; }
.auth {
  position: fixed; inset: 0; z-index: 50;
  background: var(--ink);
  display: grid; place-items: center; padding: 16px;
  overflow-y: auto;
}
.auth-card {
  background: var(--card); border-radius: 16px;
  width: min(400px, 100%); padding: 28px;
  display: flex; flex-direction: column; gap: 13px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.auth-card .wordmark { padding: 0; margin-bottom: 6px; }
.auth-card .wordmark .mark { background: var(--ink); color: var(--ink-text); }
.auth-card .wordmark .sub { color: var(--muted); }
.auth-card h1 { font-family: var(--serif); font-size: 24px; }
.auth-intro { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.auth-intro:empty { display: none; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: #45524b; }
.auth-error { color: var(--red); font-size: 13px; min-height: 1em; }
.auth-error:empty { display: none; }
.auth-card .btn.wide { padding: 10px; margin-top: 4px; }

/* ================= signed-in user (sidebar) ================= */
body:not(.is-admin) .admin-only { display: none !important; }
.me-block {
  display: flex; align-items: center; gap: 10px;
  border-top: 1px solid rgba(233, 241, 234, .12);
  padding: 14px 4px 0;
}
.me-block .avatar { width: 32px; height: 32px; font-size: 12px; box-shadow: 0 0 0 2px rgba(233, 241, 234, .25); }
.me-text { min-width: 0; }
.me-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted); margin-left: 4px;
}
.me-links { font-size: 12px; color: var(--ink-muted); }
.link-btn {
  border: none; background: none; padding: 0; color: inherit;
  font-size: inherit; text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: rgba(127, 140, 132, .5);
}
.side .link-btn:hover { color: var(--ink-text); }
.side-actions { margin-top: auto; }

.form-hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.form-hint:empty { display: none; }
.kcol-nologin {
  font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--card);
  border: 1px dashed #c4cbc1; border-radius: 99px; padding: 0 7px; white-space: nowrap;
}

/* ================= task modal: Progress | History tabs ================= */
.panel-tabs { display: flex; gap: 4px; }
.panel-tab {
  border: none; background: none; padding: 2px 0; margin-right: 14px;
  font-family: var(--serif); font-size: 20px; font-weight: 700; color: #A9B3AC;
  border-bottom: 2px solid transparent;
}
.panel-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel-tab:hover { color: var(--text); }
.ptab-body { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.ptab-body.hidden { display: none; }
.history-list {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.history-list li { border-left: 3px solid #C9D0C6; padding: 3px 0 3px 10px; }
.history-list .p-empty { border: none; padding: 2px 0; color: var(--muted); font-size: 13px; }
.history-list .avatar { width: 18px; height: 18px; font-size: 9px; }
.history-list .act-name { font-weight: 600; color: #45524b; }
.kind-add { border-left-color: var(--green) !important; }
.kind-remove { border-left-color: var(--red) !important; }
.kind-move { border-left-color: #4A7DB8 !important; }
.kind-done { border-left-color: #6FBF95 !important; }
.kind-login { border-left-color: #C9D0C6 !important; }

/* ================= activity log ================= */
.act-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.act-filters input { width: 240px; }
.act-row {
  display: grid; grid-template-columns: 52px 180px minmax(0, 1fr); gap: 12px; align-items: baseline;
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid #C9D0C6;
  border-radius: 8px; padding: 9px 14px; margin-bottom: 5px; font-size: 13.5px;
}
.act-time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.act-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.act-who .avatar { width: 20px; height: 20px; font-size: 9px; align-self: center; }
.act-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-name.muted { color: var(--muted); font-weight: 400; }
.act-what { display: flex; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.act-target { font-weight: 600; display: inline-flex; gap: 6px; align-items: baseline; }
.act-target .link-btn { font-weight: 600; color: var(--accent); text-align: left; }
.act-type {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); background: var(--paper); border-radius: 4px; padding: 1px 5px;
}
.act-summary { color: #45524b; overflow-wrap: anywhere; }
.act-more { text-align: center; margin: 14px 0; }

@media (max-width: 860px) {
  .me-block { border: none; padding: 0; }
  .act-row { grid-template-columns: 46px minmax(0, 1fr); }
  .act-what { grid-column: 1 / -1; }
}

@media (max-height: 760px) and (min-width: 861px) {
  .side { gap: 16px; }
}

/* ================= clients: details, links, people involved ================= */
.kind {
  font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border-radius: 4px; padding: 1px 6px; vertical-align: middle; margin-left: 4px;
}
.kind-company { color: #2F5E93; background: #E8EFF8; }
.kind-individual { color: #7A4E9A; background: #F1EAF6; }
.client-meta { font-size: 12.5px; color: #45524b; margin-top: 4px; overflow-wrap: anywhere; }
.client-meta a { color: var(--accent); }
.client-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.link-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 1px solid var(--line); background: var(--paper); border-radius: 99px;
  padding: 3px 10px; font-size: 12.5px; max-width: 100%;
}
.link-chip:hover { border-color: #c4cbc1; background: #fff; }
.link-chip .lc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-chip .lc-role { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.link-chip.kind-company { border-left: 3px solid #4A7DB8; }
.link-chip.kind-individual { border-left: 3px solid #9A73B8; }
details.client-notes { margin-top: 8px; }
details.client-notes summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.involved-title {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 4px 0 6px;
}
.client-card.flash { box-shadow: 0 0 0 3px rgba(30, 107, 71, .35), var(--shadow); transition: box-shadow .3s; }
.team-bar .muted { color: var(--muted); }

.involved {
  font-size: 12px; color: #7A4E9A; background: #F5EFF9; border-radius: 5px; padding: 1px 7px; white-space: nowrap;
}
.involved i { font-style: normal; color: var(--muted); }
.kc-involved { display: flex; flex-wrap: wrap; gap: 4px; }

/* task form: People involved */
.involved-box { display: flex; flex-direction: column; gap: 6px; }
.involved-head { font-size: 12.5px; font-weight: 600; color: #45524b; }
.involved-head .muted, .involved-box .muted { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.involved-list { display: flex; flex-direction: column; gap: 4px; max-height: 140px; overflow-y: auto; }
.modal-form label.involved-opt {
  flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 13.5px; color: var(--text);
  background: var(--paper); border-radius: 7px; padding: 6px 10px; cursor: pointer;
}
.involved-opt input { width: 15px; height: 15px; accent-color: var(--accent); }
.link-list .p-text b { font-weight: 700; }
