/* ==========================================================================
   Procodify — design system
   Calm Linear/Notion surfaces + colorful accents on data.
   ========================================================================== */

/* Sidebar typeface: Plus Jakarta Sans (variable, self-hosted for CSP) */
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/plus-jakarta-sans-latin-ext.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/plus-jakarta-sans-latin.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font-display: "Plus Jakarta Sans", var(--font);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f7f7f8;
  --bg-sidebar: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --surface-3: #eaeaee;
  --border: #e6e6ea;
  --border-strong: #d4d4da;
  --text: #17171c;
  --text-2: #55555f;
  --text-3: #8b8b96;
  --accent: #1281c2;
  --accent-hover: #0e6fae;
  --accent-soft: #e4f3fb;
  --accent-text: #ffffff;
  --ring: rgba(24, 144, 210, .32);
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .05);
  --shadow: 0 1px 3px rgba(16, 16, 24, .06), 0 6px 16px -6px rgba(16, 16, 24, .08);
  --shadow-lg: 0 24px 60px -12px rgba(16, 16, 24, .25), 0 0 0 1px rgba(16, 16, 24, .06);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --sidebar-w: 236px;

  /* tones: bg / fg */
  --t-gray-bg: #f0f0f3;   --t-gray-fg: #5c5c66;
  --t-blue-bg: #e7f0ff;   --t-blue-fg: #1d5bd8;
  --t-green-bg: #e3f7ea;  --t-green-fg: #16803c;
  --t-amber-bg: #fff3dc;  --t-amber-fg: #a35a00;
  --t-red-bg: #ffe8e8;    --t-red-fg: #c62828;
  --t-violet-bg: #f0eaff; --t-violet-fg: #6b3fd4;
  --t-teal-bg: #ddf6f3;   --t-teal-fg: #0f766e;
  color-scheme: light;
}

/* theme.js always sets data-theme (stored choice, else system preference) before first paint */
:root[data-theme="dark"] {
  --bg: #0f0f12;
  --bg-sidebar: #131317;
  --surface: #18181d;
  --surface-2: #1f1f25;
  --surface-3: #2a2a31;
  --border: #2a2a31;
  --border-strong: #3a3a43;
  --text: #ececf1;
  --text-2: #a8a8b3;
  --text-3: #72727e;
  --accent: #2fa3dc;
  --accent-hover: #45b1e6;
  --accent-soft: #0f2c40;
  --ring: rgba(47, 163, 220, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 20px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06);
  --t-gray-bg: #26262d;   --t-gray-fg: #b4b4be;
  --t-blue-bg: #14264a;   --t-blue-fg: #8ab4ff;
  --t-green-bg: #12301f;  --t-green-fg: #6fdc95;
  --t-amber-bg: #3a2a0c;  --t-amber-fg: #ffc061;
  --t-red-bg: #3d1517;    --t-red-fg: #ff8a8a;
  --t-violet-bg: #2a1d4d; --t-violet-fg: #bba2ff;
  --t-teal-bg: #0f322f;   --t-teal-fg: #5fd8c9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
/* URLs in free text (linkify()) */
a.text-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
a.text-link:hover { text-decoration-thickness: 2px; }
a.link { color: var(--accent); }
a.link:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.icon { flex: none; display: block; }
[x-cloak] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus:not(:focus-visible) { outline: none; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}
/* Sidebar: calm light surface, brand blue only where it means something */
.sidebar {
  background:
    radial-gradient(140% 220px at 0% 0%, color-mix(in srgb, #29abe1 13%, transparent), transparent 70%),
    radial-gradient(120% 180px at 100% 100%, color-mix(in srgb, #f7921e 9%, transparent), transparent 70%),
    var(--bg-sidebar);
}
.sidebar { font-family: var(--font-display); }
.sidebar .brand { padding: 6px 8px 18px; font-size: 16.5px; font-weight: 800; letter-spacing: -.035em; }
.sidebar .search-trigger { font-family: var(--font-display); font-weight: 500; }
.sidebar .nav a { font-size: 13.5px; font-weight: 550; letter-spacing: -.008em; }
.sidebar .nav a.active { font-weight: 650; }
.sidebar .nav-label { font-size: 10.5px; font-weight: 650; letter-spacing: .1em; }
.sidebar-foot .who b { font-weight: 650; letter-spacing: -.01em; }
.sidebar-foot .who span { font-weight: 500; }
.sidebar .nav { display: grid; gap: 1px; }
.sidebar .nav a { position: relative; }
.sidebar .nav a .icon { color: var(--text-3); transition: color .12s; }
.sidebar .nav a:hover .icon { color: var(--text-2); }
.sidebar .nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar .nav a.active .icon { color: var(--accent); }
.sidebar .nav a.active::before {
  content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(180deg, #29abe1, var(--accent));
}
.sidebar .nav .count { min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center; font-size: 11px; font-weight: 600; line-height: 18px; background: var(--accent-soft); color: var(--accent); }
.sidebar .nav-label { color: var(--text-3); }
.sidebar-foot .btn-sm.btn-icon { color: var(--text-3); width: 26px; }
.sidebar-foot > a.row { gap: 8px; }
.sidebar-foot .btn-icon:hover { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; }
.brand-logo { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-3); font: inherit; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger kbd { margin-left: auto; }
kbd {
  font: 11px var(--mono); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3);
}
.nav-label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.active .icon { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.sidebar-foot { margin-top: auto; padding: 7px 4px 7px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 2px; }
.sidebar-foot .who { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { font-size: 11.5px; color: var(--text-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13.5px; min-width: 0; }
.crumbs a:hover { color: var(--text); }
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.crumb > .icon { flex: none; }
.crumb a, .crumbs b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs b { color: var(--text); font-weight: 600; }
.crumbs-back { display: none; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; margin-left: -6px; border-radius: 8px; color: var(--text-2); }
.crumbs-back:hover { background: var(--surface-2); color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 24px 28px 64px; max-width: 1440px; width: 100%; }
/* Long URLs, e-mails and paths must wrap instead of widening the page on phones */
.content { overflow-wrap: break-word; }
.content pre { overflow-wrap: anywhere; }
input[type="file"] { max-width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.page-head > :first-child, .page-head > :first-child > div { min-width: 0; }
.page-head h1, .page-head p { overflow-wrap: anywhere; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus, .select:focus, .textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--t-red-fg); }
.btn-danger:hover { background: var(--t-red-bg); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.empty { padding: 36px 18px; text-align: center; color: var(--text-3); }
.empty .icon { margin: 0 auto 10px; opacity: .6; }

.grid { display: grid; gap: 16px; }
.grid > *, .stack > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }

/* ---------- KPI tiles (the colorful part) ---------- */
/* Dashboard welcome banner — same brand canvas as the login hero */
.page-head.welcome {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 24px 26px; border-radius: var(--radius-lg); color: #fff;
  background:
    radial-gradient(55% 120% at 100% 100%, rgba(247, 146, 30, .4), transparent 70%),
    linear-gradient(155deg, #0e6fae 0%, #1890d2 50%, #29abe1 100%);
  box-shadow: 0 12px 30px -16px rgba(14, 111, 174, .7);
}
.page-head.welcome::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(90deg, transparent 20%, #000);
          mask-image: linear-gradient(90deg, transparent 20%, #000);
}
.page-head.welcome h1 { color: #fff; }
.page-head.welcome p { color: rgba(255, 255, 255, .82); }
.page-head.welcome .btn { background: rgba(6, 42, 72, .32); border-color: rgba(255, 255, 255, .45); color: #fff; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .35); backdrop-filter: blur(8px); }
.page-head.welcome .btn:hover { background: rgba(6, 42, 72, .45); border-color: rgba(255, 255, 255, .6); }
.page-head.welcome .btn-solid { background: #fff; border-color: #fff; color: #0e6fae; text-shadow: none; }
.page-head.welcome .btn-solid:hover { background: #eaf6fd; border-color: #eaf6fd; }
.page-head.welcome kbd { background: rgba(255, 255, 255, .9); color: #0e4f7d; border-color: transparent; font-weight: 600; text-shadow: none; }

/* Quick "new task" picker */
.pick-search { position: relative; }
.pick-search > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.pick-search .input { padding-left: 34px; }
.pick-group { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 12px 4px 6px; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); }
.pick-row:hover, .pick-row:focus-visible { background: var(--surface-2); outline: none; }
.pick-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-row .title { font-weight: 550; }
.pick-row > .icon { color: var(--text-3); }
.pick-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.pick-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; }

.kpi {
  position: relative; overflow: hidden;
  padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 100% 0%, var(--kpi-glow, transparent) 0%, transparent 55%);
  opacity: .9; pointer-events: none;
}
.kpi > * { position: relative; }
.kpi-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--kpi-bg); color: var(--kpi-fg); }
.kpi-label { margin-top: 12px; color: var(--text-2); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kpi[data-tone="blue"]   { --kpi-bg: var(--t-blue-bg);   --kpi-fg: var(--t-blue-fg);   --kpi-glow: color-mix(in srgb, var(--t-blue-fg) 14%, transparent); }
.kpi[data-tone="green"]  { --kpi-bg: var(--t-green-bg);  --kpi-fg: var(--t-green-fg);  --kpi-glow: color-mix(in srgb, var(--t-green-fg) 14%, transparent); }
.kpi[data-tone="amber"]  { --kpi-bg: var(--t-amber-bg);  --kpi-fg: var(--t-amber-fg);  --kpi-glow: color-mix(in srgb, var(--t-amber-fg) 14%, transparent); }
.kpi[data-tone="red"]    { --kpi-bg: var(--t-red-bg);    --kpi-fg: var(--t-red-fg);    --kpi-glow: color-mix(in srgb, var(--t-red-fg) 14%, transparent); }
.kpi[data-tone="violet"] { --kpi-bg: var(--t-violet-bg); --kpi-fg: var(--t-violet-fg); --kpi-glow: color-mix(in srgb, var(--t-violet-fg) 14%, transparent); }
.kpi[data-tone="teal"]   { --kpi-bg: var(--t-teal-bg);   --kpi-fg: var(--t-teal-fg);   --kpi-glow: color-mix(in srgb, var(--t-teal-fg) 14%, transparent); }
.kpi-of { font-size: 16px; font-weight: 500; color: var(--text-3); }
/* Segmented progress bars (dashboard). Segments grow in; "live" segments (problems) stripe + pulse. */
.kpi-bar { display: flex; gap: 2px; height: 8px; margin-top: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.kpi-bar.sm { height: 4px; margin-top: 8px; }
.kpi-bar.lg { height: 14px; margin: 12px 0 14px; }
.kpi-bar > span { width: var(--w); flex: none; animation: bar-grow 1.1s cubic-bezier(.2, .8, .2, 1) both; }
.kpi-bar > span:first-child { border-radius: 999px 0 0 999px; }
.kpi-bar > span:last-child { border-radius: 0 999px 999px 0; }
.kpi-bar > span:only-child { border-radius: 999px; }
.kpi-bar + .kpi-sub { margin-top: 8px; }
.seg-green  { background: var(--t-green-fg); }
.seg-blue   { background: var(--t-blue-fg); }
.seg-teal   { background: var(--t-teal-fg); }
.seg-violet { background: var(--t-violet-fg); }
.seg-amber  { background: var(--t-amber-fg); }
.seg-red    { background: #ef4444; }
.seg-gray   { background: var(--t-gray-fg); opacity: .45; }
.kpi-bar > span.live {
  min-width: 6px;
  background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .32) 0 6px, transparent 6px 12px);
  background-size: 17px 17px;
  animation: bar-grow 1.1s cubic-bezier(.2, .8, .2, 1) both, bar-stripes .8s linear infinite, bar-pulse 1.6s ease-in-out infinite;
}
@keyframes bar-grow { from { width: 0; } }
@keyframes bar-stripes { to { background-position: 17px 0; } }
@keyframes bar-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .kpi-bar > span, .kpi-bar > span.live { animation: none; } }
/* Dashboard top row: charts (8/12) + 2×2 compact KPIs (4/12), same proportion as .grid-main */
.dash-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-charts { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.card-fill { display: flex; flex-direction: column; }
.card-fill .card-body { flex: 1; display: flex; flex-direction: column; }
.card-fill .chart-box { flex: 1; height: auto; min-height: 190px; max-height: 260px; }
/* Dashboard three-day agenda (today + 2) */
.dash-agenda { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 190px; }
.dash-agenda-day { display: flex; flex-direction: column; gap: 8px; padding: 10px 8px; min-width: 0; }
.dash-agenda-day + .dash-agenda-day { border-left: 1px solid var(--border); }
.dash-agenda-day.is-today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.dash-agenda-head { display: flex; align-items: center; gap: 4px; }
.dash-agenda-head .small { flex: 1; font-weight: 600; }
.dash-agenda-day.is-today .cal-date { background: var(--accent); color: #fff; }
.dash-agenda-day:hover .cal-add { opacity: 1; }
.dash-agenda .cal-tasks { max-height: 240px; overflow-y: auto; }
.dash-agenda .cal-task { align-items: flex-start; font-size: 11.5px; }
.dash-agenda .cal-task .icon { margin-top: 2px; }
.dash-agenda .clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.dash-agenda-empty { padding: 2px; opacity: .7; }
.kpi-quad { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi.compact { padding: 14px 16px; display: flex; flex-direction: column; }
.kpi.compact .kpi-icon { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; border-radius: 8px; }
.kpi.compact .kpi-label { margin-top: 0; padding-right: 30px; font-size: 12.5px; }
.kpi.compact .kpi-value { margin-top: 6px; font-size: 24px; }
.kpi.compact .kpi-bar { margin-top: auto; }
.kpi.compact .kpi-value + .kpi-bar { margin-top: 14px; }
.kpi.compact .kpi-sub { font-size: 11.5px; }
@media (max-width: 1240px) { .dash-charts { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) {
  .dash-top { grid-template-columns: minmax(0, 1fr); }
  .kpi-quad { order: -1; }
  .dash-charts { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .kpi-quad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .dash-charts { grid-template-columns: minmax(0, 1fr); }
  .kpi-quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.legend-list { display: grid; gap: 2px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; font-size: 13.5px; }
.legend-row:hover { background: var(--surface-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Reorderable card grids */
[data-reorder] > [data-id] { cursor: grab; user-select: none; -webkit-user-drag: none; }
[data-reorder] > [data-id]:active { cursor: grabbing; }
[data-reorder].is-reordering > [data-id] { transition: transform .18s; }
[data-reorder] .sortable-ghost { opacity: .25; outline: 2px dashed var(--accent); outline-offset: -2px; }
[data-reorder] .sortable-chosen { box-shadow: var(--shadow); }
/* Drag hint icon */
.drag-handle { margin-left: auto; padding: 4px; border-radius: 6px; color: var(--text-3); cursor: grab; opacity: .55; transition: opacity .12s, background .12s; }
.kpi:hover .drag-handle { opacity: 1; }
.drag-handle:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Badges, avatars, dots ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--b-bg); color: var(--b-fg);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
/* Badge-looking status picker (inline edit in tables); sits above stretched row links */
select.badge.status-select {
  position: relative; z-index: 1; appearance: none; -webkit-appearance: none; border: 0; cursor: pointer; font-family: inherit;
  padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 11px center, right 7px center; background-size: 4px 4px; background-repeat: no-repeat; background-color: var(--b-bg);
}
select.badge.status-select:hover { filter: brightness(.96); }
select.badge.status-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select.badge.status-select option { background: var(--surface); color: var(--text); }
.htmx-request select.status-select, select.status-select.htmx-request { opacity: .6; }
/* Status picker as badges (task modal): radios styled as pills, unselected ones muted */
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; min-height: 40px; align-items: center; }
.status-pick .badge { display: inline-flex; margin: 0; font-weight: 550; height: 28px; padding: 0 11px; font-size: 13px; cursor: pointer; background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); transition: background .12s, color .12s, box-shadow .12s; }
.status-pick .badge::before { background: var(--b-fg); }
.status-pick .badge:hover { background: var(--surface-2); color: var(--text); }
.status-pick .badge:has(:checked) { background: var(--b-bg); color: var(--b-fg); box-shadow: inset 0 0 0 1.5px var(--b-fg); }
.status-pick .badge:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.status-pick input { position: absolute; opacity: 0; pointer-events: none; }
.htmx-request .status-pick { opacity: .6; }
/* Person picker: radio chips with avatar (task assignee) */
.person-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.field .person-pick label { display: inline-flex; align-items: center; gap: 6px; margin: 0; height: 30px; padding: 0 11px 0 4px; border-radius: 999px; font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer; box-shadow: inset 0 0 0 1px var(--border); transition: background .12s, color .12s, box-shadow .12s; }
.field .person-pick label:hover { background: var(--surface-2); color: var(--text); }
.field .person-pick label:has(:checked) { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--accent); }
.field .person-pick label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.person-pick input { position: absolute; opacity: 0; pointer-events: none; }
.badge-gray { --b-bg: var(--t-gray-bg); --b-fg: var(--t-gray-fg); }
.badge-blue { --b-bg: var(--t-blue-bg); --b-fg: var(--t-blue-fg); }
.badge-green { --b-bg: var(--t-green-bg); --b-fg: var(--t-green-fg); }
.badge-amber { --b-bg: var(--t-amber-bg); --b-fg: var(--t-amber-fg); }
.badge-red { --b-bg: var(--t-red-bg); --b-fg: var(--t-red-fg); }
.badge-violet { --b-bg: var(--t-violet-bg); --b-fg: var(--t-violet-fg); }
.badge-teal { --b-bg: var(--t-teal-bg); --b-fg: var(--t-teal-fg); }
.badge-cat { --b-bg: color-mix(in srgb, var(--c) 16%, var(--surface)); --b-fg: color-mix(in srgb, var(--c) 80%, var(--text)); }

.avatar {
  --c: #6366f1;
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
  color: color-mix(in srgb, var(--c) 85%, var(--text));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-empty { --c: #9ca3af; border-style: dashed; }
.avatars { display: flex; }
.avatars .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar:first-child { margin-left: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--accent)); flex: none; }
.org-mark {
  --c: #0ea5e9;
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: color-mix(in srgb, var(--c) 80%, var(--text));
}
.org-mark.lg { width: 48px; height: 48px; font-size: 16px; border-radius: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 9px 14px; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
.table th.sortable:hover, .table th[aria-sort] { color: var(--text); }
.table th.sortable::after { content: "↕"; display: inline-block; margin-left: 5px; font-size: 10px; opacity: 0; transition: opacity .12s; }
.table th.sortable:hover::after { opacity: .45; }
.table th[aria-sort="ascending"]::after { content: "↑"; opacity: .9; }
.table th[aria-sort="descending"]::after { content: "↓"; opacity: .9; }
.table th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table .cell-main { font-weight: 550; }
.table .cell-main:hover { color: var(--accent); }
.row-link { cursor: pointer; }
/* Whole row clickable through its main link (keeps real <a> for ctrl-click / boost) */
tr:has(> td > a.stretch) { position: relative; }
.table a.stretch::after { content: ""; position: absolute; inset: 0; }
.table a.stretch { color: var(--text); gap: 8px; }

/* Spreadsheet-like checklist grid */
.sheet th.check-col, .sheet td.check-col { text-align: center; padding: 6px 4px; width: 1%; }
.sheet th.check-col { height: 110px; font-weight: 600; padding: 8px 4px; vertical-align: bottom; }
/* Rotate only the label: transforming the th itself flips its border-bottom to the top */
.sheet th.check-col > span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); }
.sheet td.sticky, .sheet th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 2; }
.sheet th.sticky { z-index: 3; }
.sheet tbody tr:hover td.sticky { background: var(--surface-2); }
.check-cell {
  width: 28px; height: 28px; margin: 0 auto; border-radius: 7px;
  display: grid; place-items: center; cursor: pointer; border: 1px dashed var(--border-strong);
  background: transparent; color: var(--text-3); transition: transform .08s, background .12s;
}
.check-cell:hover { transform: scale(1.08); }
.check-cell.yes { background: var(--t-green-bg); color: var(--t-green-fg); border: 1px solid transparent; }
.check-cell.no { background: var(--t-red-bg); color: var(--t-red-fg); border: 1px solid transparent; }
.check-cell { position: relative; }
.check-cell.auto::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #29abe1); }
.progress.green > span { background: linear-gradient(90deg, #22c55e, #16a34a); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 14px var(--font);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b96' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.select[multiple] { height: auto; min-height: 120px; padding: 6px; background-image: none; }
.input-sm { height: 30px; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--t-red-fg); margin-top: 4px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--t-red-fg); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.color-input { width: 36px; height: 36px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.pick-list { display: grid; gap: 6px; max-height: 300px; overflow: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.pick-list label:hover { background: var(--surface-2); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 150px; height: 32px; font-size: 13px; }
/* View controls (how) live apart from filters (what): view-bar in the page head, filter-bar below it. */
.view-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-bar .select { width: auto; min-width: 130px; height: 32px; font-size: 13px; }
.view-bar-tab { margin-bottom: 10px; }
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; height: 32px; font-size: 13px; }
.filter-bar .check { white-space: nowrap; }
.page-head .actions { align-items: center; }
.filter-label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding-right: 4px; }
.filter-clear { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }

fieldset.brand-fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; display: grid; gap: 12px; }
fieldset.brand-fieldset legend { display: flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }

/* ---------- Tabs & segmented ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 9px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); }
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border); }
.segmented a { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 550; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); font-size: 12.5px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: 13.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item:last-child { padding-bottom: 0; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(250px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 600; font-size: 13px; }
.column-head .count { color: var(--text-3); font-weight: 500; }
.column-head .add { margin-left: auto; }
.column-body { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; overflow-y: auto; }
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab; user-select: none;
  transition: box-shadow .12s, border-color .12s, transform .12s;
  border-left: 3px solid var(--pri, transparent);
}
.task-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.task-card .t-title { font-weight: 550; font-size: 13.5px; line-height: 1.4; }
.task-card .t-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.task-card .t-foot .avatar { margin-left: auto; }
.task-card.pri-urgent { --pri: var(--t-red-fg); }
.task-card.pri-high { --pri: var(--t-amber-fg); }
.task-card.is-done .t-title { color: var(--text-3); text-decoration: line-through; }
.sortable-ghost { opacity: .35; }
.board.board-projects { grid-template-columns: repeat(6, minmax(230px, 1fr)); }

/* ---------- Task list (grouped by due date) ---------- */
.task-group { margin-bottom: 14px; }
.task-group > summary { list-style: none; cursor: pointer; }
.task-group > summary::-webkit-details-marker { display: none; }
.task-group > summary h2 { display: flex; align-items: center; gap: 6px; }
.task-group > summary h2 .icon { transition: transform .15s; }
.task-group:not([open]) > summary h2 .icon { transform: rotate(-90deg); }
.task-group:not([open]) > summary { border-bottom: 0; }
.group-switch { gap: 6px; }
.group-switch label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.task-group > summary h2 .swatch { width: 10px; height: 10px; }
.task-row { color: var(--text); border-left: 3px solid var(--pri, transparent); }
/* List view task tree: rows nest one level under their parent; drag a row onto a task to make it a subtask. */
.task-tree .list-item { border-bottom: 0; }
.task-tree > .task-node { border-bottom: 1px solid var(--border); }
.task-tree > .task-node:last-child { border-bottom: 0; }
.subtask-list .task-node { border-top: 1px dashed var(--border); }
.subtask-list .list-item { padding-left: 30px; }
.subtask-mark { width: 12px; margin-right: -4px; }
.tasks-dragging .subtask-list:empty { min-height: 8px; }
.task-node.drop-parent { background: color-mix(in srgb, var(--accent) 8%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.task-node.sortable-drag .subtask-list { display: none; }
.task-row.pri-urgent { --pri: var(--t-red-fg); }
.task-row.pri-high { --pri: var(--t-amber-fg); }

/* ---------- Task calendar ---------- */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cal-head h2 { font-size: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px 10px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.cal-day { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-weekend { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal-day.is-other .cal-date { color: var(--text-3); opacity: .6; }
.cal-date { font-size: 12px; font-weight: 600; color: var(--text-2); width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.is-today .cal-date { background: var(--accent); color: #fff; }
.cal-tasks { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 24px; }
.cal-task {
  display: flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: grab; user-select: none;
  background: color-mix(in srgb, var(--c) 13%, var(--surface)); border-left: 3px solid var(--c); color: var(--text); min-width: 0;
}
.cal-task:hover { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.cal-task.is-done { opacity: .55; text-decoration: line-through; }
.cal-task.is-late { box-shadow: inset 0 0 0 1px var(--t-red-fg); }
.cal-task.pri-urgent::after, .cal-task.pri-high::after { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; margin-left: auto; background: var(--t-amber-fg); }
.cal-task.pri-urgent::after { background: var(--t-red-fg); }
.cal-side { position: sticky; top: 76px; }
/* Agenda */
.agenda-event, .agenda-task { cursor: pointer; }
.agenda-event > .icon { flex: none; margin-left: auto; opacity: .55; }
.segmented label { display: flex; align-items: center; padding: 4px 12px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.segmented label:has(:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.repeat-quick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.repeat-quick button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer; }
.repeat-quick button:hover, .repeat-quick button.active { border-color: var(--accent); color: var(--accent); }
.repeat-delete { gap: 6px; flex-wrap: wrap; }
.agenda-event b { font-weight: 650; font-variant-numeric: tabular-nums; }
.agenda-event.is-linked { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
.agenda-task { background: transparent; border-left-style: dashed; color: var(--text-2); }
.agenda-task .icon { flex: none; color: var(--c); }
.cal-add { opacity: 0; border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: 4px; cursor: pointer; display: grid; place-items: center; }
.cal-day:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
.cal-add:hover { background: var(--surface-2); color: var(--accent); }
@media (hover: none) { .cal-add { opacity: 1; } }
.agenda-soon { padding: 10px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
.agenda-soon-day { display: flex; flex-direction: column; gap: 3px; }
.agenda-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; max-height: 160px; overflow-y: auto; }
.agenda-people .check { display: flex; align-items: center; gap: 6px; }
.cal-unscheduled { padding: 10px; max-height: 60vh; overflow-y: auto; min-height: 60px; }
.cal-hint { padding: 0 12px 12px; margin: 0; }
.project-card { display: block; color: var(--text); }
.project-card .t-foot > span { display: inline-flex; align-items: center; gap: 3px; }
.project-card .t-foot .avatars { margin-left: auto; }
.column-body:not([data-project-board]) > .project-card { cursor: pointer; }
.sortable-drag { transform: rotate(2deg); box-shadow: var(--shadow-lg) !important; }
.due-late { color: var(--t-red-fg) !important; font-weight: 600; }
.due-soon { color: var(--t-amber-fg) !important; }

/* ---------- Modal (native dialog) ---------- */
.task-detail { grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; }
@media (max-width: 760px) { .task-detail { grid-template-columns: minmax(0, 1fr); } }
dialog.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: auto;
}
dialog.modal.wide { width: min(920px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 10, 16, .45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 20px; }

/* ---------- Command palette ---------- */
.palette-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10, 10, 16, .4); backdrop-filter: blur(2px); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fade-in .12s ease-out; }
/* CSS animation, not x-transition: Alpine transitions wait on requestAnimationFrame, which a background
   tab never runs, and a toggle made then left the palette stuck (open=true but hidden, clicks ignored). */
@keyframes fade-in { from { opacity: 0; } }
.palette { width: min(620px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font: 16px var(--font); color: var(--text); }
.palette-results { max-height: 380px; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.palette-item .sub { margin-left: auto; font-size: 12px; color: var(--text-3); }
.palette-item.active { background: var(--accent-soft); color: var(--text); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); }

/* ---------- Notifications ---------- */
.notif-wrap { position: relative; }
.bell { position: relative; width: 40px; height: 40px; }
.bell > .icon { width: 22px; height: 22px; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.bell-count.accent { background: var(--accent); }
.online-trigger { position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 8px; margin-right: 4px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
.online-trigger:hover { background: var(--surface-2, var(--accent-soft)); }
.online-trigger .avatars .avatar { box-shadow: 0 0 0 2px var(--bg); }
.online-dot { position: absolute; right: 6px; bottom: 6px; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px var(--bg); }
.avatar-more { --c: #9ca3af; }
.online-dropdown { width: min(300px, calc(100vw - 24px)); }
.notif-dropdown { position: absolute; right: 0; top: 42px; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40; }
.notif-head, .notif-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }
.notif-head { border-bottom: 1px solid var(--border); }
.notif-foot { border-top: 1px solid var(--border); justify-content: center; gap: 6px; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.notif.unread::after { content: ""; position: absolute; right: 14px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.notif-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.notif-title { display: block; font-weight: 550; font-size: 13.5px; padding-right: 14px; }
.notif-body { display: block; font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.notif-time { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

/* Toggle switch (checkbox) */
input.switch { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }

/* Vault */
.vault-fields { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.vault-fields .vf { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.vault-fields code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; }

/* Member picker with vault question */
.member-pick { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 7px 8px; border-radius: 8px; }
.member-pick:hover { background: var(--surface-2); }
.member-pick .vault-q { grid-column: 2; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); padding: 4px 0 2px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 32px)); pointer-events: none; }
/* #toasts is a popover (see raiseToasts in app.js): undo the UA popover box styles. */
.toasts[popover] { inset: 16px 16px auto auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; height: auto; color: inherit; }
.toasts[popover]:not(:popover-open) { display: none; }
.toast {
  --tc: var(--t-green-fg); --tb: var(--t-green-bg);
  position: relative; overflow: hidden; pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 12px 15px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  border-left: 4px solid var(--tc); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.45; animation: toast-in .22s ease-out;
}
.toast.error { --tc: var(--t-red-fg); --tb: var(--t-red-bg); }
.toast.warning { --tc: var(--t-amber-fg); --tb: var(--t-amber-bg); }
.toast.info { --tc: var(--t-blue-fg); --tb: var(--t-blue-bg); }
.toast-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--tb); color: var(--tc); }
.toast-text { flex: 1; min-width: 0; padding-top: 3px; overflow-wrap: anywhere; }
.toast-close { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--text-3); cursor: pointer; }
.toast-close svg { width: 15px; height: 15px; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--tc); opacity: .35; transform-origin: left; animation: toast-bar var(--toast-ms, 4s) linear forwards; }
.toast.paused .toast-bar { animation-play-state: paused; }
.toast.leaving { opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 600px) { .toasts, .toasts[popover] { inset: auto 16px 16px 16px; width: auto; } }

/* Confirm dialog (replaces window.confirm, see confirmDialog in app.js) */
dialog.confirm-dialog {
  width: min(420px, calc(100vw - 32px)); margin: auto; padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.confirm-dialog[open] { animation: pop .16s ease-out; }
dialog.confirm-dialog::backdrop { background: rgba(10, 10, 16, .5); backdrop-filter: blur(2px); }
.confirm-box { padding: 26px 24px 20px; text-align: center; }
.confirm-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: var(--t-blue-bg); color: var(--t-blue-fg); }
.confirm-icon svg { width: 26px; height: 26px; }
.confirm-dialog.danger .confirm-icon { background: var(--t-red-bg); color: var(--t-red-fg); }
.confirm-title { margin: 0 0 6px; font: 700 17px/1.3 var(--font-display); }
.confirm-msg { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.confirm-actions { display: flex; gap: 10px; margin-top: 22px; }
.confirm-actions .btn { flex: 1; justify-content: center; height: 38px; }
.btn-danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }

/* Running timer pill */
.timer-pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--t-red-bg); color: var(--t-red-fg); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer-pill .pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* HTMX progress bar */
.htmx-bar { position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 300; background: linear-gradient(90deg, var(--accent), #29abe1, #f7921e); transition: width .3s ease, opacity .3s; opacity: 0; }
.htmx-bar.on { opacity: 1; width: 70%; transition: width 2s cubic-bezier(.1, .7, .2, 1); }

/* ---------- Auth ---------- */
.impersonation-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; background: var(--accent-soft); color: var(--text); }
.impersonation-bar form { margin-left: auto; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; background: var(--t-red-bg); color: var(--t-red-fg); }
.auth-form .alert { display: flex; align-items: flex-start; gap: 8px; }
.auth-form .alert > .icon { margin-top: 1px; }
.alert.info { background: var(--t-blue-bg); color: var(--t-blue-fg); }
.alert.success { background: var(--t-green-bg); color: var(--t-green-fg); }
.alert.warning { background: var(--t-amber-bg); color: var(--t-amber-fg); }

.auth-body { background: var(--bg); }
.auth-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* Left: brand panel (logo blue + orange) with a product preview */
.auth-hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 28px;
  padding: 40px 52px 0; margin: 12px; border-radius: 20px;
  color: #fff;
  background:
    radial-gradient(70% 55% at 100% 100%, rgba(247, 146, 30, .45), transparent 70%),
    radial-gradient(60% 50% at 0% 0%, rgba(255, 255, 255, .16), transparent 70%),
    linear-gradient(155deg, #0e6fae 0%, #1890d2 45%, #29abe1 100%);
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 75%);
          mask-image: linear-gradient(180deg, #000, transparent 75%);
}
.hero-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.hero-brand .brand-logo { background: #fff; padding: 4px; border-radius: 9px; }
.hero-copy { max-width: 500px; margin-top: 28px; }
.hero-copy h2 { font-size: clamp(30px, 3vw, 42px); line-height: 1.1; font-weight: 750; letter-spacing: -.03em; }
.hero-copy p { margin-top: 14px; font-size: 15.5px; line-height: 1.6; color: rgba(255,255,255,.85); }

.hero-shot {
  flex: 1; min-height: 300px; margin-top: 8px;
  background: #f7f8fa; color: #1f2430;
  border-radius: 14px 14px 0 0; border: 1px solid rgba(255,255,255,.5); border-bottom: 0;
  box-shadow: 0 30px 70px -20px rgba(4, 40, 70, .55);
  overflow: hidden;
}
.shot-bar { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; background: #fff; border-bottom: 1px solid #e8e9ee; font-size: 12px; font-weight: 600; color: #6b7080; }
.shot-bar i { width: 10px; height: 10px; border-radius: 50%; background: #e3e4ea; }
.shot-bar i:nth-child(1) { background: #ff5f57; } .shot-bar i:nth-child(2) { background: #febc2e; } .shot-bar i:nth-child(3) { background: #28c840; }
.shot-bar span { margin-left: 10px; }
.shot-board { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 14px; padding: 16px; }
.shot-col-head { display: flex; align-items: center; gap: 7px; margin: 0 2px 10px; font-size: 12px; font-weight: 650; color: #3d4250; }
.shot-col-head em { font-style: normal; font-weight: 600; color: #9a9eab; }
.sd { width: 8px; height: 8px; border-radius: 50%; }
.sd.gray { background: #a1a5b2; } .sd.blue { background: #29abe1; } .sd.green { background: #22c55e; }
.shot-card { background: #fff; border: 1px solid #e8e9ee; border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; box-shadow: 0 1px 2px rgba(16,16,24,.04); }
.shot-card b { display: block; margin: 7px 0 9px; font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.shot-card.done b { color: #8a8f9c; text-decoration: line-through; text-decoration-color: #c9ccd4; }
.shot-card .tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 600; }
.tag.orange { background: #fff1e0; color: #c26a05; } .tag.blue { background: #e3f3fb; color: #1479b0; }
.tag.teal { background: #ddf6f3; color: #0f766e; } .tag.violet { background: #f0eaff; color: #6b3fd4; }
.tag.green { background: #e3f7ea; color: #16803c; } .tag.gray { background: #f0f0f3; color: #5c5c66; }
.shot-card .meta { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #8a8f9c; }
.shot-card .av { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 8.5px; font-weight: 700; color: #fff; background: var(--c); }
.shot-card .ok { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: #e3f7ea; color: #16803c; }
.progress-mini { height: 4px; border-radius: 999px; background: #eceef2; margin-bottom: 9px; overflow: hidden; }
.progress-mini span { display: block; height: 100%; border-radius: inherit; background: #29abe1; }
@media (max-width: 1240px) {
  .shot-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shot-col:nth-child(3) { display: none; }
}

/* Right: form */
.auth-main { position: relative; isolation: isolate; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px 28px; overflow: hidden; }
.auth-theme { position: absolute; top: 18px; right: 18px; }
:root[data-theme="dark"] .when-light, :root:not([data-theme="dark"]) .when-dark { display: none; }
.auth-panel { width: min(380px, 100%); margin: auto 0; animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; margin-bottom: 28px; }
.auth-head { margin-bottom: 26px; }
.auth-head h1 { font-size: 28px; font-weight: 750; letter-spacing: -.03em; }
.auth-head p { margin-top: 8px; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.auth-head p b { color: var(--text); font-weight: 600; }
.auth-badge {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 14px;
  color: #fff; background: linear-gradient(155deg, #1890d2, #29abe1);
  box-shadow: 0 10px 24px -10px rgba(24, 144, 210, .7);
}
.auth-form { gap: 16px; }
.auth-form .input { height: 46px; border-radius: 11px; font-size: 14.5px; background: var(--surface); }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; transition: color .15s; }
.input-icon .input { padding-left: 42px; }
.input-icon:focus-within > .icon { color: var(--accent); }
.input-icon .reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; }
.input-icon .reveal:hover { color: var(--text); background: var(--surface-2); }
.input-icon:has(.reveal) .input { padding-right: 44px; }
.reveal .when-shown, .reveal.shown .when-hidden { display: none; }
.reveal.shown .when-shown { display: block; }
.btn-auth {
  position: relative; height: 46px; width: 100%; justify-content: center; gap: 8px; border-radius: 11px; font-size: 14.5px; font-weight: 600;
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn-auth.btn-primary {
  border: 0; color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 20px -10px rgba(24, 144, 210, .8), inset 0 1px 0 rgba(255,255,255,.15);
}
.btn-auth.btn-primary:hover { background: var(--accent-hover); }
.btn-auth .icon { transition: transform .2s; }
.btn-auth:hover .icon:last-child { transform: translateX(3px); }
.btn-auth.loading { pointer-events: none; color: transparent; }
.btn-auth.loading::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-secondary { display: flex; align-items: center; }
.auth-link { display: block; text-align: center; font-size: 13.5px; font-weight: 550; color: var(--accent); padding: 4px; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-link.inline { display: inline; padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; }
.auth-link.back { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-top: 18px; color: var(--text-2); font-weight: 500; }
.auth-link.back:hover { color: var(--text); }
.auth-alt { margin-top: 18px; text-align: center; font-size: 13.5px; color: var(--text-2); }
.auth-alt:empty, .auth-alt:not(:has(button)) { display: none; }
.otp-input {
  height: 64px !important; text-align: center; font-family: var(--mono); font-size: 30px !important; font-weight: 700;
  letter-spacing: .55em; padding-left: .55em !important; caret-color: var(--accent);
}
.otp-input::placeholder { color: var(--surface-3); }
.auth-foot { margin-top: 28px; font-size: 12px; color: var(--text-3); text-align: center; }

@media (max-width: 960px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-panel { animation: none; }
}

.chart-box { position: relative; height: 240px; }
.error-page { text-align: center; padding: 80px 20px; }
.error-page .code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; background: linear-gradient(135deg, #1281c2, #29abe1 60%, #f7921e); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar { gap: 6px; }
  /* Dropdowns span the topbar instead of hanging off their trigger, which can sit far from the right edge */
  .notif-wrap { position: static; }
  .notif-dropdown, .online-dropdown { left: 12px; right: 12px; top: 52px; width: auto; }
  .notif-list { max-height: calc(100dvh - 170px); }
  .crumb:not(.is-last) { display: none; }
  .crumb.is-last > .icon { display: none; }
  .crumbs-back { display: inline-flex; }
  .grid-2, .grid-3, .form-row, .form-row.three { grid-template-columns: minmax(0, 1fr); }
  .board, .board.board-projects { grid-template-columns: repeat(5, 82vw); scroll-snap-type: x mandatory; }
  .board.board-projects { grid-template-columns: repeat(6, 82vw); }
  .cal-wrap { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; }
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-task { font-size: 11px; padding: 2px 4px; }
  .column { scroll-snap-align: start; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 600px) {
  /* Narrow rows: keep the title readable, let badges/dates wrap below it */
  .list-item { flex-wrap: wrap; row-gap: 6px; padding-left: 14px; padding-right: 14px; }
  .list-item > .grow { min-width: 55%; }
  .list-item > .swatch + .grow { flex-basis: calc(100% - 22px); }
  .list-item > .swatch + .grow + * { margin-left: 22px; }
  .list-item > .grow ~ .nowrap { min-width: 0 !important; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 22px; }
}

/* Team login → client portal link */
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: var(--text-3); font-size: 12.5px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn.auth-corporate { width: 100%; justify-content: center; gap: 8px; }
.btn.auth-corporate .icon:last-child { margin-left: auto; }
.btn.auth-corporate .icon:first-child { color: var(--accent); }

/* Generic busy state for any submit button (data-submit-once forms) */
.btn.loading { position: relative; pointer-events: none; color: transparent !important; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: color-mix(in srgb, var(--text) 25%, transparent); border-top-color: var(--text);
  animation: spin .7s linear infinite;
}
.btn-primary.loading::after, .btn-brand.loading::after { border-color: rgba(255,255,255,.4); border-top-color: #fff; }

/* ---------- Searchable select (select[data-search]) ---------- */
.ss { position: relative; display: inline-flex; }
.ss > select { display: none; }
.ss-btn { text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ss-btn.ss-empty { color: var(--text-2); }
.ss.open .ss-btn { border-color: var(--accent); }
.ss.ss-invalid .ss-btn { border-color: var(--t-red-fg); }
.field .ss { display: flex; width: 100%; }
.field .ss-btn { max-width: none; }
.field.has-error .ss-btn { border-color: var(--t-red-fg); }
.ss-drop { position: fixed; z-index: 1000; width: max-content; max-width: 340px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-lg); }
.ss-drop .ss-search { height: 32px; font-size: 13px; margin-bottom: 4px; width: 100%; min-width: 220px; }
.ss-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }
.ss-list li { padding: 6px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-list li.active { background: var(--surface-2); }
.ss-list li.selected { font-weight: 600; color: var(--accent); }
.ss-list li.ss-clear { color: var(--text-3); }
.ss-list li.ss-none { color: var(--text-3); cursor: default; }

/* Admin › Hata kayıtları */
.log-files a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-files a:hover { background: var(--surface-2); }
.log-files a.active { background: var(--surface-3); font-weight: 600; }
.log-entry { border-bottom: 1px solid var(--border); }
.log-entry > summary { display: flex; align-items: baseline; gap: 10px; padding: 9px 18px; cursor: pointer; list-style: none; }
.log-entry > summary::-webkit-details-marker { display: none; }
.log-entry > summary:hover { background: var(--surface-2); }
.log-msg { font-family: var(--mono); font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.log-entry[open] .log-msg { white-space: normal; word-break: break-word; }
.log-detail { margin: 0; padding: 10px 18px 14px; font: 12px/1.55 var(--mono); color: var(--text-2); background: var(--surface-2); white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; }
.log-layout { grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .log-layout { grid-template-columns: minmax(0, 1fr); } .log-entry > summary { flex-wrap: wrap; } }

/* Task description read view (links clickable, click to edit) */
.desc-view {
  white-space: pre-line; overflow-wrap: anywhere; cursor: text; min-height: 60px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.desc-view:hover { border-color: var(--border-strong, var(--text-3)); }
