/* =====================================================================
   Sabhi Task Hub - styles. Mobile first; wider screens get a sidebar.
   ===================================================================== */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --border: #e3e6ee;
  --text: #161a23;
  --muted: #5d6474;
  --faint: #8a91a1;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eef0ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);

  /* status */
  --s-review: #7c3aed;   --s-review-bg: #f3e8ff;
  --s-new: #475569;      --s-new-bg: #eef1f5;
  --s-progress: #2563eb; --s-progress-bg: #e0ecff;
  --s-blocked: #dc2626;  --s-blocked-bg: #fee2e2;
  --s-done: #16a34a;     --s-done-bg: #dcfce7;
  /* priority */
  --p-urgent: #dc2626;   --p-urgent-bg: #fee2e2;
  --p-high: #ea580c;     --p-high-bg: #ffedd5;
  --p-medium: #a16207;   --p-medium-bg: #fef3c7;
  --p-low: #64748b;      --p-low-bg: #eef1f5;

  --danger: #dc2626;
  --warn: #c2410c;
  --ok: #15803d;

  --radius: 14px;
  --radius-sm: 9px;
  --topbar-h: 56px;
  --bottom-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117;
    --surface: #171b24;
    --surface-2: #1f2430;
    --border: #2a3040;
    --text: #e8eaf0;
    --muted: #a3aabb;
    --faint: #7a8296;
    --brand: #818cf8;
    --brand-ink: #0e1117;
    --brand-soft: #23264a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --s-review: #c4b5fd;   --s-review-bg: #2e2347;
    --s-new: #cbd5e1;      --s-new-bg: #262c39;
    --s-progress: #93c5fd; --s-progress-bg: #1b2b4a;
    --s-blocked: #fca5a5;  --s-blocked-bg: #451a1a;
    --s-done: #86efac;     --s-done-bg: #143322;
    --p-urgent: #fca5a5;   --p-urgent-bg: #451a1a;
    --p-high: #fdba74;     --p-high-bg: #43260f;
    --p-medium: #fde047;   --p-medium-bg: #3b3210;
    --p-low: #cbd5e1;      --p-low-bg: #262c39;
    --danger: #f87171;
    --warn: #fb923c;
    --ok: #4ade80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-word; }

.faint { color: var(--faint); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 12px 4px; }
.pad-lg { padding: 18px !important; }
.prewrap { white-space: pre-wrap; word-break: break-word; margin: 0; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.row-between p { margin: 0; flex: 1 1 240px; }

/* ---------- loading ---------- */
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 14px;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { min-height: 50px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--muted); position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--danger); }
.file-btn { cursor: pointer; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], input:not([type]), input[inputmode],
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface);
  font-size: 16px; /* 16px stops iPhone zooming in */
}
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
.invalid { border-color: var(--danger) !important; outline-color: var(--danger) !important; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.hint summary { cursor: pointer; margin-bottom: 8px; }
.hint textarea { margin-bottom: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.check-row { display: flex; gap: 10px; align-items: center; margin: 8px 0 14px; font-size: 14px; }
.check-row input { width: 20px; height: 20px; accent-color: var(--brand); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
}
.seg-item input:checked + span { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg-item.prio-urgent input:checked + span { background: var(--p-urgent); border-color: var(--p-urgent); color: #fff; }
.seg-item.prio-high input:checked + span { background: var(--p-high); border-color: var(--p-high); color: #fff; }
.seg-item.prio-medium input:checked + span { background: #eab308; border-color: #eab308; color: #1c1917; }
.seg-item.prio-low input:checked + span { background: var(--p-low); border-color: var(--p-low); color: #fff; }
.seg-item input:focus-visible + span { outline: 2px solid var(--brand); }
.seg-sm { background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; }
.seg-btn { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- chips / pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.prio-urgent { background: var(--p-urgent-bg); color: var(--p-urgent); }
.chip.prio-high   { background: var(--p-high-bg);   color: var(--p-high); }
.chip.prio-medium { background: var(--p-medium-bg); color: var(--p-medium); }
.chip.prio-low    { background: var(--p-low-bg);    color: var(--p-low); }
.chip-danger { background: var(--s-blocked-bg); color: var(--s-blocked); }
.chip-ok { background: var(--s-done-bg); color: var(--s-done); }
.chip-warn { background: var(--p-high-bg); color: var(--p-high); }
.chip.role-admin { background: var(--brand-soft); color: var(--brand); }
.chip.role-lead { background: var(--s-progress-bg); color: var(--s-progress); }
.chip-x button { border: 0; background: none; padding: 0; display: grid; color: inherit; }
.chip-x svg { width: 14px; height: 14px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 8px 0 11px; border-radius: 999px;
  border: 0; font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
span.status-pill { padding-right: 11px; }
.status-pill svg { width: 15px; height: 15px; opacity: .7; }
.s-to_review   { background: var(--s-review-bg);   color: var(--s-review); }
.s-not_started { background: var(--s-new-bg);      color: var(--s-new); }
.s-in_progress { background: var(--s-progress-bg); color: var(--s-progress); }
.s-blocked     { background: var(--s-blocked-bg);  color: var(--s-blocked); }
.s-done        { background: var(--s-done-bg);     color: var(--s-done); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.s-to_review { background: var(--s-review); }
.status-dot.s-not_started { background: var(--s-new); }
.status-dot.s-in_progress { background: var(--s-progress); }
.status-dot.s-blocked { background: var(--s-blocked); }
.status-dot.s-done { background: var(--s-done); }

.dept-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dept-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.due { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.due svg { width: 14px; height: 14px; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--warn); }

.avatar {
  --size: 28px;
  width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0;
  display: inline-grid; place-items: center; color: #fff; font-weight: 700;
  font-size: calc(var(--size) * .4); letter-spacing: .02em; vertical-align: middle;
}
.avatar.empty { background: var(--surface-2); color: var(--faint); border: 1px dashed var(--border); }

.count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.count.bad { background: var(--s-blocked-bg); color: var(--s-blocked); }

/* ---------- callouts ---------- */
.callout { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 12px 0; }
.callout.danger { background: var(--s-blocked-bg); color: var(--s-blocked); }
.callout.warn { background: var(--p-medium-bg); color: var(--p-medium); }
.callout.ok { background: var(--s-done-bg); color: var(--s-done); }

/* ---------- login ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 26px 22px; box-shadow: var(--shadow-lg); }
.auth-card h2 { margin: 18px 0 6px; }
.auth-card form { margin-top: 16px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 14px; font-weight: 600; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 10px; }
.brand-name { font-weight: 750; font-size: 17px; }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.topbar-brand img { border-radius: 8px; }
.demo-tag { display: none; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; background: var(--p-medium-bg); color: var(--p-medium); padding: 3px 8px; border-radius: 6px; }
body.demo .demo-tag { display: inline-block; }
.bell .badge {
  position: absolute; top: 5px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center;
  border: 2px solid var(--bg);
}
.me-btn { border: 0; background: none; padding: 4px; border-radius: 50%; }

.view {
  padding: 16px 16px calc(var(--bottom-h) + var(--safe-b) + 90px);
  max-width: 920px; margin: 0 auto;
}
.view-board { max-width: none; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(var(--n, 4), 1fr);
  height: calc(var(--bottom-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav .nav-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11.5px; font-weight: 650;
}
.bottom-nav .nav-link.active { color: var(--brand); }
.bottom-nav .nav-link svg { width: 23px; height: 23px; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--bottom-h) + var(--safe-b) + 16px); z-index: 21;
  height: 56px; min-width: 56px; padding: 0 18px; border-radius: 18px; border: 0;
  background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow-lg);
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px;
}
.fab svg { width: 24px; height: 24px; }
.fab span { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 18px; grid-row: 1 / span 2;
    position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0 8px; }
  .sidebar .brand-name { font-size: 15px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav .nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
    color: var(--muted); font-weight: 600;
  }
  .side-nav .nav-link:hover { background: var(--surface-2); }
  .side-nav .nav-link.active { background: var(--brand-soft); color: var(--brand); }
  .topbar { grid-column: 2; padding-left: 24px; }
  .topbar-brand { display: none; }
  .view { grid-column: 2; padding: 24px 28px 100px; width: 100%; }
  .bottom-nav { display: none; }
  .fab { bottom: 28px; right: 28px; }
  .fab span { display: inline; }
}

/* ---------- page heads ---------- */
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }

/* ---------- My Tasks ---------- */
.hero { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.hero-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.hero h1 { margin-top: 2px; }
.week-count { text-align: center; background: var(--s-done-bg); color: var(--s-done); border-radius: 12px; padding: 6px 12px; line-height: 1.1; }
.week-count b { display: block; font-size: 24px; }
.week-count span { font-size: 11px; font-weight: 700; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-2); margin: 16px 0 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #22c55e); transition: width .5s; }
.hero-sub { font-size: 13px; }

.all-done {
  display: flex; gap: 14px; align-items: center; padding: 16px; margin-bottom: 16px;
  border-radius: var(--radius); background: var(--s-done-bg); color: var(--s-done);
}
.all-done .faint { color: inherit; opacity: .8; }
.all-done-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--s-done); color: #fff; display: grid; place-items: center; }
.all-done-icon svg { width: 26px; height: 26px; }

.task-section { margin-bottom: 20px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 8px 2px; color: var(--muted); }
.task-section.is-overdue .section-title { color: var(--danger); }
.section-title.toggle { border: 0; background: none; padding: 6px 2px; width: 100%; font-weight: 650; }
.chev { display: inline-grid; transition: transform .2s; }
.chev.open { transform: rotate(180deg); }

/* ---------- task card ---------- */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-card {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px 6px 4px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid transparent; transition: opacity .3s;
}
.task-card.p-urgent { border-left-color: var(--p-urgent); }
.task-card.p-high { border-left-color: var(--p-high); }
.task-card.p-medium { border-left-color: #eab308; }
.task-card.is-done .task-title { text-decoration: line-through; color: var(--faint); }
.task-card.just-done { opacity: .5; }
.check {
  flex-shrink: 0; width: 44px; height: 44px; border: 0; background: none; display: grid; place-items: center; color: transparent;
  position: relative;
}
.check::before { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); transition: all .15s; }
.check:hover::before { border-color: var(--s-done); }
.check svg { position: relative; width: 15px; height: 15px; stroke-width: 3; }
.check:hover svg { color: var(--s-done); }
.check.checked::before { background: var(--s-done); border-color: var(--s-done); }
.check.checked svg { color: #fff; }
.check.placeholder { pointer-events: none; }
.check.placeholder::before { border-style: dashed; opacity: .5; }
.task-main { flex: 1; min-width: 0; padding: 8px 4px; color: inherit; }
.task-title { font-weight: 600; word-break: break-word; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; }
.meta-text { font-size: 13px; color: var(--muted); }
.blocked-note { color: var(--danger); flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ---------- board ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin: 0 -16px 6px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters > * { flex-shrink: 0; }
.filter { width: auto; min-height: 38px; padding: 6px 30px 6px 12px; font-size: 14px; border-radius: 999px; }
.filter.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.search { display: flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--faint); }
.search input { border: 0; min-height: 36px; padding: 0; width: 140px; background: none; font-size: 14px; }
.search input:focus { outline: none; }
.filters .chip { height: 38px; padding: 0 12px; font-size: 13px; }

.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(86vw, 320px); gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px;
}
.column { scroll-snap-align: start; background: var(--surface-2); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 700; font-size: 14px; }
.column-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 12px; flex: 1; min-height: 80px; }
.column .task-card { box-shadow: var(--shadow); }
.column .task-card[data-draggable] { cursor: grab; }
.column .task-side .status-pill { display: none; }
.column-empty { text-align: center; color: var(--faint); font-size: 13px; padding: 24px 0; }
.column-more { text-align: center; padding: 0 0 12px; font-size: 13px; }
.drag-ghost { opacity: .35; }
@media (min-width: 900px) {
  .board { grid-auto-columns: minmax(250px, 1fr); margin: 0; padding: 0 0 8px; scroll-snap-type: none; }
  .filters { margin: 0 0 6px; padding: 0 0 10px; flex-wrap: wrap; overflow: visible; }
}

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 6px 18px calc(18px + var(--safe-b));
  transform: translateY(100%); transition: transform .22s ease-out; box-shadow: var(--shadow-lg);
}
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; position: sticky; bottom: calc(-18px - var(--safe-b)); background: var(--surface); padding: 10px 0 4px; }
.sheet-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 460px; border-radius: 20px; padding: 18px 22px 22px;
           transform: translate(-50%, -46%); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet.wide { width: 620px; }
  .sheet-wrap.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-handle { display: none; }
  .sheet-actions .btn { flex: 0 0 auto; min-width: 110px; }
}

.status-list { display: flex; flex-direction: column; gap: 6px; }
.status-option { display: flex; align-items: center; justify-content: space-between; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.status-option:hover { background: var(--surface-2); }
.status-option.current { border-color: var(--brand); }
.status-option .status-pill { height: 32px; font-size: 14px; padding: 0 14px; }

.profile { display: flex; gap: 14px; align-items: center; margin: 8px 0 16px; }
.menu { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 14px 4px; border-bottom: 1px solid var(--border); font-weight: 600; }
.menu .danger { color: var(--danger); }

.notif-list { display: flex; flex-direction: column; }
.notif { display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 6px; border: 0; border-bottom: 1px solid var(--border); background: none; }
.notif.unread { background: var(--brand-soft); border-radius: 10px; }
.notif-icon { font-size: 18px; line-height: 1.3; }
.notif-msg { display: block; font-weight: 550; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-h) + var(--safe-b) + 84px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); transition: all .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: var(--danger); color: #fff; }
.toast-action { border: 0; background: none; color: var(--brand); font-weight: 800; padding: 4px; }
.toast.error .toast-action { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast-action { color: #4f46e5; } }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- task detail ---------- */
.detail-top { display: flex; align-items: center; gap: 8px; margin: -6px -6px 10px; }
.detail-title { font-size: 22px; word-break: break-word; }
.detail-status { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 4px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; margin: 16px 0; box-shadow: var(--shadow); }
.facts > div { background: var(--surface); padding: 10px 14px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--faint); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; word-break: break-word; }
.block { margin: 18px 0; }
blockquote { margin: 0; padding: 10px 14px; border-left: 3px solid #25d366; background: var(--surface); border-radius: 0 10px 10px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 20px 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs > * { border: 0; background: none; padding: 10px 12px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs > .active { color: var(--brand); border-bottom-color: var(--brand); }
.comments { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.comment { display: flex; gap: 10px; }
.comment-body { background: var(--surface); padding: 8px 12px; border-radius: 4px 14px 14px 14px; box-shadow: var(--shadow); min-width: 0; flex: 1; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(var(--bottom-h) + var(--safe-b) + 8px); }
@media (min-width: 900px) { .comment-form { bottom: 12px; } }
.comment-form textarea { min-height: 44px; max-height: 160px; }
.activity { list-style: none; margin: 0; padding: 0 0 0 6px; border-left: 2px solid var(--border); }
.activity li { position: relative; display: flex; gap: 10px; padding: 0 0 14px 14px; font-size: 14px; }
.act-dot { position: absolute; left: -7px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--bg); }
.val { font-weight: 650; }
.empty-state { text-align: center; padding: 48px 16px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .tiles { grid-template-columns: repeat(6, 1fr); } }
.tile { background: var(--surface); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); color: inherit; border-top: 3px solid var(--border); }
.tile-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.tile.t-red { border-top-color: var(--danger); } .tile.t-red .tile-value { color: var(--danger); }
.tile.t-orange { border-top-color: var(--p-high); } .tile.t-orange .tile-value { color: var(--p-high); }
.tile.t-blue { border-top-color: var(--s-progress); }
.tile.t-green { border-top-color: var(--s-done); } .tile.t-green .tile-value { color: var(--s-done); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 16px; min-width: 0; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.grid-cards { display: grid; gap: 16px; }
@media (min-width: 1000px) { .grid-cards { grid-template-columns: 1fr 1fr; } }
.grid-cards .card { margin: 0; }
.task-list.compact .task-card { box-shadow: none; border: 1px solid var(--border); border-left-width: 4px; }
.more-link { display: block; text-align: center; padding: 10px; font-weight: 600; font-size: 14px; }
.table-scroll { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--faint); font-weight: 650; padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.stats td:first-child { font-weight: 600; position: sticky; left: 0; background: var(--surface); }
.stats td:first-child a { color: inherit; display: inline-flex; align-items: center; gap: 6px; }
.stats td:not(:first-child), .stats th:not(:first-child) { text-align: center; }
.stats .zero { color: var(--border); }
.stats .bad { color: var(--danger); font-weight: 800; }
.stats .warn { color: var(--p-high); font-weight: 800; }
.pct-col { min-width: 110px; }
td.pct-col { display: flex; align-items: center; gap: 8px; }
.mini-bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.mini-bar div { height: 100%; background: var(--s-done); }

/* ---------- settings ---------- */
.list-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; }
.list-row:last-child { border-bottom: 0; }
button.list-row:hover { background: var(--surface-2); }
.list-row.inactive { opacity: .5; }
.list-row input[type=color] { width: 30px; height: 30px; padding: 0; border: 0; background: none; border-radius: 50%; }
.row-title { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.summary { padding-left: 20px; margin: 8px 0 12px; }
.summary li { margin-bottom: 4px; }
.preview td { white-space: normal; min-width: 80px; vertical-align: top; }
.preview td:nth-child(2) { min-width: 220px; }
.warn-row { background: var(--p-high-bg); }
.dup-row td { color: var(--faint); }
.card + .card { margin-top: 16px; }
.btn-block + .btn-block { margin-top: 8px; }
#import-preview { margin-top: 16px; }

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

/* ---------- department view ---------- */
.dept-head .dept-name { color: inherit; flex: 1; }
.dept-flags { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 6px; }
.dept-people { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.person-pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px; border-radius: 999px; background: var(--surface); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow); }
.person-pill b { color: var(--brand); }
@media (min-width: 900px) { .dept-board { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); } }
