/* Zindagi app shell + inbox styles. All values from design-tokens.css. */

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.app__sidebar {
  border-bottom: 1px solid var(--z-border);
  background: var(--z-surface);
  padding: var(--z-space-3) var(--z-space-4);
  padding-top: max(var(--z-space-3), env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: var(--z-space-3);
}

.app__content {
  padding: var(--z-space-4);
  padding-bottom: max(var(--z-space-6), env(safe-area-inset-bottom));
  min-width: 0;
}

@media (min-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .app__scrim { display: none; }
  /* Sidebar is mobile-only. On desktop the topbar carries the nav. */
  .app__sidebar { display: none; }
  .app__content {
    padding: var(--z-space-6);
  }
}

/* ---------- Mobile top bar + drawer ----------
   All mobile-only rules live inside this media query. Rules OUTSIDE any
   query would beat the desktop `display: none` above (same specificity,
   later source order wins) and leak the topbar onto desktop. */

@media (max-width: 767.98px) {
  .app__topbar {
    display: flex;
    align-items: center;
    gap: var(--z-space-3);
    padding: var(--z-space-2) var(--z-space-3);
    padding-top: max(var(--z-space-2), env(safe-area-inset-top));
    background: var(--z-surface);
    border-bottom: 1px solid var(--z-border);
    position: sticky; top: 0; z-index: 20;
  }

  .app__drawer-btn {
    min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--z-radius-md);
    border: 1px solid var(--z-border);
    background: var(--z-surface-2);
    color: var(--z-text-2);
    cursor: pointer;
    font-size: 18px;
  }

  .app__topbar-title {
    flex: 1;
    font-weight: 600;
    color: var(--z-text);
    font-size: var(--z-fs-strong);
  }

  .app__topbar-toggle .workspace-toggle__btn--flip {
    min-height: 40px;
    padding: 6px 12px;
    background: var(--z-primary-soft);
    color: var(--z-primary-active);
    border: 1px solid var(--z-primary-soft);
    border-radius: var(--z-radius-md);
    font-size: var(--z-fs-small);
    font-weight: 500;
    cursor: pointer;
  }

  .app__scrim {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 30;
    opacity: 0; pointer-events: none;
    transition: opacity 180ms ease-out;
  }
  .app__scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

  .app__sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 180ms ease-out;
    box-shadow: var(--z-shadow-md);
    overflow-y: auto;
  }
  .app__sidebar[data-open="true"] { transform: translateX(0); }
}

/* Desktop topbar — full-width strip carrying brand, primary nav, workspace
   toggle, and user chip. Mobile-only pieces (drawer button, mobile-title span,
   mobile workspace flip) are hidden here. Sidebar is desktop-hidden entirely. */
@media (min-width: 768px) {
  .app__scrim { display: none !important; }

  .app__topbar {
    display: flex;
    align-items: center;
    gap: var(--z-space-3);
    height: 48px;
    padding: 0 var(--z-space-6);
    background: var(--z-surface);
    border-bottom: 1px solid var(--z-border);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .app__drawer-btn,
  .app__topbar-toggle,
  .app__topbar-title--mobile { display: none; }

  .app__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--z-space-2);
    font-size: var(--z-fs-strong);
    font-weight: 600;
    color: var(--z-text);
    text-decoration: none;
    letter-spacing: -0.01em;
    padding-right: var(--z-space-3);
    border-right: 1px solid var(--z-border);
  }
  .app__brand:hover { color: var(--z-text); }

  .app__nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }
  .app__nav-item {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    font-size: var(--z-fs-small);
    font-weight: 500;
    color: var(--z-text-2);
    text-decoration: none;
    border-radius: var(--z-radius-md);
    white-space: nowrap;
  }
  .app__nav-item:hover {
    background: var(--z-surface-2);
    color: var(--z-text);
  }
  .app__nav-item[data-active="true"] {
    background: var(--z-primary-soft);
    color: var(--z-primary-active);
  }

  .app__topbar-workspace { margin-left: auto; }
}

/* Mobile: hide desktop-only elements, keep drawer + workspace flip.
   `!important` because `.workspace-toggle { display: flex }` (used for the
   segmented control in the mobile drawer) is declared later at the same
   specificity — without it the compound-class `.workspace-toggle.app__topbar-workspace`
   inherits `display: flex` and leaks into the mobile topbar. */
@media (max-width: 767.98px) {
  .app__brand,
  .app__nav,
  .app__topbar-workspace,
  .app__topbar-user { display: none !important; }
  .app__topbar-title--mobile {
    flex: 1;
    font-weight: 600;
    color: var(--z-text);
    font-size: var(--z-fs-strong);
  }
}

/* ---------- Workspace toggle (segmented control in sidebar) ---------- */

.workspace-toggle {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--z-surface-2);
  border-radius: var(--z-radius-md);
}

.workspace-toggle__btn {
  flex: 1;
  padding: 6px 10px;
  min-height: 36px;
  font-size: var(--z-fs-small);
  font-weight: 500;
  color: var(--z-text-2);
  background: transparent;
  border: 0;
  border-radius: var(--z-radius-sm);
  cursor: pointer;
}
.workspace-toggle__btn[data-active="true"] {
  background: var(--z-primary);
  color: var(--z-on-primary);
  box-shadow: var(--z-shadow-sm);
}

/* ---------- Toasts ---------- */

.z-toasts {
  position: fixed;
  right: var(--z-space-4);
  bottom: max(var(--z-space-4), env(safe-area-inset-bottom));
  display: flex; flex-direction: column-reverse; gap: var(--z-space-2);
  z-index: 60;
  pointer-events: none;
}
.z-toast {
  padding: 10px 14px;
  border-radius: var(--z-radius-md);
  box-shadow: var(--z-shadow-md);
  background: var(--z-surface);
  color: var(--z-text-body);
  font-size: var(--z-fs-small);
  pointer-events: auto;
  animation: z-toast-in 160ms ease-out;
  max-width: 320px;
}
.z-toast--error { background: var(--z-danger); color: white; }

@keyframes z-toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Overdue affordance on task row ---------- */

.task-row[data-overdue="true"] { box-shadow: inset 2px 0 0 var(--z-danger); }
.task-row[data-overdue="true"] .task-row__due { color: var(--z-danger); font-weight: 600; }

.sidebar__brand {
  font-size: var(--z-fs-h3);
  font-weight: 600;
  color: var(--z-text);
  letter-spacing: -0.01em;
}

.sidebar__workspace {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
}

.sidebar__counts {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-1);
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
}

.sidebar__count-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 6px;
  border-radius: var(--z-radius-sm);
}

.sidebar__count-row:hover {
  background: var(--z-surface-2);
}

.sidebar__count-num {
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
  color: var(--z-text-body);
}

.sidebar__actions {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-1);
  margin-top: auto;
}

.sidebar__action {
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: transparent;
  border: 1px dashed var(--z-border-strong);
  border-radius: var(--z-radius-md);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  min-height: 36px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-1);
}

.sidebar__action:hover {
  background: var(--z-surface-2);
  color: var(--z-text-body);
}

/* ---------- Content header ---------- */

.page-header {
  display: flex;
  align-items: baseline;
  gap: var(--z-space-3);
  margin-bottom: var(--z-space-4);
}

.page-header__title {
  font-size: var(--z-fs-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--z-text);
  margin: 0;
}

.page-header__count {
  font-size: var(--z-fs-body);
  color: var(--z-text-3);
  font-variant-numeric: tabular-nums;
}

.page-header__spacer { flex: 1; }

.page-header__logout button {
  padding: 6px 10px;
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  cursor: pointer;
  min-height: 36px;
}

/* ---------- Quick-add ---------- */

.quick-add {
  display: flex;
  gap: var(--z-space-2);
  align-items: center;
  padding: var(--z-space-2) var(--z-space-3);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  margin-bottom: var(--z-space-4);
}

.quick-add__input {
  flex: 1;
  font: inherit;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--z-text-body);
  min-height: 32px;
}

.quick-add__input:focus { outline: none; box-shadow: none; }

.quick-add__project {
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  padding: 6px 8px;
  min-height: 36px;
  max-width: 40%;
}

.quick-add__submit {
  font: inherit;
  font-weight: 500;
  color: var(--z-on-primary);
  background: var(--z-primary);
  border: 0;
  border-radius: var(--z-radius-md);
  padding: 8px 14px;
  cursor: pointer;
  min-height: 36px;
}

.quick-add__submit:hover { background: var(--z-primary-hover); }

@media (max-width: 767px) {
  .quick-add { flex-wrap: wrap; }
  .quick-add__project { max-width: 100%; flex: 1 1 100%; }
}

/* ---------- Task list ---------- */

.task-group__header {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  padding: var(--z-space-3) var(--z-space-2) var(--z-space-1);
  display: flex;
  gap: var(--z-space-2);
  align-items: center;
}

.task-group__count {
  font-variant-numeric: tabular-nums;
  color: var(--z-text-muted);
}

.task-row {
  display: grid;
  /* Column widths match the actual rendered element widths — fixed columns
     that don't overflow into the title. Order: status (28) · priority (16)
     · title (flex) · actions (auto). */
  grid-template-columns: 28px 16px 1fr auto;
  grid-template-areas:
    "status priority title actions"
    ".      .        meta  meta";
  align-items: center;
  gap: var(--z-space-1) var(--z-space-2);
  padding: var(--z-space-2) var(--z-space-3);
  border-bottom: 1px solid var(--z-border-soft);
  min-height: 44px;
  transition: background 60ms ease;
}

@media (min-width: 768px) {
  .task-row {
    grid-template-columns: 28px 16px 1fr auto auto auto auto 28px 28px;
    grid-template-areas: "status priority title type ctx subs due assignee actions";
    min-height: 36px;
  }
}

.task-row:hover {
  background: var(--z-row-hover);
}

.task-row[data-status="done"] .task-row__title { color: var(--z-text-muted); text-decoration: line-through; }

.task-row__status {
  grid-area: status;
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  border-radius: var(--z-radius-full);
}

.task-row__status:hover { background: var(--z-surface-2); }

.task-row__status svg { width: 16px; height: 16px; }

/* Signal-bar priority indicator — 3 vertical bars, increasing height, colored
   from left (low) to right (high) based on `data-priority`. */
.task-row__priority {
  grid-area: priority;
  justify-self: start;
  align-self: center;
  position: relative;
  width: 12px; height: 14px;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  cursor: pointer;
  padding: 1px;
  border-radius: var(--z-radius-sm);
}
.task-row__priority:hover { background: var(--z-surface-2); }

/* Three equal horizontal bars stacked (≡). Fill count = priority level:
   1 = low, 2 = medium, 3 = high. Filled bottom-up. */
.task-row__priority > span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: var(--z-border-strong);
  pointer-events: none;
}

/* Overlay <select> — invisible but sits over the bars and receives clicks so
   the OS-native picker opens without showing the browser's default chevron. */
/* Priority bars are now a real <button>, not a <label> with overlay <select>.
   The native <select> approach was retired because browsers ignore <option>
   styling — inconsistent with the rest of the app. Popover replaces it. */
button.task-row__priority {
  background: transparent;
  border: 0;
}

/* ==========================================================================
   Popover — small floating overlay anchored to a trigger element.
   Used by the inline task-row pickers so they share styling with the modal.
   ========================================================================== */

.z-popover {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;              /* click-outside catcher, not a scrim */
}
.z-popover__panel {
  position: absolute;
  min-width: 180px;
  padding: 8px;
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  box-shadow: var(--z-shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.z-popover__title {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--z-text-3);
  padding: 0 2px;
}

/* Signal-bars fill left→right. Low = 1 bar lit, Med = 2, High = 3, Urgent = 3 red.
   Unlit bars stay --z-border-strong (default from base rule above). */
/* Fill count = priority level, from the BOTTOM up.
   Spans are ordered top→bottom in DOM, so `:nth-child(3)` = bottom bar. */
.task-row[data-priority="low"] .task-row__priority > span:nth-child(3) { background: var(--z-prio-low); }
.task-row[data-priority="medium"] .task-row__priority > span:nth-child(n+2) { background: var(--z-prio-medium); }
.task-row[data-priority="high"] .task-row__priority > span { background: var(--z-prio-high); }
.task-row[data-priority="urgent"] .task-row__priority > span { background: var(--z-prio-urgent); }

.task-row__title {
  grid-area: title;
  color: var(--z-text-body);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: transparent; border: 0; padding: 0;
  font: inherit; text-align: left; cursor: text;
}

.task-row__title:focus { outline: none; box-shadow: var(--z-focus-ring); border-radius: var(--z-radius-sm); }

.task-row__title-input {
  grid-area: title;
  font: inherit; color: var(--z-text-body);
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  padding: 4px 6px;
  min-width: 0;
}

.task-row__meta {
  grid-area: meta;
  display: flex; flex-wrap: wrap; gap: var(--z-space-2);
  color: var(--z-text-3); font-size: var(--z-fs-small);
  align-items: center;
}

@media (min-width: 768px) {
  .task-row__meta { display: contents; }
}

.task-row__type {
  grid-area: type;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px;
  border-radius: var(--z-radius-sm);
  font-size: var(--z-fs-caption);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.task-row__type::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.task-row[data-type="dev"] .task-row__type { background: var(--z-type-dev-bg); color: var(--z-type-dev); }
.task-row[data-type="operational"] .task-row__type { background: var(--z-type-ops-bg); color: var(--z-type-ops); }
.task-row[data-type="financial"] .task-row__type { background: var(--z-type-fin-bg); color: var(--z-type-fin); }

.task-row__ctx { grid-area: ctx; font-size: var(--z-fs-small); color: var(--z-text-3); }
.task-row__subs { grid-area: subs; font-size: var(--z-fs-small); color: var(--z-text-3); font-variant-numeric: tabular-nums; }
.task-row__due { grid-area: due; font-size: var(--z-fs-small); color: var(--z-text-2); font-variant-numeric: tabular-nums; }
.task-row__assignee {
  grid-area: assignee;
  width: 22px; height: 22px; border-radius: var(--z-radius-full);
  background: var(--z-primary-soft); color: var(--z-primary-active);
  display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 600;
}
/* Placeholder when no assignee: tiny outlined dot, not a filled circle. */
.task-row__assignee--empty {
  background: transparent;
  border: 1px dashed var(--z-border-strong);
  width: 22px; height: 22px;
  opacity: 0.5;
}

.task-row__actions { grid-area: actions; display: inline-flex; gap: var(--z-space-1); }

.task-row__delete {
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  color: var(--z-text-3);
  border-radius: var(--z-radius-sm);
  font-size: 18px; line-height: 1;
  opacity: 0;                       /* only visible on row hover */
  transition: opacity 100ms ease-out;
}
.task-row:hover .task-row__delete,
.task-row__delete:focus-visible { opacity: 1; }
.task-row__delete:hover { background: var(--z-surface-2); color: var(--z-danger); }

/* Status glyphs */
.glyph { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.glyph--backlog { border: 1.5px dashed var(--z-status-backlog); background: transparent; }
.glyph--todo { border: 1.5px solid var(--z-status-todo); background: transparent; }
.glyph--in_progress {
  border: 1.5px solid var(--z-status-in-progress);
  background: linear-gradient(90deg, var(--z-status-in-progress) 50%, transparent 50%);
}
.glyph--blocked { border: 1.5px solid var(--z-status-blocked); background: var(--z-status-blocked); position: relative; }
.glyph--blocked::after { content: ""; position: absolute; inset: 3px; background: white; border-radius: 50%; }
.glyph--done { border: 1.5px solid var(--z-status-done); background: var(--z-status-done); }

/* ---------- Empty state ---------- */

.empty {
  border: 1px dashed var(--z-border-strong);
  border-radius: var(--z-radius-lg);
  padding: var(--z-space-6);
  text-align: center;
  color: var(--z-text-2);
  background: var(--z-surface);
}

.empty__title {
  font-size: var(--z-fs-strong);
  color: var(--z-text);
  font-weight: 600;
  margin: 0 0 var(--z-space-2);
}

.empty__body { margin: 0 0 var(--z-space-4); }

.empty__cta {
  display: inline-block;
  padding: 8px 14px;
  background: var(--z-primary);
  color: var(--z-on-primary);
  border-radius: var(--z-radius-md);
  text-decoration: none;
  font-weight: 500;
  min-height: 36px;
}

.empty__cta:hover { background: var(--z-primary-hover); color: var(--z-on-primary); }

/* ---------- Slide-over ---------- */

.slide-over {
  position: fixed; inset: 0;
  background: rgba(19, 19, 22, 0.35);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--z-space-4);
}

.slide-over__panel {
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-lg);
  box-shadow: var(--z-shadow-md);
  padding: var(--z-space-5);
  width: 100%;
  max-width: 420px;
}

.slide-over__title {
  font-size: var(--z-fs-h3);
  font-weight: 600;
  color: var(--z-text);
  margin: 0 0 var(--z-space-3);
}

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--z-space-3); }
.field label { font-size: var(--z-fs-small); font-weight: 500; color: var(--z-text-2); }
.field input, .field select {
  font: inherit; color: var(--z-text-body);
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  padding: 8px 10px;
  min-height: 40px;
}
.field input:focus, .field select:focus { outline: none; box-shadow: var(--z-focus-ring); }

.field__error { color: var(--z-danger); font-size: var(--z-fs-small); }

.form-actions { display: flex; justify-content: flex-end; gap: var(--z-space-2); }

.btn {
  font: inherit; font-weight: 500;
  border-radius: var(--z-radius-md);
  padding: 8px 14px;
  cursor: pointer;
  min-height: 40px;
  border: 1px solid transparent;
}

.btn--primary { background: var(--z-primary); color: var(--z-on-primary); border-color: var(--z-primary); }
.btn--primary:hover { background: var(--z-primary-hover); border-color: var(--z-primary-hover); }
.btn--ghost { background: transparent; color: var(--z-text-2); border-color: var(--z-border-strong); }
.btn--ghost:hover { background: var(--z-surface-2); color: var(--z-text-body); }

/* =====================================================================
   Sidebar: brand + compact toggle row, primary nav
   ===================================================================== */

.sidebar__head {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 0 4px;
}
.sidebar__head .sidebar__brand { flex: 1; }

.workspace-toggle--compact {
  padding: 3px;
  gap: 2px;
}
.workspace-toggle--compact .workspace-toggle__btn {
  min-width: 26px;
  min-height: 26px;
  padding: 2px 8px;
  flex: none;
  font-size: var(--z-fs-caption);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--z-space-2);
}
.sidebar__nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 6px 8px;
  min-height: 34px;
  border-radius: var(--z-radius-sm);
  color: var(--z-text-body);
  font-size: var(--z-fs-body);
  text-decoration: none;
  font-weight: 500;
}
.sidebar__nav-item:hover { background: var(--z-row-hover); color: var(--z-text); }
.sidebar__nav-item[data-active="true"] {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
}
.sidebar__nav-glyph {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--z-text-3);
}
.sidebar__nav-item[data-active="true"] .sidebar__nav-glyph { color: var(--z-primary-active); }

/* =====================================================================
   Tasks toolbar (group + filter chips)
   ===================================================================== */

.tasks-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--z-space-2);
  padding: var(--z-space-2) 0 var(--z-space-3);
  border-bottom: 1px solid var(--z-border-soft);
  margin-bottom: var(--z-space-3);
}
.tasks-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
}
.tasks-toolbar__select {
  font: inherit;
  font-size: var(--z-fs-small);
  background: var(--z-surface-2);
  color: var(--z-text-body);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  padding: 4px 8px;
  min-height: 30px;
}
.tasks-toolbar__spacer { flex: 1; }

.chip-group {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--z-surface-2);
  border-radius: var(--z-radius-md);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  min-height: 28px;
  font-size: var(--z-fs-small);
  font-weight: 500;
  color: var(--z-text-2);
  background: transparent;
  border: 0;
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.chip:hover { color: var(--z-text); }
.chip[data-active="true"] {
  background: var(--z-surface);
  color: var(--z-text);
  box-shadow: var(--z-shadow-sm);
}
.chip__count {
  font-variant-numeric: tabular-nums;
  color: var(--z-text-3);
  font-size: var(--z-fs-caption);
}

/* =====================================================================
   Inline row controls (priority / type / due date)
   ===================================================================== */

.task-row__inline-select {
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--z-radius-sm);
  padding: 2px 6px;
  min-height: 26px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.task-row__inline-select:hover { background: var(--z-surface-2); border-color: var(--z-border); }
.task-row__inline-select:focus { background: var(--z-surface-2); border-color: var(--z-primary); outline: none; }

.task-row__due-input {
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--z-radius-sm);
  padding: 2px 6px;
  min-height: 26px;
  min-width: 90px;
  font-variant-numeric: tabular-nums;
  color-scheme: light;
}
.task-row__due-input:hover { background: var(--z-surface-2); border-color: var(--z-border); }
.task-row__due-input:focus { background: var(--z-surface-2); border-color: var(--z-primary); outline: none; }

/* Kill the native calendar-picker icon — the input already opens on click,
   the icon adds visual noise to a dense list. Muted on hover as a hint. */
.task-row__due-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  padding: 0;
  margin: 0;
}
.task-row__due-input::-webkit-datetime-edit-day-field,
.task-row__due-input::-webkit-datetime-edit-month-field,
.task-row__due-input::-webkit-datetime-edit-year-field {
  padding: 0 1px;
}
/* Empty date input shows placeholder-ish "—" instead of blank */
.task-row__due-input:not(:focus)::-webkit-datetime-edit {
  color: var(--z-text-2);
}
.task-row__due:has(input[value=""]) { position: relative; }
.task-row__due:has(input[value=""])::before {
  content: "—";
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  color: var(--z-text-muted);
  pointer-events: none;
  font-size: var(--z-fs-small);
}
.task-row__due:has(input[value=""]) .task-row__due-input {
  color: transparent;
}

/* =====================================================================
   Masters page — tree of Organisations -> Clients -> Projects
   ===================================================================== */

.masters {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-3);
}

.masters__toolbar {
  display: flex;
  gap: var(--z-space-2);
  padding-bottom: var(--z-space-3);
  border-bottom: 1px solid var(--z-border-soft);
}

.masters__empty {
  border: 1px dashed var(--z-border-strong);
  border-radius: var(--z-radius-lg);
  padding: var(--z-space-6);
  text-align: center;
  color: var(--z-text-2);
  background: var(--z-surface);
}
.masters__empty h2 { color: var(--z-text); font-size: var(--z-fs-h3); margin: 0 0 var(--z-space-2); }

.tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tree__node {
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  background: var(--z-surface);
  overflow: hidden;
}
.tree__row {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 8px var(--z-space-3);
  min-height: 40px;
  cursor: pointer;
  user-select: none;
}
.tree__row:hover { background: var(--z-row-hover); }
.tree__row > summary { list-style: none; display: contents; }
.tree__row::-webkit-details-marker { display: none; }
details > summary.tree__row { }
.tree__caret {
  color: var(--z-text-3);
  width: 12px; display: inline-flex; justify-content: center;
  transition: transform 120ms ease-out;
}
details[open] > summary .tree__caret { transform: rotate(90deg); }
.tree__dot {
  width: 10px; height: 10px; border-radius: 3px;
  flex: none;
}
.tree__title {
  flex: 1;
  font-weight: 500;
  color: var(--z-text);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree__meta {
  color: var(--z-text-3);
  font-size: var(--z-fs-small);
  font-variant-numeric: tabular-nums;
}
.tree__actions {
  display: inline-flex;
  gap: 4px;
}
.tree__children {
  padding: var(--z-space-1) var(--z-space-4) var(--z-space-2) 30px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--z-border-soft);
  background: var(--z-canvas);
}
.tree__leaf {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 6px 8px;
  min-height: 32px;
  border-radius: var(--z-radius-sm);
  font-size: var(--z-fs-body);
  color: var(--z-text-body);
}
.tree__leaf:hover { background: var(--z-row-hover); }
.tree__leaf-dot {
  width: 6px; height: 6px; border-radius: var(--z-radius-full);
  flex: none;
  background: var(--z-text-3);
}
.tree__add {
  padding: 4px 8px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  background: transparent;
  border: 1px dashed var(--z-border-strong);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  min-height: 28px;
  text-align: left;
  align-self: flex-start;
  margin-top: 4px;
}
.tree__add:hover { background: var(--z-surface); color: var(--z-primary); border-color: var(--z-primary); }

/* Color dot helpers, keyed by organisation color token */
.dot-co-1 { background: var(--z-co-1); }
.dot-co-2 { background: var(--z-co-2); }
.dot-co-3 { background: var(--z-co-3); }
.dot-co-4 { background: var(--z-co-4); }
.dot-co-5 { background: var(--z-co-5); }
.dot-co-6 { background: var(--z-co-6); }

/* =====================================================================
   Masters tree — variant naming used by masters.html
   ===================================================================== */

.masters-tree {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-2);
}

.tree-node {
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  background: var(--z-surface);
  overflow: hidden;
}
.tree-node--client, .tree-node--project {
  border: 0;
  background: transparent;
  border-radius: 0;
}

.tree-node__summary,
.tree-node--project {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 8px var(--z-space-3);
  min-height: 38px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.tree-node__summary::-webkit-details-marker { display: none; }
.tree-node__summary:hover { background: var(--z-row-hover); }
.tree-node--project { cursor: default; padding-left: var(--z-space-4); }
.tree-node--project:hover { background: var(--z-row-hover); }

.tree-node__chevron {
  color: var(--z-text-3);
  width: 12px;
  display: inline-flex;
  justify-content: center;
  transition: transform 120ms ease-out;
  transform: rotate(-90deg);
}
details[open] > .tree-node__summary .tree-node__chevron { transform: rotate(0deg); }

.tree-node__dot {
  width: 10px; height: 10px; border-radius: 3px;
  flex: none;
}
.tree-node__dot--co-1 { background: var(--z-co-1); }
.tree-node__dot--co-2 { background: var(--z-co-2); }
.tree-node__dot--co-3 { background: var(--z-co-3); }
.tree-node__dot--co-4 { background: var(--z-co-4); }
.tree-node__dot--co-5 { background: var(--z-co-5); }
.tree-node__dot--co-6 { background: var(--z-co-6); }

.tree-node__client-icon,
.tree-node__project-icon {
  color: var(--z-text-3);
  font-size: 12px;
  width: 12px;
  display: inline-flex;
  justify-content: center;
}

.tree-node__label {
  flex: 1;
  font-weight: 500;
  color: var(--z-text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-node__meta {
  color: var(--z-text-3);
  font-size: var(--z-fs-small);
  font-variant-numeric: tabular-nums;
}

.tree-node__badge {
  padding: 2px 6px;
  font-size: var(--z-fs-caption);
  font-weight: 600;
  color: var(--z-text-3);
  background: var(--z-surface-2);
  border-radius: var(--z-radius-sm);
}

.tree-node__spacer { flex: 1; }

.tree-node__actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.tree-node__add {
  padding: 4px 8px;
  font: inherit;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  background: transparent;
  border: 1px dashed var(--z-border-strong);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  min-height: 28px;
}
.tree-node__add:hover { background: var(--z-canvas); color: var(--z-primary); border-color: var(--z-primary); }

.tree-node__children {
  padding: var(--z-space-1) var(--z-space-3) var(--z-space-2) 30px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--z-border-soft);
  background: var(--z-canvas);
}

.tree-node__empty {
  padding: 6px 8px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  font-style: italic;
}

/* =====================================================================
   Inbox placeholder
   ===================================================================== */

.stub-hero {
  padding: var(--z-space-8) var(--z-space-4);
  text-align: center;
  color: var(--z-text-2);
  max-width: 480px;
  margin: var(--z-space-6) auto;
}
.stub-hero h1 { color: var(--z-text); font-size: var(--z-fs-h2); margin: 0 0 var(--z-space-2); }
.stub-hero p { margin: 0 0 var(--z-space-4); }

/* ==========================================================================
   Sidebar head row (brand + compact workspace toggle) + primary nav items
   ========================================================================== */

.sidebar__head {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  margin-bottom: var(--z-space-2);
}
.sidebar__head .sidebar__brand { flex: 1; }

.workspace-toggle--compact {
  padding: 3px;
  gap: 2px;
}
.workspace-toggle--compact .workspace-toggle__btn {
  min-height: 28px;
  min-width: 28px;
  padding: 4px 8px;
  font-size: var(--z-fs-caption);
  flex: none;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: var(--z-space-2) 0;
}

.sidebar__nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 7px 8px;
  min-height: 34px;
  border-radius: var(--z-radius-sm);
  color: var(--z-text-body);
  font-size: var(--z-fs-body);
  text-decoration: none;
}
.sidebar__nav-item:hover {
  background: var(--z-row-hover);
  color: var(--z-text);
}
.sidebar__nav-item[data-active="true"] {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
  font-weight: 500;
}
.sidebar__nav-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  color: var(--z-text-3);
}
.sidebar__nav-item[data-active="true"] .sidebar__nav-glyph {
  color: var(--z-primary);
}

/* ==========================================================================
   Tasks toolbar — filter chips + grouping select
   ========================================================================== */

.tasks-toolbar {
  display: flex;
  align-items: center;
  gap: var(--z-space-3);
  flex-wrap: wrap;
  margin-bottom: var(--z-space-3);
  padding: var(--z-space-2) 0;
  border-bottom: 1px solid var(--z-border-soft);
}
.tasks-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-1);
}
.tasks-toolbar__spacer { flex: 1; }
.tasks-toolbar__label {
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
}
.tasks-toolbar__select {
  padding: 4px 8px;
  min-height: 28px;
  font-size: var(--z-fs-small);
  color: var(--z-text-body);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
}
.tasks-toolbar__group-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
}

/* Segmented control — toolbar variant (anchor tabs, not radio inputs). */
.seg--toolbar {
  display: inline-flex;
  padding: 3px;
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  gap: 2px;
}
.seg--toolbar .seg__opt--anchor {
  display: inline-flex;
  text-decoration: none;
  border: 0;
  border-left: 0 !important;
}
.seg--toolbar .seg__label {
  padding: 4px 12px;
  min-height: 26px;
  line-height: 18px;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  background: transparent;
  border-radius: var(--z-radius-sm);
  border-left: 0;
  transition: background 80ms, color 80ms;
}
.seg--toolbar .seg__opt--anchor:hover .seg__label {
  background: var(--z-surface);
  color: var(--z-text);
}
.seg--toolbar .seg__label--on {
  background: var(--z-surface);
  color: var(--z-text);
  box-shadow: var(--z-shadow-sm);
  font-weight: 600;
}

/* ==========================================================================
   Masters — hierarchical tree
   ========================================================================== */

.masters-tree {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-1);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-lg);
  padding: var(--z-space-3);
}

.tree-node { display: block; }

.tree-node__summary {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 6px 8px;
  min-height: 36px;
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.tree-node__summary::-webkit-details-marker { display: none; }
.tree-node__summary:hover { background: var(--z-row-hover); }

.tree-node--org > .tree-node__summary {
  font-weight: 600;
  color: var(--z-text);
}
.tree-node--client > .tree-node__summary {
  color: var(--z-text-body);
}

.tree-node__chevron {
  color: var(--z-text-3);
  width: 12px;
  display: inline-block;
  transition: transform 120ms ease-out;
  transform: rotate(-90deg);
}
details[open] > .tree-node__summary > .tree-node__chevron {
  transform: rotate(0deg);
}

.tree-node__dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}
.tree-node__dot--co-1 { background: var(--z-co-1); }
.tree-node__dot--co-2 { background: var(--z-co-2); }
.tree-node__dot--co-3 { background: var(--z-co-3); }
.tree-node__dot--co-4 { background: var(--z-co-4); }
.tree-node__dot--co-5 { background: var(--z-co-5); }
.tree-node__dot--co-6 { background: var(--z-co-6); }

.tree-node__client-icon,
.tree-node__project-icon {
  color: var(--z-text-3);
  width: 12px;
  display: inline-block;
  text-align: center;
}

.tree-node__label { flex: 0 1 auto; }
.tree-node__meta {
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
}
.tree-node__spacer { flex: 1; }
.tree-node__badge {
  padding: 2px 6px;
  font-size: var(--z-fs-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--z-text-3);
  background: var(--z-surface-2);
  border-radius: var(--z-radius-sm);
}

.tree-node__actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease-out;
}
.tree-node__summary:hover .tree-node__actions,
.tree-node:hover > .tree-node__actions { opacity: 1; }
@media (max-width: 767.98px) {
  .tree-node__actions { opacity: 1; }
}

.tree-node__add {
  padding: 4px 8px;
  min-height: 28px;
  font-size: var(--z-fs-caption);
  font-weight: 500;
  color: var(--z-text-2);
  background: var(--z-surface-2);
  border: 1px dashed var(--z-border);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
}
.tree-node__add:hover {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
  border-color: var(--z-primary-soft);
}

.tree-node__children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 22px;
}

.tree-node--project {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 4px 8px;
  min-height: 32px;
  border-radius: var(--z-radius-sm);
}
.tree-node--project:hover { background: var(--z-row-hover); }

.tree-node__empty {
  padding: 4px 8px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  font-style: italic;
}

/* Field inline (checkbox with label to the right) */
.field--inline label {
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-2);
  color: var(--z-text-body);
  font-weight: 400;
}

/* Masters hint bar */
.masters-tree__hint {
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  margin: 0 0 var(--z-space-3);
  padding: 6px 10px;
  background: var(--z-surface-2);
  border-radius: var(--z-radius-sm);
}

/* Prevent dblclick text selection on tree rows */
.tree-node--project { user-select: none; }
.tree-node__label { user-select: none; }

/* Slide-over meta line under title */
.slide-over__meta {
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  margin: -6px 0 var(--z-space-3);
}

/* ==========================================================================
   Task modal — dense, keyboard-first, single-column form.
   Segmented pickers (touching pills) instead of loose chip clusters so short
   labels don't render as circles and 4 items don't wrap 2×2.
   ========================================================================== */

.task-modal {
  width: min(572px, 96vw);
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
  border-radius: var(--z-radius-lg);
  overflow: hidden;
}
.task-modal__head {
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: 14px 18px;
  border-bottom: 1px solid var(--z-border-soft);
}
.task-modal__head .slide-over__title { flex: 1; margin: 0; font-size: var(--z-fs-strong); font-weight: 600; }
.task-modal__close {
  width: 28px; height: 28px;
  background: transparent; border: 0; padding: 0;
  color: var(--z-text-3); cursor: pointer;
  font-size: 20px; line-height: 1;
  border-radius: var(--z-radius-sm);
}
.task-modal__close:hover { background: var(--z-surface-2); color: var(--z-text); }

.task-modal__form {
  padding: 14px 18px;
  overflow-y: auto;
  overflow-x: hidden;    /* explicit — `overflow-y: auto` alone lets browsers implicit-auto the x-axis */
  display: flex; flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.task-modal__field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.task-modal__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
}
.task-modal__row {
  display: grid;
  /* Priority has 4 options vs Type's 3 — give it more room so labels don't truncate to "No…", "Me…". */
  grid-template-columns: minmax(0, 3fr) minmax(0, 4fr);
  gap: 14px;
}
@media (max-width: 519.98px) {
  .task-modal__row { grid-template-columns: minmax(0, 1fr); }
}

/* Title = the star. Borderless headline that pulses on focus, not a boxed input. */
.task-modal__title-input {
  padding: 4px 0 6px;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--z-text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  outline: none;
  transition: border-color 120ms ease-out;
}
.task-modal__title-input::placeholder {
  color: var(--z-text-muted);
  font-weight: 400;
}
.task-modal__title-input:focus {
  border-bottom-color: var(--z-primary);
  box-shadow: none;
}

.task-modal__due { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.task-modal__date-input {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: var(--z-radius-sm);
  border: 1px solid var(--z-border);
  background: var(--z-surface);
  min-height: 32px;
  font-size: var(--z-fs-small);
  color: var(--z-text-body);
  font-variant-numeric: tabular-nums;
}
.due-quick { display: flex; gap: 4px; flex-wrap: wrap; }

.task-modal__foot {
  padding: 10px 18px;
  border-top: 1px solid var(--z-border-soft);
  display: flex; align-items: center; gap: var(--z-space-3);
  background: var(--z-surface);
  justify-content: space-between;
}
.task-modal__hint {
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-modal__hint kbd {
  padding: 0 4px;
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: var(--z-font-mono);
  font-size: 10px;
  color: var(--z-text-body);
}
.task-modal__foot .form-actions { flex: 0 0 auto; gap: 6px; }

/* ---------- Segmented picker (Type + Priority) ---------------------------
   Uses grid so each option is equal width. Native <input> hidden; the <span>
   is the visible chip. First/last children get outer radii, everything else
   touches. */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  overflow: hidden;
  background: var(--z-surface);
  min-width: 0;
}
.seg .seg__opt { position: relative; display: block; cursor: pointer; min-width: 0; }
.seg .seg__opt + .seg__opt { border-left: 1px solid var(--z-border); }
.seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.seg .seg__label {
  display: block;
  padding: 6px 6px;         /* tighter horizontal so 4-item Priority column fits without ellipsis */
  min-height: 30px;
  font-size: var(--z-fs-small);
  font-weight: 500;
  color: var(--z-text-2);
  text-align: center;
  line-height: 18px;
  background: var(--z-surface);
  transition: background 80ms, color 80ms;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg .seg__opt:hover .seg__label { background: var(--z-surface-2); color: var(--z-text); }
.seg input:checked + .seg__label {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
  font-weight: 600;
}
.seg input:focus-visible + .seg__label { box-shadow: inset 0 0 0 2px var(--z-primary); }

/* Type-specific checked tints */
.seg input:checked + .seg__label--dev { background: var(--z-type-dev-bg); color: var(--z-type-dev); }
.seg input:checked + .seg__label--operational { background: var(--z-type-ops-bg); color: var(--z-type-ops); }
.seg input:checked + .seg__label--financial { background: var(--z-type-fin-bg); color: var(--z-type-fin); }

/* Priority-specific checked tints (None is no longer in the picker — no
   selection = no priority; the × clear button unsets a chosen priority). */
.seg input:checked + .seg__label--prio-low { background: rgba(107,114,128,0.12); color: var(--z-prio-low); }
.seg input:checked + .seg__label--prio-medium { background: rgba(234,179,8,0.16); color: var(--z-prio-medium); }
.seg input:checked + .seg__label--prio-high { background: rgba(245,158,11,0.16); color: var(--z-prio-high); }

/* Segment with an appended clear (×) button — used by the Priority picker.
   Uses flex (not grid) so the radios take equal space and the × sizes to
   its content. The × has NO outer border — it borrows the seg's frame and
   uses a left border as the divider matching the other seg dividers. */
.seg--with-clear {
  display: flex;
  align-items: stretch;
}
.seg--with-clear .seg__opt {
  flex: 1 1 0;
  min-width: 0;
}
.seg__clear {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 0 10px;
  border: 0;
  border-left: 1px solid var(--z-border);
  border-radius: 0;
  background: transparent;
  color: var(--z-text-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.seg__clear:hover { background: var(--z-surface-2); color: var(--z-danger); }
.seg__clear[hidden] { display: none; }

/* Ghost pill buttons for due-date shortcuts */
.chip--ghost {
  padding: 3px 10px;
  min-height: 26px;
  font-size: var(--z-fs-caption);
  color: var(--z-text-2);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
}
.chip--ghost:hover { background: var(--z-primary-soft); color: var(--z-primary-active); border-color: var(--z-primary); }

/* Keyboard hint pill on a primary button */
.kbd-hint {
  margin-left: 6px;
  padding: 0 5px;
  background: rgba(255,255,255,0.22);
  border-radius: 3px;
  font-family: var(--z-font-mono);
  font-size: 10px;
  font-weight: 600;
}

/* ==========================================================================
   Combobox (searchable dropdown with keyboard nav)
   ========================================================================== */

.z-combobox {
  position: relative;
  /* Chevron sits at the right — the caret is a background SVG so the input
     itself stays a normal <input> (no wrapper flex needed). */
}
.z-combobox__input {
  width: 100%;
  padding: 7px 32px 7px 10px;
  min-height: 34px;
  font-size: var(--z-fs-body);
  color: var(--z-text-body);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  cursor: text;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%2384858f' stroke-width='1.5' stroke-linecap='round'><path d='M3 5l3 3 3-3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.z-combobox__input:hover { border-color: var(--z-border-strong); }
.z-combobox__input:focus {
  outline: none;
  border-color: var(--z-primary);
  box-shadow: var(--z-focus-ring);
}
.z-combobox__menu {
  /* Positioned by JS on open — `position: fixed` escapes the modal's
     overflow:auto container so the dropdown floats above other fields
     instead of being clipped or overlaying them awkwardly. */
  position: fixed;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  box-shadow: var(--z-shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 200;
  z-index: 10;
}
.z-combobox__item {
  padding: 6px 8px;
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
}
.z-combobox__item.is-active,
.z-combobox__item:hover {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
}
.z-combobox__primary { font-weight: 500; font-size: var(--z-fs-body); }
.z-combobox__secondary { font-size: var(--z-fs-small); color: var(--z-text-3); }
.z-combobox__item.is-active .z-combobox__secondary,
.z-combobox__item:hover .z-combobox__secondary { color: var(--z-primary-active); opacity: 0.85; }
.z-combobox__empty {
  padding: 8px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  font-style: italic;
}

/* ==========================================================================
   Tasks page polish (matches the modal's tight Plane-density conventions)
   ========================================================================== */

/* Hide the native calendar picker icon on the inline row date input.
   The whole cell is still click-to-open — WebKit's own icon is redundant
   and reads as visual noise next to every task. */
.task-row__due-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  width: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;   /* still clickable, just invisible */
}
.task-row__due-input {
  padding-right: 4px;
  color-scheme: light;
}
.task-row__due-input:not(:focus):placeholder-shown,
.task-row__due-input:not(:focus)[value=""] {
  color: var(--z-text-3);
}

/* Toolbar variant of the segmented control — used by the tasks page filter row.
   Renders anchors instead of radios (`.seg__opt--anchor` styled to look identical). */
.seg--toolbar {
  display: inline-flex;
  min-width: 0;
}
.seg--toolbar .seg__opt {
  display: block;
  text-decoration: none;
  color: inherit;
}
.seg--toolbar .seg__opt + .seg__opt { border-left: 1px solid var(--z-border); }
.seg--toolbar .seg__label {
  padding: 6px 12px;
  min-height: 30px;
  display: block;
  font-size: var(--z-fs-small);
  font-weight: 500;
  color: var(--z-text-2);
  background: var(--z-surface);
  transition: background 80ms, color 80ms;
  cursor: pointer;
  white-space: nowrap;
}
.seg--toolbar .seg__opt:hover .seg__label { background: var(--z-surface-2); color: var(--z-text); }
.seg--toolbar .seg__label--on {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
  font-weight: 600;
}

/* Row-density trims: overrides for tasks page only (already scoped by @media above) */
@media (min-width: 768px) {
  .task-row {
    padding: 4px var(--z-space-3);
    min-height: 32px;
  }
}

/* Group headers on the tasks page — quieter than page titles, still scannable */
.task-group__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--z-space-3) 6px;
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--z-text-3);
}
.task-group__count {
  font-size: var(--z-fs-caption);
  color: var(--z-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Group select — inline, small, matches toolbar */
.tasks-toolbar__group-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
}


/* ==========================================================================
   Sidebar footer — version + environment badge, pinned to bottom
   ========================================================================== */

.sidebar__foot {
  margin-top: auto;
  padding: 8px 6px 0;
  border-top: 1px solid var(--z-border-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
}
.sidebar__version {
  font-family: var(--z-font-mono);
  font-size: 10px;
  color: var(--z-text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.env-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: var(--z-radius-sm);
  background: var(--z-surface-2);
  color: var(--z-text-2);
  border: 1px solid var(--z-border);
}
.env-tag--local { background: var(--z-primary-soft); color: var(--z-primary-active); border-color: var(--z-primary-soft); }
.env-tag--dev { background: rgba(8,145,178,0.12); color: var(--z-type-ops); border-color: rgba(8,145,178,0.4); }
.env-tag--stage { background: rgba(217,119,6,0.12); color: var(--z-warning); border-color: rgba(217,119,6,0.4); }
.env-tag--production { background: rgba(22,163,74,0.12); color: var(--z-success); border-color: rgba(22,163,74,0.4); }

/* ==========================================================================
   User chip + dropdown — rendered inside the topbar (see .app__topbar-user)
   ========================================================================== */

.user-chip { position: relative; }

.user-chip__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  min-height: 32px;
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-full);
  cursor: pointer;
  color: var(--z-text-body);
  font-size: var(--z-fs-small);
}
.user-chip__trigger:hover { background: var(--z-surface-2); border-color: var(--z-border-strong); }
.user-chip__trigger:focus-visible { box-shadow: var(--z-focus-ring); outline: none; }

.user-chip__avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--z-primary);
  color: var(--z-on-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  flex: none;
}
.user-chip__email {
  color: var(--z-text-body);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip__caret {
  color: var(--z-text-3);
  font-size: 10px;
  margin-left: 2px;
}

.user-chip__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  box-shadow: var(--z-shadow-md);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-chip__menu[hidden] { display: none; }

.user-chip__menu-header {
  padding: 8px 10px;
  border-bottom: 1px solid var(--z-border-soft);
  margin-bottom: 4px;
}
.user-chip__menu-name {
  font-size: var(--z-fs-body);
  font-weight: 600;
  color: var(--z-text);
}
.user-chip__menu-email {
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  font-family: var(--z-font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip__menu-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--z-text-body);
  text-align: left;
  font-size: var(--z-fs-small);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.user-chip__menu-item:hover { background: var(--z-surface-2); color: var(--z-text); }
.user-chip__menu-item--danger:hover { background: rgba(220,38,38,0.08); color: var(--z-danger); }

/* ---- Outline view: org -> client -> project -> tasks ------------------ */
.outline-org { margin-top: var(--z-space-4); }
.outline-org__header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px var(--z-space-2) 4px;
  font-size: var(--z-fs-strong); font-weight: 600;
  color: var(--z-text); border-bottom: 1px solid var(--z-border);
}
.outline-org__label { flex: 0 1 auto; }
.outline-client { margin-left: 18px; margin-top: var(--z-space-2); }
.outline-client__header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px 4px;
  font-size: var(--z-fs-body); font-weight: 600; color: var(--z-text-2);
}
.outline-project { margin-left: 18px; }
.outline-project--orphan { margin-left: 18px; }
.outline-project__header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px 4px;
  font-size: var(--z-fs-small);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--z-text-3);
}
.outline-project__label { flex: 0 1 auto; }
.outline__caret {
  display: inline-block; width: 12px;
  color: var(--z-text-muted); font-size: 10px; line-height: 1;
  flex: 0 0 auto;
}
.outline-project .task-row,
.outline-project--orphan .task-row { padding-left: 20px; }

/* ---- Kanban board ----------------------------------------------------- */
.kanban-board {
  display: flex; gap: var(--z-space-3);
  overflow-x: auto;
  padding: var(--z-space-2) 0 var(--z-space-4);
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.kanban-column {
  flex: 0 0 280px; min-width: 280px; max-width: 280px;
  display: flex; flex-direction: column;
  background: var(--z-surface-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  scroll-snap-align: start;
}
.kanban-column__header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 8px;
  font-size: var(--z-fs-caption);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; color: var(--z-text-3);
  border-bottom: 1px solid var(--z-border);
}
.kanban-column__label { flex: 1 1 auto; }
.kanban-column__count {
  font-variant-numeric: tabular-nums;
  color: var(--z-text-muted); font-size: var(--z-fs-caption);
}
.kanban-column__body {
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 60px;
}
.kanban-column__empty {
  padding: 12px 8px; color: var(--z-text-muted);
  font-size: var(--z-fs-small); text-align: center; font-style: italic;
}
.kanban-column .task-row {
  grid-template-columns: 22px 16px 1fr auto;
  grid-template-areas:
    "status priority title actions"
    "ctx    ctx      ctx   ctx"
    "due    due      due   due";
  padding: 8px 10px; min-height: 0;
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  background: var(--z-surface);
  row-gap: 4px;
}
.kanban-column .task-row:hover { background: var(--z-row-hover); }
.kanban-column .task-row__ctx {
  grid-area: ctx; font-size: var(--z-fs-caption);
  color: var(--z-text-muted); padding-left: 2px;
}
.kanban-column .task-row__due {
  grid-area: due; font-size: var(--z-fs-caption);
  justify-self: start; border: 0; padding: 0 2px;
  background: transparent; color: var(--z-text-muted);
  width: auto; max-width: 100%;
}
.kanban-column .task-row__type,
.kanban-column .task-row__subs,
.kanban-column .task-row__assignee { display: none; }
.kanban-column .task-row__title {
  font-size: var(--z-fs-body);
  white-space: normal; text-align: left; padding: 0;
}

/* ---- Status seg (modal + row popover) --------------------------------- */
.seg--status {
  display: flex; flex-direction: column; min-width: 180px;
}
.seg--status .seg__opt { display: block; }
.seg--status .seg__opt + .seg__opt {
  border-left: 0; border-top: 1px solid var(--z-border);
}
.seg--status .seg__label {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-start; text-align: left;
  padding: 6px 10px;
}
.seg--status .seg__label .glyph { flex: 0 0 auto; }
.seg input:checked + .seg__label--status-backlog     { background: rgba(107,114,128,0.10); color: var(--z-status-backlog); }
.seg input:checked + .seg__label--status-todo        { background: rgba(107,109,120,0.12); color: var(--z-status-todo); }
.seg input:checked + .seg__label--status-in_progress { background: rgba(217,119,6,0.14);   color: var(--z-status-in-progress); }
.seg input:checked + .seg__label--status-blocked     { background: rgba(220,38,38,0.12);   color: var(--z-status-blocked); }
.seg input:checked + .seg__label--status-done        { background: rgba(22,163,74,0.14);   color: var(--z-status-done); }

/* ---- Kanban drag-to-move states -------------------------------------- */
.kanban-column .task-row.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
}
.kanban-column .task-row { cursor: grab; }
.kanban-column.is-drop-target {
  outline: 2px dashed var(--z-primary);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--z-primary) 6%, var(--z-surface-2));
}
