/* ============================================================
   TaskTrack — styles
   Dependency-free. Works by opening index.html directly.
   ============================================================ */

:root {
  --c-bg: #f4f5f7;
  --c-surface: #ffffff;
  --c-surface-2: #fafbfc;
  --c-border: #e4e7ec;
  --c-text: #1a1f36;
  --c-text-soft: #6b7280;
  --c-text-faint: #9ca3af;
  --c-accent: #4f46e5;
  --c-accent-soft: #eef2ff;

  --s-pending: #94a3b8;
  --s-inprogress: #3b82f6;
  --s-blocked: #ef4444;
  --s-onhold: #f59e0b;
  --s-completed: #22c55e;

  --p-high: #ef4444;
  --p-medium: #f59e0b;
  --p-low: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .12);
  --radius: 12px;
}

/* Dark palette. Applied when the viewer's system prefers dark AND they haven't
   forced light, or when they've explicitly chosen dark via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-bg: #0f1117;
    --c-surface: #181b23;
    --c-surface-2: #1f232d;
    --c-border: #2a2f3a;
    --c-text: #e8eaed;
    --c-text-soft: #9aa1ad;
    --c-text-faint: #6b7280;
    --c-accent: #7c7bff;
    --c-accent-soft: #21243b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  --c-bg: #0f1117;
  --c-surface: #181b23;
  --c-surface-2: #1f232d;
  --c-border: #2a2f3a;
  --c-text: #e8eaed;
  --c-text-soft: #9aa1ad;
  --c-text-faint: #6b7280;
  --c-accent: #7c7bff;
  --c-accent-soft: #21243b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
}

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

/* The `hidden` attribute must always win over the display rules below
   (e.g. .modal-overlay/.board set display, which would otherwise beat it). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ===== Boot spinner ===== */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center; gap: 18px;
  background: var(--c-bg); grid-auto-flow: row;
}
.boot-mark {
  width: 52px; height: 52px; border-radius: 14px; background: var(--c-accent);
  color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--c-border); border-top-color: var(--c-accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinning { animation: spin .8s linear infinite; }

/* ===== Auth screen ===== */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--c-bg); }
.auth-card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 32px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 20px;
}
.brand.center { flex-direction: column; text-align: center; gap: 12px; }
.brand.center .brand-text h1 { font-size: 22px; }
.brand.center .brand-text span { font-size: 13px; }
.auth-tabs { display: flex; background: var(--c-bg); border-radius: 9px; padding: 3px; }
.auth-tab { flex: 1; border: none; background: transparent; cursor: pointer; padding: 8px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--c-text-soft); font-family: inherit; }
.auth-tab.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.primary-btn.wide { width: 100%; padding: 11px; }
.auth-msg { font-size: 13px; padding: 10px 12px; border-radius: 8px; margin: 0; }
.auth-msg.ok { background: rgba(34,197,94,.12); color: #16a34a; }
.auth-msg.err { background: rgba(239,68,68,.12); color: var(--s-blocked); }
.auth-hint { font-size: 12px; color: var(--c-text-faint); text-align: center; margin: 0; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 42px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: none; cursor: pointer; font-size: 16px; padding: 4px 6px; opacity: .6; line-height: 1; }
.pw-eye:hover { opacity: 1; }
.pw-eye.on { opacity: 1; }
.linklike { display: block; margin: -4px auto 0; border: none; background: none; padding: 4px; cursor: pointer; font: inherit; font-size: 13px; color: var(--c-accent); text-decoration: underline; }
.linklike:hover { opacity: .8; }
.track-link { margin-top: 12px; padding: 12px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-bg); }
.track-link-label { margin: 0 0 8px; font-size: 12.5px; color: var(--c-text-soft); }
.track-link-row { display: flex; gap: 8px; }
.track-link-row input { flex: 1; min-width: 0; font-size: 12.5px; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text); }
.track-hint { margin: 0 0 10px; font-size: 12px; color: var(--c-text-faint); }

/* ===== Account block ===== */
.account {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--c-border); border-radius: 10px; margin-bottom: 10px; background: var(--c-surface-2);
}
.account-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--c-accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.account-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-email { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-size: 11px; color: var(--c-text-faint); }
.footer-actions { display: flex; gap: 8px; }
.upload-text { font-size: 14px; color: var(--c-text-soft); line-height: 1.5; margin: 0 0 4px; }
.notif-btn { width: 100%; margin-bottom: 10px; }
.theme-toggle { width: 100%; margin-top: 8px; }
.portal-account .theme-toggle, .portal-top .theme-toggle { width: auto; margin-top: 0; }

/* ===== Request / attention badges ===== */
.chip.request-chip { background: rgba(14,165,233,.14); color: #0284c7; }
.chip.attention-chip { background: rgba(249,115,22,.16); color: #ea580c; }
.card.flagged, .list-row.flagged { box-shadow: 0 0 0 2px rgba(249,115,22,.4); }

/* ===== People & roles ===== */
.people-hint { font-size: 13px; color: var(--c-text-soft); margin: 0 0 14px; }
.invite-form { display: flex; gap: 8px; margin-bottom: 8px; }
.invite-form input { flex: 1; min-width: 0; border: 1px solid var(--c-border); background: var(--c-surface-2); padding: 9px 11px; border-radius: 9px; font-size: 14px; font-family: inherit; color: var(--c-text); }
.invite-form select { border: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 9px; padding: 9px; font-size: 13px; font-family: inherit; color: var(--c-text); }
.invite-form input:focus, .invite-form select:focus { outline: none; border-color: var(--c-accent); }
.invite-hint { font-size: 12px; color: var(--c-text-faint); margin: 0 0 14px; }
.invite-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.invite-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--c-accent-soft); border-radius: 8px; }
.invite-email { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-role-tag { font-size: 11px; font-weight: 700; color: var(--c-accent); text-transform: uppercase; letter-spacing: .3px; }
.people-subhead { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--c-text-faint); font-weight: 700; margin: 6px 0 8px; }
.people-list { display: flex; flex-direction: column; gap: 8px; max-height: 44vh; overflow-y: auto; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--c-border); border-radius: 10px; flex-wrap: wrap; }
.person-role { flex: none; }
.person-remove { flex: none; padding: 6px 12px; font-size: 12.5px; }
.person-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name { font-size: 13.5px; font-weight: 600; }
.person-email { font-size: 12px; color: var(--c-text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--c-accent); background: var(--c-accent-soft); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.you-tag.pending-tag { color: #d97706; background: rgba(245,158,11,.16); }
.person-role { border: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 8px; padding: 6px 8px; font-size: 13px; font-family: inherit; color: var(--c-text); }

/* ===== Requester portal ===== */
.portal { position: fixed; inset: 0; overflow-y: auto; background: var(--c-bg); }
.portal-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--c-surface); border-bottom: 1px solid var(--c-border); }
.portal-account { display: flex; align-items: center; gap: 12px; }
.portal-body { max-width: 680px; margin: 0 auto; padding: 24px 20px 60px; display: flex; flex-direction: column; gap: 28px; }
/* Dashboard with side nav (one view at a time) */
.portal-shell { max-width: 920px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.portal-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 20px; }
.pnav-btn { display: flex; align-items: center; gap: 10px; text-align: left; border: none; background: transparent; color: var(--c-text-soft); font: inherit; font-size: 14px; font-weight: 600; padding: 11px 12px; border-radius: 10px; cursor: pointer; }
.pnav-btn:hover { background: var(--c-surface); }
.pnav-btn.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }
.pnav-btn .count { margin-left: auto; font-size: 12px; background: var(--c-bg); color: var(--c-text-faint); border-radius: 999px; padding: 1px 8px; }
.portal-main { min-width: 0; }
@media (max-width: 720px) {
  .portal-shell { grid-template-columns: 1fr; gap: 14px; padding: 14px; }
  .portal-nav { flex-direction: row; overflow-x: auto; position: static; gap: 6px; }
  .pnav-btn { flex: 1 0 auto; justify-content: center; }
  .pnav-btn .count { display: none; }
}
.portal-new, .portal-list { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px; padding: 22px; }
.portal-new h2, .portal-list h2 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.portal-hint { font-size: 13px; color: var(--c-text-faint); margin-bottom: 16px; }
.portal-new form { display: flex; flex-direction: column; gap: 14px; }
.request-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.request-row:last-child { border-bottom: none; }
.request-main { flex: 1; min-width: 0; }
.request-title { font-size: 14.5px; font-weight: 600; }
.request-row.done .request-title { text-decoration: line-through; color: var(--c-text-faint); }
.request-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.nudge-btn { flex: none; }
.request-row.clickable { cursor: pointer; border-radius: 10px; padding: 12px 10px; margin: 0 -10px; }
.request-row.clickable:hover { background: var(--c-bg); }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-notes { font-size: 13.5px; color: var(--c-text-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-notes:empty { display: none; }
.request-row.col { flex-direction: column; align-items: stretch; }
.request-toprow { display: flex; align-items: center; gap: 14px; }
.thread-toggle { align-self: flex-start; margin: 8px 0 0; }
.mini-thread { margin-top: 8px; padding: 10px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-bg); }
.mini-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; margin-bottom: 8px; font-size: 13px; }
.mini-item.sys { font-size: 12px; color: var(--c-text-faint); font-style: italic; }
.mini-when { font-size: 11px; color: var(--c-text-faint); margin-left: 4px; }
.mini-empty { font-size: 12.5px; color: var(--c-text-faint); }
.mini-compose { display: flex; gap: 8px; }
.mini-compose input { flex: 1; min-width: 0; border: 1px solid var(--c-border); background: var(--c-surface); padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--c-text); }
.mini-compose input:focus { outline: none; border-color: var(--c-accent); }
.status-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: .3px; }
.status-badge.s-pending { background: rgba(148,163,184,.18); color: #64748b; }
.status-badge.s-inprogress { background: rgba(59,130,246,.15); color: #2563eb; }
.status-badge.s-blocked { background: rgba(239,68,68,.14); color: #dc2626; }
.status-badge.s-onhold { background: rgba(245,158,11,.16); color: #d97706; }
.status-badge.s-completed { background: rgba(34,197,94,.16); color: #16a34a; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 24px;
  min-height: 0;          /* allow the column to shrink within the 100vh grid */
  overflow-y: auto;       /* scroll when views + projects exceed the height */
  overscroll-behavior: contain;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--c-accent); color: #fff;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.brand-text span { font-size: 12px; color: var(--c-text-faint); }

.filters { display: flex; flex-direction: column; gap: 2px; }
.filters-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--c-text-faint); font-weight: 600; padding: 0 8px 6px;
}
.filters-label.with-action {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 8px 6px;
}
.mini-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--c-text-faint); font-size: 16px; line-height: 1;
  padding: 2px 6px; border-radius: 6px; font-family: inherit;
}
.mini-btn:hover { background: var(--c-surface-2); color: var(--c-accent); }

.project-list { display: flex; flex-direction: column; gap: 2px; }
.project-row { display: flex; align-items: center; }
.project-row .project-btn { flex: 1; min-width: 0; }
.project-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-edit {
  border: none; background: transparent; cursor: pointer;
  color: var(--c-text-faint); font-size: 15px; line-height: 1;
  padding: 4px 8px; border-radius: 6px; font-family: inherit;
  opacity: 0; transition: opacity .12s;
}
.project-row:hover .row-edit { opacity: 1; }
.row-edit:hover { background: var(--c-surface-2); color: var(--c-text); }
.filter-btn {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; cursor: pointer;
  padding: 9px 10px; border-radius: 8px;
  font-size: 14px; color: var(--c-text-soft); font-weight: 500;
  font-family: inherit; text-align: left; width: 100%;
  transition: background .12s, color .12s;
}
.filter-btn:hover { background: var(--c-surface-2); }
.filter-btn.active { background: var(--c-accent-soft); color: var(--c-accent); font-weight: 600; }
.filter-btn .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.filter-btn .count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  background: var(--c-bg); color: var(--c-text-soft);
  padding: 1px 8px; border-radius: 20px; min-width: 22px; text-align: center;
}
.filter-btn.active .count { background: var(--c-surface); color: var(--c-accent); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; }

/* ===== Buttons ===== */
.primary-btn {
  background: var(--c-accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  box-shadow: var(--shadow-sm); transition: filter .12s, transform .05s;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: translateY(1px); }

.ghost-btn {
  background: var(--c-surface); color: var(--c-text-soft);
  border: 1px solid var(--c-border);
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; flex: 1;
  transition: background .12s;
}
.ghost-btn:hover { background: var(--c-surface-2); }

.danger-btn {
  background: transparent; color: var(--s-blocked);
  border: 1px solid transparent; padding: 8px 12px; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit;
}
.danger-btn:hover { background: rgba(239, 68, 68, .1); }
.ghost-btn.danger-outline { color: var(--s-blocked); border-color: var(--s-blocked); }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; color: var(--c-text-faint); padding: 6px;
  border-radius: 6px; line-height: 1;
}
.icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn.danger { color: var(--s-blocked); border: 1px solid var(--c-border); }
.icon-btn.danger:hover { background: rgba(239, 68, 68, .12); border-color: var(--s-blocked); }

/* ===== Topbar ===== */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--c-border);
  background: var(--c-surface); gap: 16px; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 18px; }
#viewTitle { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }

.view-toggle { display: flex; background: var(--c-bg); border-radius: 9px; padding: 3px; }
.toggle-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600;
  color: var(--c-text-soft); font-family: inherit; transition: all .12s;
}
.toggle-btn.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-faint); font-size: 15px;
}
#search {
  border: 1px solid var(--c-border); background: var(--c-surface-2);
  padding: 9px 12px 9px 32px; border-radius: 9px; font-size: 14px;
  font-family: inherit; color: var(--c-text); width: 220px; transition: border .12s;
}
#search:focus { outline: none; border-color: var(--c-accent); background: var(--c-surface); }

/* ===== Board ===== */
.board {
  flex: 1; display: flex; gap: 16px; padding: 20px 24px;
  overflow-x: auto; overflow-y: hidden; align-items: flex-start;
}
.column {
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: var(--radius); width: 288px; flex: none;
  display: flex; flex-direction: column; max-height: 100%;
}
.column.drag-over { border-color: var(--c-accent); background: var(--c-accent-soft); }
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}
.column-head .status-dot { width: 10px; height: 10px; border-radius: 50%; }
.column-head .col-count {
  margin-left: auto; font-size: 12px; color: var(--c-text-faint);
  background: var(--c-bg); padding: 1px 8px; border-radius: 20px; font-weight: 600;
}
.column-body {
  padding: 4px 10px 10px; overflow-y: auto; display: flex;
  flex-direction: column; gap: 10px; flex: 1; min-height: 40px;
}
.col-empty {
  color: var(--c-text-faint); font-size: 12.5px; text-align: center;
  padding: 18px 8px; border: 1.5px dashed var(--c-border); border-radius: 8px;
}

/* ===== Card ===== */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 12px; cursor: grab;
  box-shadow: var(--shadow-sm); transition: box-shadow .12s, transform .05s;
  border-left: 3px solid var(--c-border);
}
.card:hover { box-shadow: var(--shadow-md); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .5; }
.card.prio-high { border-left-color: var(--p-high); }
.card.prio-medium { border-left-color: var(--p-medium); }
.card.prio-low { border-left-color: var(--p-low); }

.card-title { font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.card.done .card-title { text-decoration: line-through; color: var(--c-text-faint); }
.card-notes {
  font-size: 12.5px; color: var(--c-text-soft); line-height: 1.4;
  margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip.project-chip {
  background: color-mix(in srgb, var(--pc) 15%, transparent);
  color: var(--pc);
}
/* Fallback for browsers without color-mix support. */
@supports not (color: color-mix(in srgb, red, blue)) {
  .chip.project-chip { background: var(--c-bg); color: var(--pc); }
}
.chip.due { background: var(--c-bg); color: var(--c-text-soft); }
.chip.due.overdue { background: rgba(239, 68, 68, .12); color: var(--s-blocked); }
.chip.due.today { background: rgba(245, 158, 11, .14); color: #d97706; }
.chip.prio { text-transform: capitalize; }
.chip.prio.high { background: rgba(239, 68, 68, .12); color: var(--p-high); }
.chip.prio.medium { background: rgba(245, 158, 11, .14); color: #d97706; }
.chip.prio.low { background: var(--c-bg); color: var(--c-text-soft); }

/* ===== List view ===== */
.list-view { flex: 1; overflow-y: auto; padding: 20px 24px; }
.list-group { margin-bottom: 22px; }
.list-group-head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 10px;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--c-text-soft);
}
.list-group-head .status-dot { width: 10px; height: 10px; border-radius: 50%; }
.list-group-head .col-count { color: var(--c-text-faint); font-weight: 600; }
.list-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: box-shadow .12s; border-left: 3px solid var(--c-border);
}
.list-row:hover { box-shadow: var(--shadow-sm); }
.list-row.prio-high { border-left-color: var(--p-high); }
.list-row.prio-medium { border-left-color: var(--p-medium); }
.list-row.prio-low { border-left-color: var(--p-low); }
.list-check {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--c-border);
  flex: none; cursor: pointer; display: grid; place-items: center;
  color: transparent; font-size: 12px; transition: all .12s;
}
.list-check:hover { border-color: var(--s-completed); }
.list-row.done .list-check { background: var(--s-completed); border-color: var(--s-completed); color: #fff; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 14px; font-weight: 600; }
.list-row.done .list-title { text-decoration: line-through; color: var(--c-text-faint); }
.list-sub { font-size: 12px; color: var(--c-text-faint); margin-top: 2px; }
.list-meta { display: flex; align-items: center; gap: 8px; flex: none; }

.restore-btn { flex: none; font-size: 12.5px; padding: 6px 12px; }

.empty-state {
  text-align: center; color: var(--c-text-faint); padding: 60px 20px;
}
.empty-state .big { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ===== Calendar view ===== */
.calendar-view { flex: 1; overflow-y: auto; padding: 16px 24px 24px; display: flex; flex-direction: column; }
.cal-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav .ghost-btn { padding: 6px 12px; font-size: 14px; }
#calPrev, #calNext { font-size: 18px; line-height: 1; padding: 4px 12px; }
.cal-label { font-size: 15px; font-weight: 700; margin-left: 8px; }
.cal-modes { display: flex; gap: 3px; background: var(--c-bg); border-radius: 9px; padding: 3px; margin-left: auto; }
.cal-mode-btn {
  border: none; background: transparent; color: var(--c-text-soft);
  padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.cal-mode-btn.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }
.cal-custom { display: flex; gap: 12px; width: 100%; }
.cal-custom label { font-size: 12.5px; color: var(--c-text-soft); display: flex; align-items: center; gap: 6px; }
.cal-custom input { padding: 6px 8px; border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text); }
.cal-body { flex: 1; min-height: 0; }

/* Month grid */
.cal-month { display: flex; flex-direction: column; }
.cal-dow-row, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--c-text-faint); padding: 6px 0; }
.cal-grid { gap: 6px; }
.cal-cell {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 9px;
  min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  transition: box-shadow .12s;
}
.cal-cell:hover { box-shadow: var(--shadow-sm); }
.cal-cell.muted { background: var(--c-surface-2); opacity: .6; }
.cal-cell.today { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent) inset; }
.cal-cell-num { font-size: 12px; font-weight: 700; color: var(--c-text-soft); }
.cal-cell.today .cal-cell-num { color: var(--c-accent); }
.cal-cell-items { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }

/* Week / day columns */
.cal-cols { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 100%; }
.cal-cols-1 { grid-template-columns: 1fr; max-width: 560px; }
.cal-col { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 9px; display: flex; flex-direction: column; min-height: 160px; cursor: pointer; }
.cal-col.today { border-color: var(--c-accent); }
.cal-col-head { padding: 8px; font-size: 12px; color: var(--c-text-soft); border-bottom: 1px solid var(--c-border); text-align: center; }
.cal-col.today .cal-col-head { color: var(--c-accent); }
.cal-col-body { padding: 6px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cal-col-empty { color: var(--c-text-faint); text-align: center; font-size: 13px; padding: 10px 0; }

/* Custom range list */
.cal-list { display: flex; flex-direction: column; gap: 14px; }
.cal-list-day { display: flex; gap: 14px; align-items: flex-start; }
.cal-list-date { flex: none; width: 120px; font-size: 13px; font-weight: 700; color: var(--c-text-soft); padding-top: 4px; }
.cal-list-items { flex: 1; display: flex; flex-direction: column; gap: 4px; }

/* Task chips */
.cal-chip {
  display: flex; align-items: center; gap: 5px; width: 100%; text-align: left;
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-left: 3px solid var(--p-low);
  border-radius: 6px; padding: 3px 6px; font-size: 12px; cursor: pointer; color: var(--c-text);
  overflow: hidden;
}
.cal-chip:hover { background: var(--c-accent-soft); }
.cal-chip.prio-high { border-left-color: var(--p-high); }
.cal-chip.prio-medium { border-left-color: var(--p-medium); }
.cal-chip.gcal { border-left-color: #4285f4; background: transparent; text-decoration: none; }
.cal-chip.gcal:hover { background: rgba(66, 133, 244, .1); }
.cal-chip.done { opacity: .55; }
.cal-chip.done .cal-chip-title { text-decoration: line-through; }
.cal-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.cal-chip-time { font-weight: 700; color: var(--c-text-soft); flex: none; }
.cal-chip-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-more { border: none; background: transparent; color: var(--c-accent); font-size: 11px; font-weight: 700; cursor: pointer; padding: 2px 4px; text-align: left; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .5);
  display: grid; place-items: center; padding: 20px; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--c-surface); border-radius: 16px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-md); overflow-x: hidden; overflow-y: auto;
  max-height: calc(100dvh - 40px);
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: var(--c-surface); z-index: 2;
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--c-text-soft); }
.field input, .field textarea, .field select {
  border: 1px solid var(--c-border); background: var(--c-surface-2);
  padding: 10px 12px; border-radius: 9px; font-size: 14px;
  font-family: inherit; color: var(--c-text); width: 100%; resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--c-accent); background: var(--c-surface);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-sm { max-width: 380px; }

/* Assignee / recipient chips */
.chip.assignee-chip { background: rgba(139,92,246,.14); color: #7c3aed; }
.chip.recipient-chip { background: rgba(20,184,166,.16); color: #0d9488; }
.chip.comment-chip { background: var(--c-bg); color: var(--c-text-soft); }
.chip.comment-chip.unread { background: rgba(79,70,229,.14); color: var(--c-accent); font-weight: 700; position: relative; }
.chip.comment-chip.unread::after { content: ""; position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; background: #ef4444; border-radius: 50%; border: 1.5px solid var(--c-surface); }

/* Checkbox group (assignees / recipients) */
.check-group { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow-y: auto; border: 1px solid var(--c-border); border-radius: 9px; padding: 6px; background: var(--c-surface-2); }
.check-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.check-item:hover { background: var(--c-surface); }
.check-item input { width: 17px; height: 17px; flex: none; accent-color: var(--c-accent); }
.check-empty { font-size: 13px; color: var(--c-text-faint); padding: 4px; }
.check-tag { color: var(--c-text-faint); font-size: 11px; margin-left: 4px; }
.assigned-status { flex: none; border: 1px solid var(--c-border); background: var(--c-surface-2); color: var(--c-text); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 13px; }
.assigned-status:focus { outline: none; border-color: var(--c-accent); }
.field-help { font-size: 11.5px; color: var(--c-text-faint); }

/* Settings rows */
.setting-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.setting-row:last-child { border-bottom: none; }
.setting-text { flex: 1; min-width: 0; }
.setting-name { font-size: 14px; font-weight: 600; }
.setting-sub { font-size: 12px; color: var(--c-text-faint); margin-top: 2px; }
.setting-actions { display: flex; gap: 8px; flex: none; }
.health-results { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.health-row { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; padding: 6px 8px; border-radius: 8px; background: var(--c-bg); flex-wrap: wrap; }
.health-row.ok { color: #16a34a; }
.health-row.bad { color: var(--s-blocked); }
.health-row.note { color: var(--c-text-soft); }
.health-row small { flex-basis: 100%; color: var(--c-text-faint); }
/* Filter bar (admin task view) */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px 0; align-items: center; }
.filter-select { border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12.5px; max-width: 180px; }
.filter-select:focus { outline: none; border-color: var(--c-accent); }
.filter-clear { padding: 6px 10px; font-size: 12.5px; }
.ms { position: relative; }
.ms-btn { cursor: pointer; text-align: left; }
.ms-btn.has-value { border-color: var(--c-accent); color: var(--c-accent); font-weight: 600; }
.ms-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 200px; max-height: 260px; overflow-y: auto; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px; }
.ms-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.ms-item:hover { background: var(--c-surface-2); }
.ms-item input { width: 16px; height: 16px; accent-color: var(--c-accent); }
.ms-empty { font-size: 12.5px; color: var(--c-text-faint); padding: 6px; }
@media (max-width: 720px) { .filter-bar { padding: 10px 14px 0; } .filter-select { flex: 1 1 40%; max-width: none; } }

.settings-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--c-text-faint); font-weight: 700; margin: 14px 0 2px; }
.settings-section-label:first-child { margin-top: 0; }
/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: var(--c-border); border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--c-accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .5; cursor: default; }

/* Task extras: attachments + activity thread */
.task-extra { border-top: 1px solid var(--c-border); gap: 18px; padding-top: 16px; }
.task-section-head { font-size: 12.5px; font-weight: 700; color: var(--c-text-soft); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.att-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--c-border); background: var(--c-surface-2); color: var(--c-text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; }
.att-item:hover { border-color: var(--c-accent); }
.att-item .att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-item .att-size { color: var(--c-text-faint); font-size: 12px; }
.upload-inline { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--c-accent); padding: 6px 2px; }
.thread-list { display: flex; flex-direction: column; gap: 10px; max-height: 240px; overflow-y: auto; margin-bottom: 10px; }
.thread-empty { font-size: 13px; color: var(--c-text-faint); padding: 4px 0; }
.thread-item { font-size: 13px; }
.thread-item.sys .thread-meta { font-size: 12px; color: var(--c-text-faint); font-style: italic; }
.thread-head { display: flex; gap: 8px; align-items: baseline; }
.thread-author { font-weight: 700; }
.thread-meta { font-size: 11.5px; color: var(--c-text-faint); }
.thread-msg { margin-top: 2px; color: var(--c-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.thread-compose { display: flex; gap: 8px; }
.thread-compose input { flex: 1; min-width: 0; border: 1px solid var(--c-border); background: var(--c-surface-2); padding: 9px 11px; border-radius: 9px; font: inherit; font-size: 13.5px; color: var(--c-text); }
.thread-compose input:focus { outline: none; border-color: var(--c-accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.swatch.sel { border-color: var(--c-text); }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.modal-foot .spacer { flex: 1; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--c-text); color: var(--c-surface);
  padding: 11px 20px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 100; animation: rise .2s ease;
}
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* "Update available" banner */
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 120;
  background: var(--c-accent); color: #fff; border: none; cursor: pointer;
  padding: 12px 20px; border-radius: 24px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; box-shadow: var(--shadow-md); animation: rise .2s ease;
}
.update-banner:hover { filter: brightness(1.08); }
@media (max-width: 760px) { .update-banner { bottom: 78px; } }  /* clear the bottom nav */

/* ===== Scrollbars ===== */
.column-body::-webkit-scrollbar, .list-view::-webkit-scrollbar, .board::-webkit-scrollbar { height: 8px; width: 8px; }
.column-body::-webkit-scrollbar-thumb, .list-view::-webkit-scrollbar-thumb, .board::-webkit-scrollbar-thumb {
  background: var(--c-border); border-radius: 20px;
}

/* ===== Responsive ===== */
.theme-top { font-size: 17px; }
.refresh-btn { font-size: 17px; }   /* stays visible on mobile (unlike .theme-top) */

/* ===== Mobile bottom navigation + sheet (shown only on small screens) ===== */
.mobile-nav { display: none; }
.sheet-overlay { display: none; }

@media (max-width: 760px) {
  /* Single column, no sidebar — a real app shell with a bottom tab bar. */
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 10px 14px; }
  #viewTitle { font-size: 18px; }
  .theme-top, #newTaskBtn { display: none; }   /* handled by the bottom nav */
  #search { width: 100%; }
  .search-wrap { flex: 1; }
  .topbar-right { flex: 1; }
  .field-row { grid-template-columns: 1fr; }

  /* keep content clear of the fixed bottom bar */
  .board, .list-view, .calendar-view { padding-bottom: 86px; }
  .board { padding-left: 14px; padding-right: 14px; }
  .list-view { padding-left: 14px; padding-right: 14px; }
  .calendar-view { padding-left: 14px; padding-right: 14px; }
  .cal-modes { margin-left: 0; }
  .cal-cell { min-height: 68px; padding: 4px; }
  .cal-cell-num { font-size: 11px; }
  .cal-chip-title { display: none; }   /* month cells show dots only on phones */
  .cal-chip { justify-content: center; padding: 3px; }
  .cal-cols { grid-template-columns: 1fr; }  /* week stacks into day columns */
  .cal-list-day { flex-direction: column; gap: 4px; }
  .cal-list-date { width: auto; }
  /* Day/week/custom keep titles; only the dense month grid hides them. */
  .cal-col .cal-chip-title, .cal-list .cal-chip-title { display: inline; }
  .cal-col .cal-chip, .cal-list .cal-chip { justify-content: flex-start; }

  .mobile-nav {
    display: flex; align-items: center; justify-content: space-around;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: 62px; padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--c-surface); border-top: 1px solid var(--c-border);
    box-shadow: 0 -2px 10px rgba(16,24,40,.06);
  }
  .mnav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    border: none; background: transparent; cursor: pointer; font-family: inherit;
    color: var(--c-text-faint); padding: 8px 0; position: relative;
  }
  .mnav-btn.active { color: var(--c-accent); }
  .mnav-ico { font-size: 19px; line-height: 1; }
  .mnav-label { font-size: 10.5px; font-weight: 600; }
  .mnav-badge {
    position: absolute; top: 2px; right: 24%; background: var(--s-blocked); color: #fff;
    font-size: 9px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 10px;
    display: grid; place-items: center; padding: 0 3px;
  }
  .mnav-fab {
    flex: none; width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--c-accent); color: #fff; font-size: 26px; font-weight: 400;
    margin-top: -22px; box-shadow: var(--shadow-md); font-family: inherit;
  }

  /* Bottom sheet ("More") */
  .sheet-overlay {
    display: block; position: fixed; inset: 0; z-index: 60;
    background: rgba(16,24,40,.5); backdrop-filter: blur(2px);
  }
  .sheet-overlay[hidden] { display: none; }
  .sheet {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: var(--c-surface); border-radius: 18px 18px 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0));
    max-height: 82vh; overflow-y: auto; animation: sheetUp .2s ease;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .sheet-handle { width: 40px; height: 4px; border-radius: 3px; background: var(--c-border); margin: 6px auto 14px; }
  .sheet-section { margin-bottom: 14px; }
  .sheet-row-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--c-text-faint); font-weight: 700; padding: 0 4px 8px;
  }
  .sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .sheet-actions .ghost-btn { text-align: left; }

  /* Search gets its own row so it isn't cramped next to the view toggle. */
  .topbar-left { flex: 1; }
  .topbar-right { flex-basis: 100%; }

  /* List rows: keep the title readable, wrap the chips onto their own line. */
  .list-row { flex-wrap: wrap; gap: 12px; }
  .list-meta { flex-basis: 100%; margin-left: 42px; margin-top: 6px; flex-wrap: wrap; }

  /* Bigger, easy-to-tap complete checkbox on touch screens. */
  .list-check {
    width: 30px; height: 30px; font-size: 16px; border-radius: 9px;
    touch-action: manipulation;
  }
}
