/* ══════════════════════════════════════════════════════════════════════
   Bridge PM — design system
   Every colour, size and spacing value lives in the token block below.
   Restyling the app means editing tokens, not hunting hex codes.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Brand ─────────────────────────────────────────────────────── */
  --navy:        #0F4162;
  --navy-deep:   #09273A;
  --navy-ink:    #1C2641;
  --blue:        #567D9C;
  --steel:       #90A3B4;

  /* ── Surfaces ──────────────────────────────────────────────────── */
  --bg:          #F7F9FB;
  --surface:     #FFFFFF;
  --surface-2:   #F2F5F8;   /* recessed: inputs, table headers */
  --surface-3:   #E9EEF3;   /* hover on recessed */
  --overlay:     rgba(9, 39, 58, 0.45);

  /* ── Text ──────────────────────────────────────────────────────── */
  --text:        #16202E;
  --text-2:      #4A5A6B;   /* secondary */
  --text-3:      #7A8896;   /* tertiary / placeholder */
  --text-invert: #FFFFFF;

  /* ── Lines ─────────────────────────────────────────────────────── */
  --line:        #E2E8EE;
  --line-strong: #CBD5DF;

  /* ── Semantic. One accent (navy) carries the UI; these are for
        meaning only, never decoration. ──────────────────────────── */
  --ok:          #1F7A5C;
  --ok-bg:       #E6F4EE;
  --warn:        #A9741A;
  --warn-bg:     #FBF0DC;
  --danger:      #B03A30;
  --danger-bg:   #FBEAE7;
  --info:        #2B6CB0;
  --info-bg:     #E5EFF9;
  --purple:      #6B4E9E;
  --purple-bg:   #EEE8F7;

  /* ── Elevation. Tight and low-contrast — depth, not drop shadows. ── */
  --shadow-1: 0 1px 2px rgba(16, 32, 46, 0.06);
  --shadow-2: 0 2px 6px rgba(16, 32, 46, 0.08), 0 1px 2px rgba(16, 32, 46, 0.04);
  --shadow-3: 0 12px 32px rgba(16, 32, 46, 0.16), 0 4px 10px rgba(16, 32, 46, 0.08);
  --ring: 0 0 0 3px rgba(15, 65, 98, 0.16);

  /* ── Radii ─────────────────────────────────────────────────────── */
  --r-sm: 5px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* ── Spacing scale (4pt base) ──────────────────────────────────── */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* ── Type scale ────────────────────────────────────────────────── */
  --f-xs:  11.5px;
  --f-sm:  12.5px;
  --f-md:  13.5px;   /* body */
  --f-lg:  15px;
  --f-xl:  18px;
  --f-2xl: 24px;
  --f-3xl: 30px;
  --lh-tight: 1.3;
  --lh:       1.55;

  /* ── Layout ────────────────────────────────────────────────────── */
  --sidebar-w: 236px;
  --header-h:  56px;
  --row-h:     40px;

  --font: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Mono', Consolas, monospace;

  --speed: 140ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Density toggle — set data-density="compact" on <html> */
:root[data-density="compact"] {
  --f-md: 12.5px;
  --f-sm: 11.5px;
  --row-h: 32px;
  --s3: 8px; --s4: 12px; --s5: 14px; --s6: 18px;
}

[data-theme="dark"] {
  --navy:        #64A3CE;
  --navy-deep:   #E3EBF2;
  --navy-ink:    #E3EBF2;
  --blue:        #8FB6D2;
  --steel:       #6E8095;

  --bg:          #0D1620;
  --surface:     #16212E;
  --surface-2:   #1E2B3A;
  --surface-3:   #27364A;
  --overlay:     rgba(0, 0, 0, 0.6);

  --text:        #E3EBF2;
  --text-2:      #A6B5C4;
  --text-3:      #7C8B9C;

  --line:        #263647;
  --line-strong: #35485E;

  --ok:          #5FBF97;  --ok-bg:     #14312A;
  --warn:        #D9A85A;  --warn-bg:   #35290F;
  --danger:      #E08A80;  --danger-bg: #3A211E;
  --info:        #78ABDD;  --info-bg:   #172B40;
  --purple:      #B196DC;  --purple-bg: #26203A;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(100, 163, 206, 0.25);
  color-scheme: dark;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  font-size: var(--f-md);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; background: var(--bg); }
[x-cloak] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; flex-shrink: 0; }
code {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--surface-2); padding: 1px 5px; border-radius: var(--r-sm);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--steel); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

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

/* ══════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: var(--s6);
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(15, 65, 98, 0.10), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--s8); box-shadow: var(--shadow-3);
}
.auth-brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.auth-brand .mark {
  width: 34px; height: 34px; border-radius: var(--r); background: var(--navy);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.auth-brand .name { font-size: var(--f-lg); font-weight: 600; color: var(--navy-deep); letter-spacing: -0.2px; }
.auth-brand .sub { font-size: var(--f-xs); color: var(--text-3); }
.auth-title { font-size: var(--f-xl); font-weight: 600; color: var(--navy-deep); letter-spacing: -0.3px; }
.auth-lede { font-size: var(--f-sm); color: var(--text-2); margin-top: var(--s1); margin-bottom: var(--s6); }
.auth-form { display: flex; flex-direction: column; gap: var(--s4); }
.auth-foot {
  margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line);
  font-size: var(--f-sm); color: var(--text-2); text-align: center;
}
.auth-error {
  background: var(--danger-bg); color: var(--danger); border: 1px solid transparent;
  padding: var(--s3) var(--s4); border-radius: var(--r); font-size: var(--f-sm);
  display: flex; gap: var(--s2); align-items: flex-start;
}
.auth-note {
  background: var(--info-bg); color: var(--info); padding: var(--s3) var(--s4);
  border-radius: var(--r); font-size: var(--f-sm); line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════════
   FORM CONTROLS
   ══════════════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: var(--f-xs); font-weight: 600; color: var(--text-2);
  letter-spacing: 0.2px;
}
.field .hint { font-size: var(--f-xs); color: var(--text-3); }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="number"],
select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r);
  font-size: var(--f-md); font-family: inherit;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: var(--ring);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2); color: var(--text-3); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 72px; line-height: var(--lh); }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A8896' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input[type="color"] {
  width: 40px; height: 34px; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface);
}
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
[data-theme="dark"] input[type="date"], [data-theme="dark"] input[type="datetime-local"] {
  color-scheme: dark;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 13px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-size: var(--f-sm); font-weight: 500; white-space: nowrap;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease),
              color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--steel); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--navy); border-color: var(--navy); color: var(--text-invert);
}
[data-theme="dark"] .btn-primary { color: #0D1620; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--navy-deep); border-color: var(--navy-deep); }
[data-theme="dark"] .btn-primary:hover:not(:disabled) { filter: brightness(1.1); background: var(--navy); }
.btn-danger { color: var(--danger); border-color: transparent; background: var(--danger-bg); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-block { width: 100%; padding: 10px 16px; font-size: var(--f-md); }
.btn-sm { padding: 5px 9px; font-size: var(--f-xs); }
.btn-icon { padding: 0; width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--text-2); }
.btn-icon:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: transparent; }

/* ── Switch ────────────────────────────────────────────────────────── */
.switch {
  width: 38px; height: 21px; border-radius: var(--r-pill); background: var(--line-strong);
  position: relative; cursor: pointer; flex-shrink: 0; border: none;
  transition: background var(--speed) var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-1); transition: transform var(--speed) var(--ease);
}
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(17px); }

/* ══════════════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════════════ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh; overflow: hidden;
}

/* ── Header ────────────────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4); background: var(--surface);
  border-bottom: 1px solid var(--line); z-index: 40;
}
/* Sized to line up with the sidebar, but allowed to shrink — a fixed width
   here was what pushed the right-hand controls off-screen on smaller
   laptops and at 150% display scaling. */
.brand {
  display: flex; align-items: center; gap: var(--s2);
  flex: 0 1 auto; min-width: 0;
  width: calc(var(--sidebar-w) - var(--s4) * 2);
}
.brand .mark {
  width: 26px; height: 26px; border-radius: 6px; background: var(--navy);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.brand .name {
  font-size: var(--f-md); font-weight: 600; color: var(--navy-deep);
  letter-spacing: -0.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.search {
  display: flex; align-items: center; gap: var(--s2);
  padding: 0 var(--s3); height: 34px; min-width: 120px; max-width: 380px; flex: 1 1 120px;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r);
  color: var(--text-3); cursor: text;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.search:focus-within { border-color: var(--navy); background: var(--surface); box-shadow: var(--ring); }
.search input { border: none; background: transparent; padding: 0; flex: 1; min-width: 0; font-size: var(--f-sm); }
.search input:focus { box-shadow: none; }
.kbd {
  font-family: var(--font); font-size: 10.5px; font-weight: 500;
  padding: 2px 5px; border-radius: 4px; background: var(--surface);
  border: 1px solid var(--line); color: var(--text-3); white-space: nowrap;
}
.search .kbd { background: var(--surface); }

.topbar-right { display: flex; align-items: center; gap: var(--s2); margin-left: auto; flex-shrink: 0; }

/* Presence cluster */
.presence { display: flex; align-items: center; padding-right: var(--s2); }
.presence .avatar:not(:first-child) { margin-left: -7px; }
.presence .avatar { border: 2px solid var(--surface); }

/* Live connection dot */
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent);
}
.live-dot.off { background: var(--text-3); box-shadow: none; }
.live-dot.reconnecting { background: var(--warn); animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.35; } }

/* ── Avatars ───────────────────────────────────────────────────────── */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 600; color: #fff; letter-spacing: 0.2px;
  user-select: none; position: relative;
}
.avatar.sm { width: 21px; height: 21px; font-size: 9px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.online::after {
  content: ''; position: absolute; right: -1px; bottom: -1px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  border: 2px solid var(--surface);
}
.avatar-stack { display: flex; align-items: center; }
.avatar-stack .avatar:not(:first-child) { margin-left: -6px; }
.avatar-stack .avatar { border: 1.5px solid var(--surface); }
.avatar-more {
  width: 21px; height: 21px; border-radius: 50%; background: var(--surface-3);
  color: var(--text-2); display: grid; place-items: center; font-size: 9px; font-weight: 600;
  border: 1.5px solid var(--surface); margin-left: -6px;
}
.avatar-empty {
  width: 21px; height: 21px; border-radius: 50%;
  border: 1.5px dashed var(--line-strong); display: grid; place-items: center;
  color: var(--text-3);
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden; padding: var(--s3) var(--s2) var(--s6);
  display: flex; flex-direction: column; gap: var(--s1);
}
.nav-group { margin-bottom: var(--s4); }
.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s2) var(--s2); margin-top: var(--s2);
}
.nav-head .title {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--text-3);
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px var(--s2); border-radius: var(--r-sm);
  font-size: var(--f-md); color: var(--text-2); text-align: left;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--navy); color: var(--text-invert); font-weight: 500; }
[data-theme="dark"] .nav-item.active { color: #0D1620; }
.nav-item.active .nav-count { background: rgba(255,255,255,0.22); color: inherit; }
.nav-item .nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  font-size: var(--f-xs); font-weight: 500; padding: 1px 6px;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-3);
  min-width: 20px; text-align: center;
}
.nav-count.alert { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
/* A nav row that carries both a main action and a secondary one. Nesting a
   <button> inside a <button> is invalid HTML — the browser drops the inner
   element outright, which made the area edit pencil impossible to click. */
.nav-row { display: flex; align-items: center; border-radius: var(--r-sm); }
.nav-row:hover { background: var(--surface-2); }
.nav-row.active { background: var(--navy); }
.nav-row.active .nav-item { color: var(--text-invert); font-weight: 500; }
[data-theme="dark"] .nav-row.active .nav-item { color: #0D1620; }
.nav-row.active .nav-count { background: rgba(255,255,255,0.22); color: inherit; }
.nav-row .nav-main { flex: 1; min-width: 0; background: transparent; }
.nav-row .nav-main:hover { background: transparent; }

.nav-edit {
  opacity: 0; padding: 4px 6px; border-radius: 4px; color: inherit; flex-shrink: 0;
  transition: opacity var(--speed) var(--ease);
}
.nav-row:hover .nav-edit, .nav-item:hover .nav-edit { opacity: 0.65; }
.nav-edit:hover { opacity: 1 !important; background: rgba(128,128,128,0.2); }
.nav-edit:focus-visible { opacity: 1; }

.nav-project { padding-left: var(--s2); }
.nav-project .due { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-project .due.late { color: var(--danger); font-weight: 600; }
.nav-project .due.soon { color: var(--warn); font-weight: 500; }
.nav-add {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px var(--s2); border-radius: var(--r-sm);
  font-size: var(--f-sm); color: var(--text-3); text-align: left;
}
.nav-add:hover { background: var(--surface-2); color: var(--navy); }

.sidebar-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); }
.me-button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px var(--s2); border-radius: var(--r-sm); text-align: left;
}
.me-button:hover { background: var(--surface-2); }
.me-button .who { min-width: 0; flex: 1; }
.me-button .who .n { font-size: var(--f-sm); font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-button .who .r { font-size: 10.5px; color: var(--text-3); text-transform: capitalize; }

/* ── Main ──────────────────────────────────────────────────────────── */
.main { overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.page { padding: var(--s5) var(--s6) var(--s10); flex: 1; min-width: 0; }
.page.flush { padding: 0; display: flex; flex-direction: column; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap;
}
.page-eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 3px;
}
.page-title { font-size: var(--f-2xl); font-weight: 600; color: var(--navy-deep); letter-spacing: -0.5px; line-height: 1.15; }
.page-sub { font-size: var(--f-sm); color: var(--text-2); margin-top: 5px; }
.page-actions { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

/* ── Filter bar ────────────────────────────────────────────────────── */
.filters {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s2) var(--s3); margin-bottom: var(--s4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.filters select, .filters input[type="date"] {
  padding: 5px 8px; font-size: var(--f-sm); border-radius: var(--r-sm);
  background: var(--surface-2); border-color: transparent; width: auto;
}
.filters select { padding-right: 26px; }
.filters .sep { width: 1px; height: 18px; background: var(--line); }
.filters .fl { font-size: var(--f-xs); color: var(--text-3); font-weight: 500; }
.filter-count { font-size: var(--f-xs); color: var(--text-2); margin-left: auto; }

/* ── Segmented control / chips ─────────────────────────────────────── */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--line);
}
.segmented button {
  padding: 5px 11px; border-radius: 6px; font-size: var(--f-sm);
  color: var(--text-2); font-weight: 500; white-space: nowrap;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-1); }
[data-theme="dark"] .segmented button.active { background: var(--surface-3); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--f-xs); font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.chip.tone-ok     { background: var(--ok-bg);     color: var(--ok); }
.chip.tone-warn   { background: var(--warn-bg);   color: var(--warn); }
.chip.tone-danger { background: var(--danger-bg); color: var(--danger); }
.chip.tone-info   { background: var(--info-bg);   color: var(--info); }
.chip.tone-purple { background: var(--purple-bg); color: var(--purple); }

/* ── Tabs (view switcher) ──────────────────────────────────────────── */
.viewtabs { display: flex; gap: 1px; align-items: center; }
.viewtabs button {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 9px; border-radius: var(--r-sm);
  font-size: var(--f-sm); font-weight: 500; color: var(--text-2);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}
.viewtabs button:hover { background: var(--surface-2); color: var(--text); }
.viewtabs button.active { background: var(--surface-2); color: var(--navy); }
[data-theme="dark"] .viewtabs button.active { background: var(--surface-3); }

/* ══════════════════════════════════════════════════════════════════
   TASK ROWS
   ══════════════════════════════════════════════════════════════════ */
.section { margin-bottom: var(--s6); }
.section-head {
  display: flex; align-items: center; gap: var(--s2);
  padding-bottom: var(--s2); margin-bottom: var(--s2);
}
.section-head h3 {
  font-size: var(--f-sm); font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 7px;
}
.section-head .count {
  font-size: var(--f-xs); color: var(--text-3); font-weight: 500;
  background: var(--surface-2); padding: 1px 7px; border-radius: var(--r-pill);
}
.section-head.danger h3 { color: var(--danger); }
.section-head.danger .count { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.section-head .rule { flex: 1; height: 1px; background: var(--line); }

.task-list {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.task-row {
  display: grid;
  grid-template-columns: 22px 4px 1fr auto;
  align-items: center; gap: var(--s3);
  padding: 9px var(--s3) 9px var(--s3);
  border-bottom: 1px solid var(--line);
  cursor: pointer; position: relative;
  transition: background var(--speed) var(--ease);
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--surface-2); }
.task-row.done .task-name { color: var(--text-3); text-decoration: line-through; }
.task-row.late .task-name { color: var(--danger); }

/* Project colour: a thin bar, not a whole tinted card. */
.task-stripe { width: 3px; height: 22px; border-radius: 2px; background: var(--steel); }

.checkbox {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; flex-shrink: 0; padding: 0;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.checkbox:hover { border-color: var(--ok); }
.checkbox svg { opacity: 0; color: #fff; transition: opacity var(--speed) var(--ease); }
.checkbox.checked { background: var(--ok); border-color: var(--ok); }
.checkbox.checked svg { opacity: 1; }

.task-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-name {
  font-size: var(--f-md); color: var(--text); font-weight: 450;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.task-name > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.task-meta {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: var(--f-xs); color: var(--text-3); min-width: 0;
}
.task-meta .sep { width: 2px; height: 2px; border-radius: 50%; background: var(--line-strong); flex-shrink: 0; }
.task-meta .proj { color: var(--text-2); font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.task-side { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }

.due-tag {
  font-size: var(--f-xs); color: var(--text-2); white-space: nowrap;
  font-variant-numeric: tabular-nums; padding: 2px 7px; border-radius: var(--r-sm);
  background: var(--surface-2);
}
.due-tag.late  { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.due-tag.today { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.due-tag.soon  { color: var(--text-2); }

.status-tag {
  font-size: var(--f-xs); font-weight: 500; padding: 2px 8px;
  border-radius: var(--r-sm); white-space: nowrap;
}
.status-tag.todo           { background: var(--surface-2); color: var(--text-2); }
.status-tag.doing          { background: var(--info-bg);   color: var(--info); }
.status-tag.waiting_data   { background: var(--warn-bg);   color: var(--warn); }
.status-tag.waiting_team   { background: var(--purple-bg); color: var(--purple); }
.status-tag.waiting_client { background: var(--purple-bg); color: var(--purple); }
.status-tag.blocked        { background: var(--danger-bg); color: var(--danger); }
.status-tag.done           { background: var(--ok-bg);     color: var(--ok); }

.prio-flag { display: inline-flex; flex-shrink: 0; }
.prio-flag.urgent { color: var(--danger); }
.prio-flag.high   { color: var(--warn); }
.prio-flag.med, .prio-flag.low { display: none; }

.lock-badge { color: var(--text-3); display: inline-flex; }
.count-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--f-xs); color: var(--text-3);
}

.badge-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 1.5px 6px; border-radius: var(--r-sm); flex-shrink: 0;
}
.badge-tag.late  { background: var(--danger); color: #fff; }
.badge-tag.phase { background: var(--warn-bg); color: var(--warn); }

/* ══════════════════════════════════════════════════════════════════
   BOARD (Kanban)
   ══════════════════════════════════════════════════════════════════ */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: var(--s3); align-items: start; padding-bottom: var(--s4);
}
.board-col {
  background: var(--surface-2); border-radius: var(--r-lg);
  border: 1px solid var(--line); display: flex; flex-direction: column;
  max-height: calc(100vh - 230px);
}
.board-col.drag-over { border-color: var(--navy); background: var(--info-bg); }
.board-col-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s2);
}
.board-col-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.board-col-head .t {
  font-size: var(--f-sm); font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.board-col-head .n {
  font-size: var(--f-xs); color: var(--text-3); background: var(--surface);
  padding: 1px 6px; border-radius: var(--r-pill); margin-left: auto;
}
.board-col-body {
  padding: 0 var(--s2) var(--s2); display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; min-height: 60px; flex: 1;
}
.board-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 10px; cursor: grab;
  display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease),
              opacity var(--speed) var(--ease);
}
.board-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.board-card:active { cursor: grabbing; }
.board-card.dragging { opacity: 0.4; }
.board-card.late { border-left: 3px solid var(--danger); }
.board-card-top { display: flex; align-items: center; gap: 6px; font-size: 10.5px; }
.board-card-top .proj {
  font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.board-card-title {
  font-size: var(--f-sm); color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.board-card.done .board-card-title { text-decoration: line-through; color: var(--text-3); }
.board-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.drop-line { height: 2px; background: var(--navy); border-radius: 2px; margin: 1px 0; }

/* ══════════════════════════════════════════════════════════════════
   CALENDAR
   ══════════════════════════════════════════════════════════════════ */
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-dow div {
  padding: 7px; text-align: center; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-3);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day {
  min-height: 108px; padding: 5px 6px; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-grid > .cal-day:nth-last-child(-n+7) { border-bottom: none; }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--text-3); opacity: 0.6; }
.cal-day.weekend:not(.out) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-num {
  font-size: var(--f-xs); font-weight: 600; color: var(--text-2);
  width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%;
  font-variant-numeric: tabular-nums;
}
.cal-day.today .cal-num { background: var(--navy); color: var(--text-invert); }
[data-theme="dark"] .cal-day.today .cal-num { color: #0D1620; }
.cal-evt {
  font-size: 10.5px; padding: 2px 5px; border-radius: 4px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 2.5px solid var(--steel); background: var(--surface-2); color: var(--text-2);
}
.cal-evt:hover { filter: brightness(0.97); }
.cal-evt.late { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); font-weight: 600; }
.cal-evt.done { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); text-decoration: line-through; opacity: 0.75; }
.cal-evt.phase { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); font-weight: 600; }
.cal-more { font-size: 10px; color: var(--text-3); padding-left: 5px; cursor: pointer; }
.cal-more:hover { color: var(--navy); }

/* ══════════════════════════════════════════════════════════════════
   TIMELINE (Gantt)
   ══════════════════════════════════════════════════════════════════ */
.tl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.tl-toolbar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line);
  background: var(--surface-2); font-size: var(--f-sm); color: var(--text-2);
}
.tl-scroll { overflow: auto; max-height: calc(100vh - 250px); position: relative; }
.tl-grid { display: grid; position: relative; font-size: var(--f-xs); }
.tl-corner {
  position: sticky; left: 0; top: 0; z-index: 6;
  background: var(--surface-2); border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line); padding: 5px var(--s3);
  font-weight: 600; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.5px; font-size: 10px; display: flex; align-items: center;
}
.tl-head {
  position: sticky; top: 0; z-index: 4; background: var(--surface-2);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 4px 2px; text-align: center; color: var(--text-3); font-weight: 600;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tl-head.month {
  background: var(--surface); color: var(--navy); font-size: 10.5px;
  letter-spacing: 0.4px; border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0; z-index: 5;
}
.tl-head.weekend { background: var(--surface-3); }
.tl-head.today { background: var(--navy); color: var(--text-invert); }
[data-theme="dark"] .tl-head.today { color: #0D1620; }

.tl-label {
  position: sticky; left: 0; z-index: 3; background: var(--surface);
  border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line);
  padding: 5px var(--s3); display: flex; align-items: center; gap: 7px;
  cursor: pointer; min-width: 0; font-size: var(--f-sm);
}
.tl-label:hover { background: var(--surface-2); }
.tl-label .txt { flex: 1; min-width: 0; overflow: hidden; }
.tl-label .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tl-label .s { font-size: 10px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label.kind-project { background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.tl-label.kind-project .n { font-weight: 600; color: var(--navy-deep); }
.tl-label.kind-phase { padding-left: var(--s6); }
.tl-label.kind-task { padding-left: var(--s8); }
.tl-label.kind-task .n { color: var(--text-2); }

.tl-row { position: relative; border-bottom: 1px solid var(--line); }
.tl-row.kind-project { background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.tl-daycol { position: absolute; top: 0; bottom: 0; }
.tl-daycol.weekend { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tl-daycol.today { background: color-mix(in srgb, var(--navy) 7%, transparent); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; pointer-events: none; }

.tl-bar {
  position: absolute; height: 20px; top: 50%; transform: translateY(-50%);
  border-radius: var(--r-sm); background: var(--blue); color: #fff;
  font-size: 10.5px; font-weight: 500; padding: 0 7px;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; cursor: pointer; z-index: 1;
  box-shadow: var(--shadow-1);
  transition: filter var(--speed) var(--ease);
}
.tl-bar:hover { filter: brightness(1.08); }
.tl-bar.done { background: var(--ok); opacity: 0.8; }
.tl-bar.late { background: var(--danger); }
.tl-marker {
  position: absolute; width: 11px; height: 11px; top: 50%;
  transform: translate(-50%, -50%) rotate(45deg); background: var(--steel);
  cursor: pointer; z-index: 1; border-radius: 2px;
}
.tl-marker:hover { transform: translate(-50%, -50%) rotate(45deg) scale(1.25); }
.tl-marker.done { background: var(--ok); }
.tl-marker.late { background: var(--danger); }
.tl-legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--f-xs); color: var(--text-3); margin-top: var(--s3); }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-swatch { width: 18px; height: 10px; border-radius: 3px; }

/* ══════════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════════ */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4); display: flex; flex-direction: column; gap: 3px;
  cursor: pointer; transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.stat .l {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-3); display: flex; align-items: center; gap: 6px;
}
.stat .v { font-size: var(--f-3xl); font-weight: 600; color: var(--navy-deep); letter-spacing: -1px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat .d { font-size: var(--f-xs); color: var(--text-3); }
.stat.alert { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.stat.alert .v { color: var(--danger); }
.stat.alert .l { color: var(--danger); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: var(--s3); }
.pcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4); cursor: pointer; display: flex; flex-direction: column; gap: var(--s3);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
  border-top: 3px solid var(--pcolor, var(--steel));
}
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.pcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.pcard-title { font-size: var(--f-lg); font-weight: 600; color: var(--navy-deep); letter-spacing: -0.2px; line-height: 1.25; }
.pcard-sub { font-size: var(--f-xs); color: var(--text-3); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pcard-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.pcard-stats { display: flex; gap: var(--s3); font-size: var(--f-xs); color: var(--text-3); }
.pcard-stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.meter { height: 5px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--navy); transition: width 260ms var(--ease); }
.meter.ok > i { background: var(--ok); }
.progress-line { display: flex; align-items: center; gap: var(--s2); font-size: var(--f-xs); color: var(--text-3); }
.progress-line .meter { flex: 1; }
.progress-line .pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2); min-width: 32px; text-align: right; }

.rag { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; padding: 2.5px 8px; border-radius: var(--r-sm); }
.rag.green { background: var(--ok-bg); color: var(--ok); }
.rag.amber { background: var(--warn-bg); color: var(--warn); }
.rag.red   { background: var(--danger-bg); color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════
   ACTIVITY FEED
   ══════════════════════════════════════════════════════════════════ */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-body { min-width: 0; flex: 1; font-size: var(--f-sm); color: var(--text-2); line-height: 1.5; }
.feed-body b { color: var(--text); font-weight: 600; }
.feed-body .what { color: var(--navy); cursor: pointer; }
.feed-body .what:hover { text-decoration: underline; }
.feed-time { font-size: var(--f-xs); color: var(--text-3); white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════
   MODALS / DRAWER
   ══════════════════════════════════════════════════════════════════ */
.scrim {
  position: fixed; inset: 0; background: var(--overlay); z-index: 100;
  display: flex; backdrop-filter: blur(3px);
  animation: scrim-in 140ms var(--ease);
}
@keyframes scrim-in { from { opacity: 0; } }

.modal-wrap { margin: auto; padding: var(--s5); width: 100%; display: flex; justify-content: center; }
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  width: 100%; max-width: 520px; max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in 160ms var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
.modal.wide { max-width: 680px; }
.modal.narrow { max-width: 420px; }

.drawer {
  margin-left: auto; height: 100vh; width: 100%; max-width: 520px;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  animation: drawer-in 180ms var(--ease);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }

.modal-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.modal-title { font-size: var(--f-lg); font-weight: 600; color: var(--navy-deep); flex: 1; min-width: 0; letter-spacing: -0.2px; }
.modal-body { padding: var(--s5); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--s4); }
.modal-body.tight { gap: var(--s3); }
.modal-foot {
  display: flex; align-items: center; gap: var(--s2); justify-content: flex-end;
  padding: var(--s3) var(--s5); border-top: 1px solid var(--line);
  background: var(--surface-2); flex-shrink: 0;
}

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.form-grid .span2 { grid-column: 1 / -1; }

.setting-block { display: flex; flex-direction: column; gap: var(--s2); }
.setting-block > h4 {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.7px;
  text-transform: uppercase; color: var(--text-3);
}
.setting-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.setting-row.clickable { cursor: pointer; transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease); }
.setting-row.clickable:hover { border-color: var(--line-strong); background: var(--surface-2); }
.setting-row.selected { border-color: var(--navy); background: var(--info-bg); }
.setting-row .info { flex: 1; min-width: 0; }
.setting-row .info .t { font-size: var(--f-md); font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.setting-row .info .d { font-size: var(--f-xs); color: var(--text-3); margin-top: 2px; line-height: 1.45; }

/* Assignee picker */
.people-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.person-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 3px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface);
  font-size: var(--f-xs); color: var(--text-2); font-weight: 500;
  transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}
.person-pill:hover { border-color: var(--steel); }
.person-pill.on { border-color: var(--navy); background: var(--info-bg); color: var(--navy); }

/* Comments */
.comment { display: flex; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.comment:last-of-type { border-bottom: none; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: 2px; }
.comment-head .who { font-size: var(--f-sm); font-weight: 600; color: var(--text); }
.comment-head .when { font-size: var(--f-xs); color: var(--text-3); }
.comment-text { font-size: var(--f-sm); color: var(--text-2); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* Phase editor rows */
.phase-row {
  display: flex; align-items: center; gap: var(--s2);
  padding: 7px var(--s3); border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); border-left: 3px solid var(--steel);
}
.phase-row.doing { border-left-color: var(--info); }
.phase-row.done  { border-left-color: var(--ok); }
.phase-row.done .phase-name { color: var(--text-3); text-decoration: line-through; }
.phase-num {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--text-3);
}
.phase-row.doing .phase-num { background: var(--info); border-color: var(--info); color: #fff; }
.phase-row.done  .phase-num { background: var(--ok);   border-color: var(--ok);   color: #fff; }
.phase-name { flex: 1; min-width: 0; border: none; background: transparent; padding: 3px 5px; border-radius: var(--r-sm); font-size: var(--f-md); }
.phase-name:hover { background: var(--surface-2); }
.phase-name:focus { background: var(--surface-2); box-shadow: none; }
.phase-row input[type="date"] { width: auto; padding: 3px 7px; font-size: var(--f-xs); border-color: transparent; background: transparent; }
.phase-row input[type="date"]:hover { background: var(--surface-2); }

/* ══════════════════════════════════════════════════════════════════
   COMMAND PALETTE
   ══════════════════════════════════════════════════════════════════ */
.palette-wrap { margin: 0 auto; padding-top: 12vh; width: 100%; display: flex; justify-content: center; align-items: flex-start; }
.palette {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); overflow: hidden; display: flex; flex-direction: column;
  animation: modal-in 140ms var(--ease);
}
.palette-input {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line); color: var(--text-3);
}
.palette-input input { border: none; background: transparent; padding: 0; font-size: var(--f-lg); }
.palette-input input:focus { box-shadow: none; }
.palette-list { max-height: 380px; overflow-y: auto; padding: var(--s1); }
.palette-item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: 8px var(--s3); border-radius: var(--r-sm); text-align: left;
  font-size: var(--f-md); color: var(--text-2);
}
.palette-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.palette-item .s { font-size: var(--f-xs); color: var(--text-3); }
.palette-item.active { background: var(--surface-2); }
.palette-item.active .t { color: var(--navy); }
.palette-group {
  font-size: 10px; font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--text-3); padding: var(--s3) var(--s3) var(--s1);
}

/* ══════════════════════════════════════════════════════════════════
   MISC
   ══════════════════════════════════════════════════════════════════ */
.empty {
  padding: var(--s10) var(--s5); text-align: center; color: var(--text-3);
  font-size: var(--f-sm); background: var(--surface);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
}
.empty .icon { color: var(--line-strong); }
.empty .head { font-size: var(--f-md); color: var(--text-2); font-weight: 500; }

.banner {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r); font-size: var(--f-sm);
  background: var(--info-bg); color: var(--info); line-height: 1.5;
}
.banner.warn   { background: var(--warn-bg);   color: var(--warn); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.banner.ok     { background: var(--ok-bg);     color: var(--ok); }
.banner .b-body { flex: 1; min-width: 0; }
.banner b { font-weight: 600; }

.toast-stack {
  position: fixed; bottom: var(--s5); left: 50%; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: var(--s2);
  align-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  background: var(--navy-deep); color: #fff; padding: 9px var(--s4);
  border-radius: var(--r-pill); font-size: var(--f-sm); box-shadow: var(--shadow-3);
  animation: toast-in 180ms var(--ease); max-width: 90vw;
}
[data-theme="dark"] .toast { background: var(--surface-3); border: 1px solid var(--line-strong); }
.toast.danger { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.row { display: flex; align-items: center; gap: var(--s2); }
.col { display: flex; flex-direction: column; gap: var(--s2); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-3); }
.small { font-size: var(--f-xs); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--line); }

/* ══════════════════════════════════════════════════════════════════
   NOTIFICATIONS
   ══════════════════════════════════════════════════════════════════ */
.bell { position: relative; }
.bell .dot {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: var(--r-pill); background: var(--danger); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center;
  border: 2px solid var(--surface); box-sizing: content-box;
}
.notif-panel {
  position: absolute; top: calc(var(--header-h) - 6px); right: var(--s4);
  width: 360px; max-width: calc(100vw - 24px); max-height: 70vh;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  z-index: 80; display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in 140ms var(--ease);
}
.notif-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
  font-size: var(--f-sm); font-weight: 600; color: var(--text);
}
.notif-list { overflow-y: auto; }
.notif-item {
  display: flex; gap: var(--s3); width: 100%; text-align: left;
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
  transition: background var(--speed) var(--ease);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--info-bg) 55%, transparent); }
.notif-item .ic {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
}
.notif-item.unread .ic { background: var(--info-bg); color: var(--info); }
.notif-item .tx { flex: 1; min-width: 0; font-size: var(--f-sm); color: var(--text-2); line-height: 1.45; }
.notif-item .tm { font-size: var(--f-xs); color: var(--text-3); margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════════
   MULTI-SELECT + BULK BAR
   ══════════════════════════════════════════════════════════════════ */
.sel-box {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; padding: 0;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: #fff;
  opacity: 0; transition: opacity var(--speed) var(--ease);
}
.task-row:hover .sel-box, .sel-box.on, .selecting .sel-box { opacity: 1; }
.sel-box.on { background: var(--navy); border-color: var(--navy); }
.sel-box svg { opacity: 0; }
.sel-box.on svg { opacity: 1; }
.task-row.picked { background: var(--info-bg); }
.task-row.picked:hover { background: var(--info-bg); }

.bulkbar {
  /* Centred with auto margins, not left:50% + translate. With left:50% the
     available width for a shrink-to-fit box is only half the viewport, so the
     bar sized itself to 636px and clipped its own last three controls. */
  position: fixed; bottom: var(--s5); left: 0; right: 0;
  margin-inline: auto; width: max-content;
  z-index: 90; display: flex; align-items: center; gap: 6px;
  padding: var(--s2) var(--s3); border-radius: var(--r-lg);
  background: var(--navy-deep); color: #fff; box-shadow: var(--shadow-3);
  /* One row, never a wrapping pill — wrapped content inside a pill radius
     balloons into an unreadable blob. Overflow stays visible at desktop
     widths so normal shrink-to-fit sizes the bar to its contents; making it
     a scroll container collapses that and leaves it narrower than its own
     children. Scrolling only kicks in where it's genuinely needed. */
  flex-wrap: nowrap;
  max-width: calc(100vw - 32px);
  animation: toast-in 160ms var(--ease);
}
@media (max-width: 920px) {
  .bulkbar { overflow-x: auto; }
  .bulkbar::-webkit-scrollbar { height: 4px; }
  .bulkbar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border: none; }
}
.bulkbar > * { flex-shrink: 0; }
/* width:auto is load-bearing. The global rule sets select { width: 100% },
   which inside a shrink-to-fit flex row resolves against the container the
   selects are supposed to be sizing — so max-content came out short and the
   trailing buttons were clipped. */
.bulkbar select { width: auto; max-width: 130px; }
[data-theme="dark"] .bulkbar { background: var(--surface-3); border: 1px solid var(--line-strong); }
.bulkbar .count {
  font-size: var(--f-sm); font-weight: 600; padding: 0 var(--s2); white-space: nowrap;
}
.bulkbar select, .bulkbar .btn {
  background: rgba(255,255,255,0.12); border-color: transparent; color: #fff;
  font-size: var(--f-xs); padding: 5px 9px; height: auto;
}
[data-theme="dark"] .bulkbar select, [data-theme="dark"] .bulkbar .btn {
  background: var(--surface); color: var(--text); border-color: var(--line);
}
.bulkbar select option { color: var(--text); background: var(--surface); }
.bulkbar .btn:hover { background: rgba(255,255,255,0.22); }
.bulkbar .sep { width: 1px; height: 18px; background: rgba(255,255,255,0.22); }

/* ══════════════════════════════════════════════════════════════════
   MILESTONES · SUBTASKS · DEPENDENCIES
   ══════════════════════════════════════════════════════════════════ */
.milestone-mark {
  width: 9px; height: 9px; transform: rotate(45deg); border-radius: 1px;
  background: var(--warn); flex-shrink: 0;
}
.task-row.is-milestone .task-name { font-weight: 600; }
.task-row.is-milestone .task-stripe {
  width: 9px; height: 9px; transform: rotate(45deg); border-radius: 1px;
}

.blocked-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--f-xs); font-weight: 500;
  padding: 1px 7px; border-radius: var(--r-sm);
  background: var(--danger-bg); color: var(--danger);
}

.sub-row {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s2); border-radius: var(--r-sm);
}
.sub-row:hover { background: var(--surface-2); }
.sub-row .t { flex: 1; min-width: 0; font-size: var(--f-sm); }
.sub-row.done .t { color: var(--text-3); text-decoration: line-through; }

.rel-row {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s2); border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); font-size: var(--f-sm);
}
.rel-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-row.done .t { color: var(--text-3); text-decoration: line-through; }

.picker {
  position: relative;
}
.picker-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: var(--shadow-2);
  max-height: 220px; overflow-y: auto;
}
.picker-item {
  display: block; width: 100%; text-align: left;
  padding: 7px var(--s3); font-size: var(--f-sm); color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.picker-item:hover { background: var(--surface-2); color: var(--text); }

.link-row {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px var(--s2); border-radius: var(--r-sm); font-size: var(--f-sm);
}
.link-row:hover { background: var(--surface-2); }
.link-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════════
   WORKLOAD
   ══════════════════════════════════════════════════════════════════ */
.wl-table {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.wl-row {
  display: grid; grid-template-columns: 210px 1fr repeat(3, 78px);
  align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line);
}
.wl-row:last-child { border-bottom: none; }
.wl-row.head {
  background: var(--surface-2); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-3);
  padding-top: var(--s2); padding-bottom: var(--s2);
}
.wl-person { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.wl-person .n { font-size: var(--f-md); font-weight: 500; color: var(--text); }
.wl-person .r { font-size: var(--f-xs); color: var(--text-3); }
.wl-bar { display: flex; align-items: center; gap: 3px; height: 26px; }
.wl-seg {
  flex: 1; border-radius: 3px; background: var(--surface-3);
  height: 100%; position: relative; display: grid; place-items: center;
  font-size: 10px; font-weight: 600; color: var(--text-3);
}
.wl-seg.has { background: color-mix(in srgb, var(--navy) 22%, transparent); color: var(--navy); }
.wl-seg.hot { background: color-mix(in srgb, var(--danger) 24%, transparent); color: var(--danger); }
.wl-num { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--f-md); font-weight: 600; }
.wl-num.zero { color: var(--text-3); font-weight: 400; }
.wl-num.bad { color: var(--danger); }
.wl-num.warn { color: var(--warn); }

/* Mobile bottom nav */
.tabbar { display: none; }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE

   The topbar carries five groups (brand · view tabs · search · presence ·
   actions) and is the first thing to run out of room — especially at 150%
   Windows scaling, where a 1280px screen is only ~1272 CSS pixels wide.
   It sheds detail in stages rather than clipping the right-hand controls.
   ══════════════════════════════════════════════════════════════════ */

/* Stage 1 — view tabs lose their text, keeping recognisable icons.
   The full layout needs 1239px. 1260 keeps a ~20px margin while still leaving
   labels visible on a maximised 1280px laptop (1272 CSS px — also what a 1280
   screen at 150% Windows scaling reports). */
@media (max-width: 1260px) {
  .viewtabs button { padding: 7px 8px; }
  .viewtabs .vt-label { display: none; }
}
/* Stage 2 — drop the shortcut hint and the workspace name. */
@media (max-width: 1180px) {
  .topbar-right .kbd { display: none; }
  .brand { width: auto; }
  .brand .name { display: none; }
  .search { max-width: 260px; }
}
/* Stage 3 — the "New task" button becomes icon-only. */
@media (max-width: 1040px) {
  .hide-sm { display: none; }
  .presence { display: none; }
}

@media (max-width: 1200px) {
  .board { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 980px) {
  :root { --sidebar-w: 0px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0; width: 260px;
    z-index: 60; transform: translateX(-100%);
    transition: transform 200ms var(--ease); box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }
  .brand { width: auto; }
  .viewtabs { display: none; }
  .topbar .menu-btn { display: grid !important; }
  /* Dim the page behind the slide-out sidebar so it reads as a layer. */
  .sidebar.open::after {
    content: ''; position: fixed; inset: 0 0 0 260px;
    background: var(--overlay); z-index: -1;
  }
}
@media (max-width: 720px) {
  .page { padding: var(--s4) var(--s3) 84px; }
  .board { grid-template-columns: 1fr; }
  .board-col { max-height: none; }
  .form-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; }
  .search .kbd { display: none; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
  .drawer { max-width: none; }
  .cal-day { min-height: 74px; padding: 3px; }
  .cal-evt { font-size: 9.5px; padding: 1px 3px; }
  .stat .v { font-size: var(--f-2xl); }
  .task-side .status-tag { display: none; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; height: 60px; z-index: 70;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 10px; color: var(--text-3);
  }
  .tabbar button.active { color: var(--navy); }
  .tabbar .fab {
    background: var(--navy); color: #fff; width: 42px; height: 42px;
    border-radius: 50%; display: grid; place-items: center; box-shadow: var(--shadow-2);
  }
}

@media print {
  .topbar, .sidebar, .tabbar, .filters, .page-actions, .toast-stack { display: none !important; }
  .shell { display: block; height: auto; }
  .main { overflow: visible; }
  .task-list, .pcard, .stat { break-inside: avoid; }
}
