/* =============================================================================
   IT Tracker styles. Warm neutral surfaces, dark primary buttons, green active
   state, soft columns and white cards. Plain CSS; light and dark via variables.
   Sections: tokens · base · forms · shell · menus · chips · filters · stats ·
   board · list · settings · panel · modal · palette · toasts · auth · reports
   ============================================================================= */

:root {
  --bg: #f3f2ef;          /* page */
  --surface: #ffffff;     /* cards, panels, inputs */
  --surface-2: #f0efeb;   /* hover, quiet fills */
  --column: #e8e7e2;      /* board columns */
  --border: #e4e2dc;
  --border-strong: #d2cfc7;
  --text: #1d1d1b;
  --text-2: #69675f;
  --text-3: #9b998f;
  --primary: #262624;     /* dark buttons, active pills */
  --primary-hover: #000000;
  --on-primary: #ffffff;
  --active: #8fdc8a;      /* active nav item */
  --active-text: #10300d;
  --focus: #5dbb57;
  --link: #2a64c9;
  --good: #2b8a3e; --good-soft: #e2f4dd;
  --warn: #a35f00; --warn-soft: #fdf0d5;
  --bad: #c92a2a;  --bad-soft: #fde3e1;
  --done-col: #dfeedb;    /* "Done" column tint */
  --shadow: 0 1px 2px rgba(30, 28, 20, .06), 0 1px 1px rgba(30, 28, 20, .04);
  --shadow-lg: 0 14px 40px rgba(30, 28, 20, .16);
  --radius: 12px; --radius-sm: 8px; --radius-lg: 16px;
  --font: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
  /* chip / label / avatar colours: background + text */
  --slate-bg: #ecebe7; --slate-fg: #55534c; --blue-bg: #e4edfd; --blue-fg: #2456b8; --green-bg: #e2f4dd; --green-fg: #2b7a30;
  --amber-bg: #fcefd6; --amber-fg: #96590a; --red-bg: #fde3e1; --red-fg: #b42424; --purple-bg: #efe8fc; --purple-fg: #6236b5;
  --teal-bg: #ddf3ef; --teal-fg: #0d6e62; --pink-bg: #fce6f1; --pink-fg: #b11f69;
}
[data-theme="dark"] {
  --bg: #161615; --surface: #1f1f1d; --surface-2: #292926; --column: #242422;
  --border: #31312d; --border-strong: #43433e;
  --text: #ecebe6; --text-2: #a8a69d; --text-3: #77756d;
  --primary: #ecebe6; --primary-hover: #ffffff; --on-primary: #161615;
  --active: #2f5a2b; --active-text: #d4f5cf; --focus: #6cc466; --link: #8db3ff;
  --good: #6fd17a; --good-soft: #1c3320; --warn: #f0b35a; --warn-soft: #3a2c13; --bad: #ff8a8a; --bad-soft: #3d1d1d;
  --done-col: #1f2d1e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45); --shadow-lg: 0 14px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
  --slate-bg: #2c2c29; --slate-fg: #c2c0b8; --blue-bg: #1c2a45; --blue-fg: #93b6ff; --green-bg: #1c3320; --green-fg: #7fd88a;
  --amber-bg: #3a2c13; --amber-fg: #f3bd6a; --red-bg: #3d1d1d; --red-fg: #ff9090; --purple-bg: #2b2142; --purple-fg: #c8aaff;
  --teal-bg: #133331; --teal-fg: #6ad8cb; --pink-bg: #3b1a2d; --pink-fg: #ff91c9;
}

/* ---- Base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 8px; }
[hidden] { display: none !important; }
.icon { width: 16px; height: 16px; flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font: 11px/1.4 var(--mono); color: var(--text-2); background: var(--surface); text-align: center; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* ---- Forms and buttons ---- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]):not([type=radio]), select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 11px; min-height: 36px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 550; white-space: nowrap; text-decoration: none !important; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn-primary, .btn-dark { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover, .btn-dark:hover { background: var(--primary-hover); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; background: transparent; border-radius: var(--radius-sm); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; text-align: left; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, legend { font-size: 12px; font-weight: 600; color: var(--text-2); }
fieldset { border: 0; padding: 0; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.check-row { display: flex; flex-wrap: wrap; gap: 10px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.inline-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-form.grow { flex: 1; }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-success { background: var(--good-soft); color: var(--good); }

/* ---- App shell ---- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.sidebar { padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 2px 8px 6px; }
.brand-center { justify-content: center; margin-bottom: 12px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--on-primary); }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 12px; color: var(--text-3); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 10px; color: var(--text); font-weight: 500; text-decoration: none !important; cursor: pointer; text-align: left; }
.nav-item .icon { color: var(--text-2); }
.nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.nav-item.active { background: var(--active); color: var(--active-text); font-weight: 600; }
.nav-item.active .icon { color: var(--active-text); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 0 7px; height: 20px; line-height: 20px; border-radius: 10px; font-size: 11.5px; font-weight: 600; text-align: center; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); }
.nav-badge.badge-alert { background: var(--bad-soft); color: var(--bad); }
.nav-kbd { margin-left: auto; font: 11px var(--mono); color: var(--text-3); }
.sidebar-foot { margin-top: auto; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 28px 6px; }
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search { position: relative; width: min(280px, 30vw); }
.search .icon { position: absolute; left: 12px; top: 10px; color: var(--text-3); }
.search input { padding-left: 36px !important; padding-right: 60px !important; border-radius: 999px !important; border-color: var(--border) !important; }
.kbd-hint { position: absolute; right: 8px; top: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-3); border-radius: 6px; font: 11px var(--mono); padding: 1px 6px; cursor: pointer; }
.tool-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); }
.me { position: relative; }
.me-button { display: grid; place-items: center; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.content { flex: 1; overflow: auto; padding: 14px 28px 28px; min-height: 0; display: flex; flex-direction: column; }
/* Children of the scrolling area keep their natural height (a scrolling child like .tabs would otherwise collapse to 0). */
.content > * { flex-shrink: 0; min-width: 0; }
.content > .board-area { flex: 1; flex-shrink: 1; min-height: 0; display: flex; flex-direction: column; }
.narrow { max-width: 680px; }
.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.narrow-box { max-width: 780px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty-state h2 { font-size: 40px; color: var(--text-3); margin-bottom: 8px; }
.section-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.section-head h3 { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Menus ---- */
.menu-user { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---- Chips, badges, avatars ---- */
.chip, .label, .badge { display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--slate-bg); color: var(--slate-fg); }
.label { border-radius: 6px; font-weight: 500; }
.c-slate { background: var(--slate-bg); color: var(--slate-fg); } .c-blue { background: var(--blue-bg); color: var(--blue-fg); }
.c-green { background: var(--green-bg); color: var(--green-fg); } .c-amber { background: var(--amber-bg); color: var(--amber-fg); }
.c-red { background: var(--red-bg); color: var(--red-fg); } .c-purple { background: var(--purple-bg); color: var(--purple-fg); }
.c-teal { background: var(--teal-bg); color: var(--teal-fg); } .c-pink { background: var(--pink-bg); color: var(--pink-fg); }
.status-todo { background: var(--slate-bg); color: var(--slate-fg); }
.status-in_progress { background: var(--blue-bg); color: var(--blue-fg); }
.status-blocked { background: var(--red-bg); color: var(--red-fg); }
.status-done { background: var(--green-bg); color: var(--green-fg); }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; flex: none; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-empty { border: 1.5px dashed var(--border-strong); color: var(--text-3); background: transparent; }
.avatar-empty .icon { width: 13px; height: 13px; }
.prio { display: inline-flex; align-items: center; color: var(--text-3); }
.prio span { position: absolute; left: -9999px; }
.prio-high { color: var(--warn); } .prio-urgent { color: var(--bad); } .prio-low { color: var(--text-3); }
.type-icon { display: inline-flex; color: var(--text-3); }
.type-icon .icon { width: 14px; height: 14px; }
.type-bug, .type-incident { color: var(--bad); }
.key { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.due .icon { width: 13px; height: 13px; }
.due-overdue { color: var(--bad); font-weight: 600; }
.due-today { color: var(--warn); font-weight: 600; }
.count { font-size: 12px; color: var(--text-3); font-weight: 500; }
.mention { background: var(--blue-bg); color: var(--blue-fg); border-radius: 4px; padding: 0 3px; font-weight: 500; }
.pill-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; text-decoration: none !important; }
.tag-good { background: var(--good-soft); color: var(--good); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }

/* ---- Filters ---- */
.showing { margin: 0 0 8px; font-size: 12.5px; text-align: right; }

/* ---- Stat strip (board) ---- */

/* ---- Board ---- */
.board-area { min-height: 0; }
.board { display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 14px; flex: 1; min-height: 0; overflow-x: auto; align-items: start; }
.column { background: var(--column); border-radius: var(--radius-lg); padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 100%; min-height: 160px; }
.column-done { background: var(--done-col); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 2px; }
.column-head h2 { font-size: 14px; font-weight: 650; }
.count-badge { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: color-mix(in srgb, var(--text) 9%, transparent); font-size: 11.5px; font-weight: 600; line-height: 20px; text-align: center; color: var(--text-2); }
.column-meta { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.column-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; overflow-y: auto; padding: 2px; }
.quick-add input { background: transparent !important; border: 0 !important; text-align: center; min-height: 34px; font-size: 13px; color: var(--text-2); border-radius: var(--radius-sm) !important; }
.quick-add input::placeholder { color: var(--text-2); font-weight: 500; }
.quick-add input:hover { background: color-mix(in srgb, var(--text) 5%, transparent) !important; }
.quick-add input:focus { background: var(--surface) !important; text-align: left; box-shadow: 0 0 0 2px var(--focus) !important; color: var(--text); }
.card { background: var(--surface); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 9px; border: 1px solid transparent; transition: box-shadow .12s, border-color .12s; }
.card:hover { box-shadow: 0 4px 14px rgba(30, 28, 20, .10); }
.card.selected { border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 30%, transparent); }
.card.is-done { opacity: .78; }
.card.is-done .card-title { text-decoration: line-through; text-decoration-color: var(--text-3); }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-heading { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.mini-chip, .time-chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.mini-chip .icon, .time-chip .icon, .mini-chip .type-icon .icon { width: 12px; height: 12px; }
.mini-chip.is-complete { background: var(--good-soft); color: var(--good); }
.time-chip { background: var(--surface-2); }
.time-chip.is-today { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.time-chip.is-late { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.card-callout { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; }
.card-callout .icon { width: 13px; height: 13px; }
.callout-warn { background: var(--warn-soft); color: var(--warn); }
.callout-bad { background: var(--bad-soft); color: var(--bad); }
.card-ghost { opacity: .4; }
.card-chosen { box-shadow: var(--shadow-lg); }
.is-dragging .card { cursor: grabbing; }

/* ---- Table / list ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tr.inactive { opacity: .55; }
.col-key { width: 90px; }
.col-title { min-width: 260px; }
.title-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }
.title-link:hover span { text-decoration: underline; }
.row-meta { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; padding-left: 22px; }
.row-meta:not(:has(*)) { display: none; }
.inline-select, .inline-input { width: auto !important; min-height: 30px !important; padding: 3px 8px !important; font-size: 13px; border-color: transparent !important; background-color: transparent !important; border-radius: var(--radius-sm); cursor: pointer; }
.inline-select:hover, .inline-input:hover { background-color: var(--surface-2) !important; }
.inline-select:focus, .inline-input:focus { border-color: var(--focus) !important; background-color: var(--surface) !important; }
.inline-input.is-overdue { color: var(--bad); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 2px; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.actions { text-align: right; white-space: nowrap; }
.actions .inline-form { display: inline-flex; }

/* ---- Settings ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 9px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none !important; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.name-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.name-list li { display: flex; align-items: center; gap: 10px; }
.name-list li.inactive .chip { opacity: .5; text-decoration: line-through; }
.name-list input[name=name] { max-width: 220px; }
.name-list select, .add-row select { width: 120px; }
.name-list .chip, .name-list .label { min-width: 96px; justify-content: center; }
.add-row input { max-width: 260px; }
.form-reveal:not([open]) { background: none; border: 0; padding: 0; }
.form-reveal > summary { list-style: none; width: fit-content; }
.form-reveal > summary::-webkit-details-marker { display: none; }
.form-reveal[open] > summary { display: none; }
.recurring-form .when-weekly, .recurring-form .when-monthly { display: none; }
.recurring-form:has(.js-frequency option[value="weekly"]:checked) .when-weekly { display: flex; }
.recurring-form:has(.js-frequency option[value="monthly"]:checked) .when-monthly { display: flex; }

/* ---- Drawer (side panel) ---- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); z-index: 20; transform: translateX(100%); transition: transform .18s ease; }
.drawer:not(:empty) { transform: none; box-shadow: var(--shadow-lg); }
.panel { background: var(--surface); height: 100%; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.panel-standalone { max-width: 860px; height: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 22px 32px; display: flex; flex-direction: column; gap: 20px; }
.title-input { font-size: 20px; font-weight: 650; border-color: transparent !important; padding: 4px 6px !important; margin-left: -6px; background: transparent !important; }
.title-input:hover { background: var(--surface-2) !important; }
.title-input:focus { border-color: var(--focus) !important; background: var(--surface) !important; }
.fields { display: grid; grid-template-columns: 110px 1fr; gap: 2px 12px; margin: 0; align-items: center; }
.fields dt { font-size: 13px; color: var(--text-2); }
.fields dd { margin: 0; min-height: 32px; display: flex; align-items: center; }
.reporter { gap: 6px; padding-left: 8px; }
.fields dd.muted { padding-left: 8px; }
.label-trigger { display: inline-flex; gap: 4px; flex-wrap: wrap; min-width: 120px; border: 1px solid transparent; }
.panel-section { display: flex; flex-direction: column; gap: 8px; }
.prose p { margin: 0 0 8px; overflow-wrap: anywhere; }
.prose p:last-child { margin-bottom: 0; }
.attachments { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.attachments li { display: flex; align-items: center; gap: 10px; }
.attachments a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.upload { display: flex; align-items: center; gap: 8px; }
.upload input[type=file] { font-size: 13px; color: var(--text-2); max-width: 280px; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.feed-event { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--text-2); padding-left: 8px; }
.feed-event strong { color: var(--text); font-weight: 600; }
.feed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; position: relative; top: -1px; }
.feed-comment { display: flex; gap: 10px; align-items: flex-start; }
.bubble { flex: 1; background: var(--surface-2); border-radius: var(--radius); padding: 9px 12px; min-width: 0; }
.bubble-head { font-size: 13px; margin-bottom: 4px; }
.comment-form textarea { margin-top: 4px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.progress.is-over span { background: var(--warn); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.checklist li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: var(--radius-sm); }
.checklist li:hover { background: var(--surface-2); }
.checklist li .check { flex: 1; align-items: flex-start; }
.checklist li .check input { margin-top: 3px; }
.checklist li.is-done span { text-decoration: line-through; color: var(--text-3); }
.checklist li .icon-btn { opacity: 0; width: 24px; height: 24px; }
.checklist li:hover .icon-btn, .checklist li .icon-btn:focus { opacity: 1; }
.checklist-add input { border-style: dashed !important; min-height: 32px; font-size: 13px; }
.time-form { display: grid; grid-template-columns: 90px 145px 1fr auto; gap: 6px; }
.time-form input { min-height: 32px; padding: 4px 9px; font-size: 13px; }
.time-logs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.time-logs li { display: flex; align-items: center; gap: 8px; }
.time-note { flex: 1; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-logs .icon-btn { width: 24px; height: 24px; opacity: .5; }
.time-logs li:hover .icon-btn { opacity: 1; }

/* ---- Running timer ---- */
.timer-chip { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px 0 12px; border-radius: 18px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 13px; }
.timer-chip .icon-btn { color: var(--bad); }
.timer-key { font-family: var(--mono); font-size: 12px; }
.timer-elapsed { font-variant-numeric: tabular-nums; }
.timer-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); animation: pulse 1.6s ease-in-out infinite; flex: none; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .timer-dot { animation: none; } .drawer { transition: none; } }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 18, 12, .4); z-index: 40; display: grid; place-items: start center; padding: 8vh 16px; overflow-y: auto; }
.modal { width: min(720px, 100%); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal-sm { width: min(560px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.shortcut-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortcut-table td { padding: 6px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.shortcut-table td:first-child { width: 45%; white-space: nowrap; padding-right: 12px; }
.shortcut-sub { margin-top: 6px; }

/* ---- Command palette ---- */
.palette-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 18, 12, .4); display: grid; place-items: start center; padding: 12vh 16px; }
.palette { width: min(640px, 100%); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input .icon { color: var(--text-3); }
.palette-input input { border: 0 !important; box-shadow: none !important; font-size: 15px; padding: 4px 0 !important; background: transparent !important; }
.palette-results { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 8px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-align: left; cursor: pointer; text-decoration: none !important; font: inherit; }
.palette-item.active, .palette-item:hover { background: var(--surface-2); }
.palette-item.active { box-shadow: inset 3px 0 0 var(--focus); }
.palette-item .icon { color: var(--text-3); }
.palette-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-tokens { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.palette-create { margin: 0; }
.token { font-size: 11.5px; padding: 1px 7px; border-radius: 5px; background: var(--slate-bg); color: var(--slate-fg); white-space: nowrap; }
.token-category { background: var(--blue-bg); color: var(--blue-fg); } .token-assignee { background: var(--purple-bg); color: var(--purple-fg); }
.token-due { background: var(--amber-bg); color: var(--amber-fg); } .token-priority { background: var(--red-bg); color: var(--red-fg); }
.token-estimate, .token-type, .token-label { background: var(--teal-bg); color: var(--teal-fg); }
.palette-empty { padding: 16px; text-align: center; }
.palette-foot { display: flex; gap: 16px; padding: 9px 18px; border-top: 1px solid var(--border); }

/* ---- Toasts ---- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 10px 16px; border-radius: 999px; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg); font-size: 13px; transition: opacity .4s, transform .4s; max-width: 90vw; }
.toast-error { background: var(--bad); color: #fff; }
.toast-hide { opacity: 0; transform: translateY(8px); }

/* ---- Auth ---- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.auth-title { font-size: 21px; text-align: center; }

/* ---- Reports ---- */
.viz { --series-1: #257de0; --series-2: #f47230; }
[data-theme="dark"] .viz { --series-1: #338ced; --series-2: #e76624; }
.report-range { margin: 4px 0 14px; font-size: 13px; }
.stat-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-alert .stat-value { color: var(--bad); }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.content > .card-box { margin-bottom: 16px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: -6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; }
.swatch.s1, .bar.s1 { background: var(--series-1); }
.swatch.s2, .bar.s2 { background: var(--series-2); }
.colchart { position: relative; display: grid; grid-template-columns: 36px 1fr; grid-template-rows: 180px auto; }
.colchart-grid { grid-column: 1 / -1; grid-row: 1; position: relative; }
.gridline { position: absolute; left: 36px; right: 0; border-top: 1px solid var(--border); }
.gridline:first-child { border-top-color: transparent; }
.gridline:last-child { border-top-color: var(--border-strong); }
.gridline span { position: absolute; left: -36px; top: -8px; width: 30px; text-align: right; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.colchart-plot { grid-column: 2; grid-row: 1; display: flex; align-items: flex-end; gap: 2px; position: relative; z-index: 1; }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; position: relative; outline: none; border-radius: 4px 4px 0 0; }
.col:hover, .col:focus-visible { background: var(--surface-2); }
.col .bar { width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; }
.col-pair .bar { max-width: 12px; }
.tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--on-primary); padding: 6px 9px; border-radius: 8px; font-size: 12px; white-space: nowrap; z-index: 5; pointer-events: none; box-shadow: var(--shadow-lg); }
.col:hover .tip, .col:focus .tip { display: block; }
.colchart-x { grid-column: 2; grid-row: 2; display: flex; gap: 2px; margin-top: 6px; }
.colchart-x span { flex: 1; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: visible; }
.table-view summary { font-size: 12px; color: var(--text-2); cursor: pointer; }
.table-view .table { margin-top: 8px; }
.table.compact td, .table.compact th { padding: 4px 10px; font-size: 12px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.matrix tfoot th { border-top: 1px solid var(--border-strong); background: var(--surface-2); }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hbars li { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: block; height: 14px; }
.hbar-track .bar { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bar-col { width: 160px; }

/* ---- Smaller screens ---- */
@media (max-width: 1200px) {
  .stat-row { grid-template-columns: repeat(3, 1fr); }
  .search { width: 200px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 8px 12px; overflow-x: auto; }
  .sidebar .nav { flex-direction: row; }
  .nav-section, .brand-name, .sidebar-foot { display: none; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .content { padding: 12px 14px; }
  .board { grid-template-columns: repeat(4, 270px); }
  .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .time-form { grid-template-columns: 1fr 1fr; }
}
.form-reveal[open] > h2 { margin-bottom: 10px; }

/* ======================= M3: portal, Telegram, AI ======================= */
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.inline-form.wrap { flex-wrap: wrap; }
.input-time { width: 120px !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-chip input { position: absolute; opacity: 0; pointer-events: none; }
.day-chip span { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 14px; background: color-mix(in srgb, var(--text) 7%, transparent); font-size: 12.5px; cursor: pointer; }
.day-chip input:checked + span { background: var(--primary); color: var(--on-primary); }
.day-chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.setup-steps { margin: 0; padding-left: 18px; }
.advanced summary { cursor: pointer; }
.advanced[open] { display: flex; flex-direction: column; gap: 8px; }
.link-steps { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.link-steps ol { margin: 6px 0; padding-left: 20px; }
.link-code { font: 600 26px/1.2 var(--mono); letter-spacing: .12em; margin: 4px 0 8px; }
.type-row { display: grid; grid-template-columns: 1.1fr 2fr 1fr .8fr auto; gap: 8px; align-items: center; margin: 0; }
.type-row select, .type-row input { min-height: 32px; padding: 4px 9px; font-size: 13px; }
.add-row.type-row { margin-top: 10px; }

/* AI */
.btn-ai { background: linear-gradient(135deg, #efe7ff, #e3f0ff); border-color: transparent; color: #3d2a8a; }
[data-theme="dark"] .btn-ai { background: linear-gradient(135deg, #2b2142, #1c2a45); color: #d6c8ff; }
.ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-banner, .suggestion { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--purple-bg); color: var(--purple-fg); font-size: 13px; }
.ai-banner span, .suggestion-text { flex: 1; }
.suggestion strong { color: inherit; }

/* Portal */
.portal-body { min-height: 100vh; }
.portal-head { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; padding: 22px 20px 6px; }
.portal-head .brand { text-decoration: none !important; color: var(--text); padding: 0; }
.portal-main { max-width: 760px; margin: 0 auto; padding: 10px 20px 48px; }
.portal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.portal-card h1 { font-size: 24px; }
.portal-card h2 { margin-top: 6px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.type-card { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.type-card:hover { border-color: var(--text-3); }
.type-card input { position: absolute; opacity: 0; }
.type-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.type-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.type-name { font-weight: 600; }
.type-hint { font-size: 12px; color: var(--text-2); }
.progress-steps { display: flex; list-style: none; margin: 4px 0; padding: 0; gap: 6px; }
.progress-steps li { flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-3); font-size: 13px; font-weight: 600; }
.progress-steps li.done { background: var(--good-soft); color: var(--good); }
@media (max-width: 700px) { .type-row { grid-template-columns: 1fr 1fr; } .portal-card { padding: 18px; } }


/* =========================================================================
   Pop-ups (CR-3): one look for Picker, Menu, Date picker, filter editor,
   Dialog, Confirm and Tooltip. Behaviour lives in public/js/popover.js.
   ========================================================================= */
:root { --pop-radius: 12px; --pop-row: 32px; --pop-shadow: 0 12px 32px rgba(30, 28, 20, .14), 0 2px 6px rgba(30, 28, 20, .06); }
[data-theme="dark"] { --pop-shadow: 0 12px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4); }

.pop { position: fixed; inset: auto; margin: 0; z-index: 60; min-width: 220px; max-width: min(360px, calc(100vw - 16px));
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--pop-radius);
  box-shadow: var(--pop-shadow); padding: 5px; overflow: hidden; display: flex; flex-direction: column; }
.pop:not(.is-open) { display: none; }
.pop.is-open { animation: pop-in .12s ease-out; }
.pop.is-open.is-above { animation-name: pop-in-above; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes pop-in-above { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .pop.is-open, .dialog[open], .tip.is-open { animation: none !important; } }

/* rows: menus and lists share height, padding, hover and the active (keyboard) state */
.menu-item, .pick-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: var(--pop-row); padding: 5px 9px;
  border: 0; background: none; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; text-align: left;
  font-size: 13px; text-decoration: none !important; flex: none; }
.menu-item:hover, .menu-item:focus-visible, .pick-item.active, .fe-section .pick-item:hover { background: var(--surface-2); outline: none; }
.menu-item .icon { color: var(--text-2); width: 15px; height: 15px; }
.menu-item kbd { margin-left: auto; }
.menu-item.danger, .menu-item.danger .icon { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-soft); }
.menu-item:disabled { opacity: .45; cursor: default; background: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; flex: none; }
.menu-title { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 6px 9px 4px; text-transform: uppercase; letter-spacing: .04em; }
.menu-user { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu form { margin: 0; }
.menu { overflow-y: auto; }

.pick-search { min-height: 34px !important; margin: 0 0 5px; border-radius: var(--radius-sm) !important; border-color: var(--border) !important; font-size: 13px; flex: none; }
.pick-list { overflow-y: auto; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: 320px; outline: none; }
.pick-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-hint { color: var(--text-3); font-size: 12px; margin-left: auto; }
.pick-tick { width: 15px; height: 15px; color: var(--text); visibility: hidden; margin-left: auto; }
.pick-hint + .pick-tick { margin-left: 6px; }
.pick-item[aria-selected="true"] .pick-tick { visibility: visible; }
.pick-item[aria-selected="true"] .pick-text { font-weight: 600; }
.pick-item .label { padding: 1px 8px; font-size: 12px; }
.pick-create { color: var(--text-2); }
.pick-create .icon { width: 14px; height: 14px; }
.pick-empty { color: var(--text-3); font-size: 13px; padding: 8px 9px; margin: 0; }
.pick-check { position: absolute; opacity: 0; pointer-events: none; }
.pick-item:has(.pick-check:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.status-todo { background: var(--text-3); } .dot.status-in_progress { background: var(--link); }
.dot.status-blocked { background: var(--bad); } .dot.status-review { background: #9a6ce0; } .dot.status-done { background: var(--good); }
.dot[class*="c-"] { background: var(--dot-c, currentColor); color: inherit; }
.dot.c-slate { --dot-c: var(--slate-fg); } .dot.c-blue { --dot-c: var(--blue-fg); } .dot.c-green { --dot-c: var(--green-fg); } .dot.c-amber { --dot-c: var(--amber-fg); }
.dot.c-red { --dot-c: var(--red-fg); } .dot.c-purple { --dot-c: var(--purple-fg); } .dot.c-teal { --dot-c: var(--teal-fg); } .dot.c-pink { --dot-c: var(--pink-fg); }

/* Picker trigger: replaces every native <select>; keeps the select's own classes */
.picker-native { display: none !important; }
.picker-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; width: 100%; padding: 4px 10px 4px 11px; text-align: left;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; color: var(--text); font-size: 14px; }
.picker-btn:hover { border-color: var(--text-3); }
.picker-btn[aria-expanded="true"] { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.picker-btn.is-invalid { border-color: var(--bad); }
.picker-btn .picker-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-btn .picker-placeholder { flex: 1; color: var(--text-3); white-space: nowrap; }
.picker-chevron { width: 14px; height: 14px; color: var(--text-3); margin-left: auto; transition: transform .12s; }
.picker-btn[aria-expanded="true"] .picker-chevron { transform: rotate(180deg); }
.picker-btn .label { padding: 1px 8px; font-size: 12px; }
.picker-btn.date-btn > .icon:first-child { color: var(--text-3); width: 15px; height: 15px; }
/* inline variant (panel fields, table cells): borderless until hovered */
.picker-btn.inline-select, .picker-btn.inline-input { width: auto; max-width: 100%; min-height: 30px; padding: 3px 8px; font-size: 13px;
  border-color: transparent; background: transparent; flex-wrap: wrap; }
.picker-btn.inline-select:hover, .picker-btn.inline-input:hover { background: var(--surface-2); border-color: transparent; }
.picker-btn.inline-select .picker-chevron, .picker-btn.inline-input .picker-chevron { opacity: 0; }
.picker-btn.inline-select:hover .picker-chevron, .picker-btn.inline-select[aria-expanded="true"] .picker-chevron { opacity: 1; }
.picker-btn.inline-select[class*="status-"] { font-weight: 600; }
.picker-btn.is-overdue { color: var(--bad); font-weight: 600; }
.picker-sm { min-height: 28px; }
.picker-btn.picker-sm { min-height: 28px; width: auto; padding: 2px 8px; font-size: 13px; border-color: transparent; background: var(--surface-2); }
.input-time { width: auto !important; }

/* Date picker */
.date-pop { flex-direction: row; gap: 4px; min-width: 0; max-width: calc(100vw - 16px); }
.date-shortcuts { display: flex; flex-direction: column; width: 170px; padding-right: 4px; border-right: 1px solid var(--border); }
.date-shortcuts .pick-hint { font-size: 11.5px; }
.cal { padding: 2px 4px 4px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 4px; }
.cal-title { font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 32px); gap: 2px; }
.cal-dow { font-size: 11px; color: var(--text-3); text-align: center; line-height: 24px; }
.cal-day { width: 32px; height: 30px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; font-size: 13px; color: var(--text); }
.cal-day:hover { background: var(--surface-2); }
.cal-day.is-outside { color: var(--text-3); }
.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 650; }
.cal-day.is-selected { background: var(--primary); color: var(--on-primary); }
.cal-day:disabled { opacity: .3; cursor: default; background: none; }
@media (max-width: 520px) { .date-pop { flex-direction: column; } .date-shortcuts { width: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 4px; } }

/* Dialog + Confirm (native <dialog>) and the htmx-loaded modal share this look */
.dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); }
.dialog-sm { width: min(440px, calc(100vw - 32px)); }
.dialog[open] { animation: pop-in .14s ease-out; }
.dialog::backdrop { background: rgba(20, 18, 12, .42); }
.dialog > form { display: flex; flex-direction: column; margin: 0; }
.dialog-head, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head { padding: 18px 22px 0; }
.dialog-body { padding: 12px 22px 4px; display: flex; flex-direction: column; gap: 12px; }
.dialog-body p { margin: 0; color: var(--text-2); }
.dialog-foot, .modal-foot { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-foot { padding: 16px 22px 18px; }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--bad) 85%, #000); }

/* Tooltip */
.tip { position: fixed; inset: auto; margin: 0; z-index: 80; max-width: 260px; padding: 5px 9px; border: 0; border-radius: 7px;
  background: var(--primary); color: var(--on-primary); font-size: 12px; line-height: 1.35; pointer-events: none; box-shadow: var(--shadow); }
.tip:not(.is-open) { display: none; }
.tip.is-open { animation: pop-in .1s ease-out; }

/* =========================================================================
   View toolbar (CR-5): view tabs · search + Filter + Sort · filter chips
   ========================================================================= */
.view-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.view-tab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--text); font-weight: 650; border-bottom-color: var(--primary); }
.tab-count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); }
.tab-count.is-alert { background: var(--bad-soft); color: var(--bad); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-search { position: relative; display: inline-flex; align-items: center; flex: 0 1 260px; }
.tb-search .icon { position: absolute; left: 11px; width: 14px; height: 14px; color: var(--text-3); }
.tb-search input { min-height: 32px !important; height: 32px; padding: 0 12px 0 32px !important; border-radius: 16px !important; border-color: var(--border) !important; font-size: 13px; }
.tb-btn, .picker-btn.tb-btn { display: inline-flex; align-items: center; gap: 6px; width: auto; height: 32px; min-height: 32px; padding: 0 13px;
  border-radius: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 550; cursor: pointer; }
.tb-btn:hover { background: var(--surface-2); border-color: var(--border); }
.tb-btn .icon { width: 14px; height: 14px; color: var(--text-2); }
.picker-btn.tb-btn .picker-chevron { margin-left: 2px; }

.chip-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; height: 28px; border-radius: 14px; background: color-mix(in srgb, var(--link) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--link) 28%, transparent); font-size: 12.5px; }
.chip-main { border: 0; background: none; cursor: pointer; padding: 0 4px 0 11px; height: 100%; color: var(--text); white-space: nowrap; }
.chip-field { font-weight: 650; }
.chip-x { border: 0; background: none; cursor: pointer; width: 24px; height: 100%; display: grid; place-items: center; color: var(--text-2); border-radius: 0 14px 14px 0; }
.chip-x:hover { color: var(--text); background: color-mix(in srgb, var(--link) 14%, transparent); }
.chip-x .icon { width: 12px; height: 12px; }
.link-btn { border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 12.5px; padding: 0 6px; }
.link-btn:hover { color: var(--text); text-decoration: underline; }

/* Filter editor pop-up */
.filter-pop { width: 300px; padding: 0; }
.filter-editor { display: flex; flex-direction: column; min-height: 0; flex: 1; margin: 0; }
.fe-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 13px; font-size: 13px; }
.fe-section { display: flex; flex-direction: column; padding: 0 5px; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.fe-section .pick-search { margin: 0 4px 5px; width: auto; }
.fe-inline { flex-direction: row; align-items: center; gap: 8px; padding: 2px 13px 4px; }
.fe-inline input[type=number] { width: 90px; min-height: 32px; }
.fe-foot { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--border); margin-top: 5px; }
@media (max-width: 640px) { .tb-search { flex: 1 1 100%; } }
.pick-search::-webkit-search-cancel-button, .tb-search input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; cursor: pointer; }
a.view-tab { text-decoration: none !important; }
.picker-btn.date-btn.tb-btn { font-weight: 500; }

/* =========================================================================
   Saved views (M5): tabs, Edited bar, Properties, table, grouped board,
   calendar, My day
   ========================================================================= */
.view-head { display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.view-head .view-tabs { border-bottom: 0; flex: 1; min-width: 0; align-items: center; }
.view-tab-wrap { display: inline-flex; flex: none; }
.view-tab-wrap[data-draggable] { cursor: grab; }
.view-tab .icon { width: 14px; height: 14px; color: var(--text-3); }
.view-tab.active .icon { color: var(--text); }
.tab-personal { display: inline-flex; color: var(--text-3); }
.tab-personal .icon { width: 11px; height: 11px; }
.view-add { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; margin: 0 0 3px 4px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-3); font-size: 13px; cursor: pointer; white-space: nowrap; flex: none; }
.view-add:hover { background: var(--surface-2); color: var(--text); }
.view-add .icon { width: 14px; height: 14px; }
.view-more { margin-bottom: 3px; flex: none; }
.view-toolbar .toolbar { min-height: 32px; }
.view-edited { display: flex; align-items: center; gap: 6px; }
.edited-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.edited-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }

.props-menu { width: 250px; }
.props-list { display: flex; flex-direction: column; }
.prop-item { cursor: default; }
.prop-item .switch { margin-left: auto; }
.drag-handle { color: var(--text-3); cursor: grab; font-size: 11px; letter-spacing: -2px; width: 12px; user-select: none; }
.switch { appearance: none; -webkit-appearance: none; width: 30px !important; height: 18px !important; border-radius: 9px; background: var(--border-strong);
  position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(12px); }
.switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.view-table { table-layout: fixed; }
.view-table th { position: relative; overflow: hidden; text-overflow: ellipsis; }
.view-table td { overflow: hidden; text-overflow: ellipsis; }
.view-table col[data-col="title"]:not([style]) { width: auto; min-width: 280px; }
.view-table .col-title { min-width: 240px; }
.col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; }
.col-resize:hover, .is-resizing .col-resize { background: color-mix(in srgb, var(--focus) 40%, transparent); }
body.is-resizing { cursor: col-resize; user-select: none; }
.cell-wrap { white-space: normal; }
.cell-wrap .label { margin: 1px 0; }
.group-row td { background: var(--surface-2); padding: 0 !important; }
.group-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border: 0; background: none; cursor: pointer; color: var(--text); font-size: 13px; text-align: left; }
.group-toggle > .icon { width: 14px; height: 14px; color: var(--text-3); transition: transform .12s; }
.is-collapsed .group-toggle > .icon { transform: rotate(-90deg); }
.table-group.is-collapsed tr:not(.group-row) { display: none; }
.dot-empty { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--border-strong); }

.board-grouped .column-head { gap: 8px; }
.board-grouped .column-head .avatar, .board-grouped .column-head .dot, .board-grouped .column-head .prio, .board-grouped .column-head .type-icon { flex: none; }

/* Calendar */
.calendar-area { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.calendar-main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.calendar-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.calendar-head h2 { font-size: 16px; min-width: 170px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav .icon-btn { text-decoration: none; }
.cal-board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-colhead { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 7px 10px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .04em; }
.cal-cell { min-height: 118px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 0 6px; display: flex; flex-direction: column; min-width: 0; }
.cal-cell:nth-child(7n + 7) { border-right: 0; }
.cal-week .cal-cell { min-height: 420px; }
.cal-cell.is-weekend { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-cell.is-outside .cal-num { color: var(--text-3); }
.cal-cell-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 2px 8px; height: 24px; }
.cal-num { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.cal-cell.is-today .cal-num { background: var(--primary); color: var(--on-primary); border-radius: 11px; padding: 1px 7px; }
.cal-add { width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; opacity: 0; }
.cal-add .icon { width: 13px; height: 13px; }
.cal-cell:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
.cal-add:hover { background: var(--surface-2); color: var(--text); }
.cal-items { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 24px; padding: 0 4px; }
.cal-chip { display: flex; align-items: center; gap: 5px; width: 100%; min-height: 24px; padding: 2px 7px 2px 6px; border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; text-align: left; overflow: hidden; }
.cal-chip:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.cal-chip .dot { width: 7px; height: 7px; }
.cal-key { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; flex: none; }
.cal-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip .avatar { flex: none; }
.cal-chip.is-done .cal-title { text-decoration: line-through; color: var(--text-3); }
.cal-chip.is-late { background: var(--bad-soft); }
.prio-edge-low { border-left-color: var(--border-strong); } .prio-edge-medium { border-left-color: var(--link); }
.prio-edge-high { border-left-color: var(--warn); } .prio-edge-urgent { border-left-color: var(--bad); }
/* a span runs edge to edge across days */
.cal-chip.part-start { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: -5px; width: calc(100% + 5px); }
.cal-chip.part-middle { border-radius: 0; margin: 0 -5px; width: calc(100% + 10px); border-left-width: 1px; }
.cal-chip.part-end { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -5px; width: calc(100% + 5px); border-left-width: 1px; }
.cal-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; position: sticky; top: 12px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.cal-side h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.cal-side > p { margin: 2px 0 8px; }
.cal-unscheduled { overflow-y: auto; padding: 0; min-height: 60px; }
.cal-empty { padding: 6px 2px; }
@media (max-width: 1100px) { .calendar-area { grid-template-columns: 1fr; } .cal-side { position: static; max-height: none; } }

/* My day */
.myday { display: flex; flex-direction: column; gap: 18px; max-width: 920px; }
.day-group h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.day-overdue h2 { color: var(--bad); }
.day-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.day-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.day-item:last-child { border-bottom: 0; }
.day-title { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; font-size: 14px; }
.day-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-meta { display: flex; align-items: center; gap: 8px; flex: none; }
.mono { font-family: var(--mono); }
.done-circle { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: none; cursor: pointer; display: grid; place-items: center; color: transparent; flex: none; }
.done-circle .icon { width: 13px; height: 13px; }
.done-circle:hover { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.cal-cont { color: var(--text-3); }
.cal-chip.part-middle .dot, .cal-chip.part-end .dot { visibility: hidden; }
/* inline pickers in table cells: the chevron floats over the text on hover instead of taking room */
.view-table .picker-btn.inline-select, .view-table .picker-btn.inline-input { position: relative; max-width: 100%; flex-wrap: nowrap; }
.view-table .picker-btn.inline-select .picker-chevron { position: absolute; right: 4px; background: var(--surface-2); border-radius: 4px; }
.view-table .picker-btn .picker-text, .view-table .picker-btn .picker-placeholder { overflow: hidden; text-overflow: ellipsis; }
/* any number of columns: one row that scrolls sideways */
.board-grouped { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); padding-bottom: 6px; }
.cal-week .cal-chip { align-items: flex-start; }
.cal-week .cal-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* Timeline (M5.1) */
.timeline-area { --label-w: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.tl-scroll { overflow-x: auto; }
.tl-grid { position: relative; display: grid; grid-template-columns: var(--label-w) calc(var(--col) * var(--days)); min-width: max-content; }
.tl-corner, .tl-label, .tl-group-label { position: sticky; left: 0; z-index: 3; background: var(--surface); border-right: 1px solid var(--border); }
.tl-corner { display: flex; align-items: flex-end; padding: 0 14px 8px; border-bottom: 1px solid var(--border); z-index: 4; }
.tl-scale { position: relative; height: 52px; border-bottom: 1px solid var(--border); }
.tl-months, .tl-days { position: absolute; left: 0; right: 0; height: 26px; }
.tl-months { top: 0; }
.tl-days { top: 26px; }
.tl-months span, .tl-days span { position: absolute; top: 0; height: 26px; line-height: 26px; padding-left: 6px; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; border-left: 1px solid var(--border); }
.tl-months span { font-weight: 650; color: var(--text-2); }
.tl-days span.is-today { color: var(--bad); font-weight: 650; }
/* weekends shaded; the range always starts on a Monday */
.tl-track { position: relative; height: 38px; border-bottom: 1px solid var(--border);
  background: repeating-linear-gradient(to right, transparent 0 calc(var(--col) * 5), color-mix(in srgb, var(--surface-2) 70%, transparent) calc(var(--col) * 5) calc(var(--col) * 7)); }
.tl-week .tl-track { background-image: repeating-linear-gradient(to right, transparent 0 calc(var(--col) * 5), color-mix(in srgb, var(--surface-2) 70%, transparent) calc(var(--col) * 5) calc(var(--col) * 7)),
  repeating-linear-gradient(to right, transparent 0 calc(var(--col) - 1px), var(--border) calc(var(--col) - 1px) var(--col)); }
.tl-label { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--border); min-width: 0; }
.tl-title { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; font-size: 13px; }
.tl-group-label { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13px; }
.tl-group-track { height: 34px; background: var(--surface-2); }
.tl-empty { grid-column: 1 / -1; padding: 28px; text-align: center; }
.tl-bar { position: absolute; top: 7px; height: 24px; min-width: 8px; border-radius: 7px; display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 550;
  cursor: grab; user-select: none; touch-action: none; overflow: hidden; white-space: nowrap; border: 1px solid transparent;
  background: color-mix(in srgb, var(--bar) 22%, var(--surface)); border-color: color-mix(in srgb, var(--bar) 55%, transparent); color: var(--text); --bar: var(--text-3); }
.tl-bar.status-in_progress { --bar: var(--link); } .tl-bar.status-blocked { --bar: var(--bad); } .tl-bar.status-done { --bar: var(--good); opacity: .7; }
.tl-bar.is-late { box-shadow: inset 0 0 0 1.5px var(--bad); }
.tl-bar.clip-start { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.tl-bar.clip-end { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }
.tl-bar:hover { box-shadow: var(--shadow); }
.tl-bar:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.tl-bar.is-dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 2; opacity: .9; }
.tl-bar-text { overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.tl-handle-start { left: 0; } .tl-handle-end { right: 0; }
.tl-handle:hover { background: color-mix(in srgb, var(--bar) 35%, transparent); }
.tl-quarter .tl-bar { padding: 0 3px; }
.tl-quarter .tl-bar-text { display: none; }
.tl-today { position: absolute; top: 26px; bottom: 0; width: 0; border-left: 2px solid var(--bad); z-index: 2; pointer-events: none; }
.tl-today span { position: absolute; top: -2px; left: -1px; transform: translateX(-50%); background: var(--bad); color: #fff; font-size: 10px; font-weight: 650; padding: 1px 5px; border-radius: 4px; }
body.is-tl-dragging { cursor: grabbing; user-select: none; }
.tl-bar.is-short .tl-bar-text { display: none; }
.tl-bar-after { position: absolute; top: 11px; font-size: 12px; color: var(--text-2); white-space: nowrap; pointer-events: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tl-track:has(.tl-bar.is-dragging) .tl-bar-after { display: none; }

/* Two-step sign-in (M6) */
.code-input { font: 600 20px/1.2 var(--mono) !important; letter-spacing: .18em; text-align: center; max-width: 220px; }
.auth-card .code-input { max-width: none; }
.setup-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 14px; }
.setup-steps li::marker { font-weight: 650; }
.qr-box { width: 200px; height: 200px; margin: 10px 0 6px; padding: 6px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.setup-key { font-size: 13px; letter-spacing: .06em; user-select: all; }
.code-form { margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.recovery-codes { list-style: none; padding: 0; margin: 4px 0 10px; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; }
.recovery-codes code { font-size: 15px; padding: 3px 8px; }
.recovery-box { border-color: var(--warn); }
.row-actions { display: flex; gap: 8px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.narrow-wide { max-width: 820px; }
input[type=radio] { accent-color: var(--primary); width: 15px; height: 15px; }
p.small code, .muted.small code { white-space: nowrap; }
.pair-code { font-size: 16px; letter-spacing: .12em; }
.qr-sm { width: 140px; height: 140px; }
.wrap-anywhere { overflow-wrap: anywhere; }
