/* ==========================================================================
   S.H.I.F.A.T Operations — design system
   Sage canvas · forest-green brand · RTL-first (logical properties throughout)
   ========================================================================== */

:root {
  color-scheme: light;
  /* surfaces */
  --canvas: #f2f5f2;
  --surface: #ffffff;
  --surface-2: #f8faf8;
  --surface-3: #eef2ee;
  --overlay: rgba(12, 22, 16, 0.42);
  /* ink */
  --ink: #142019;
  --ink-2: #3c4a41;
  --muted: #5d6b62;
  --faint: #8a968e;
  /* lines */
  --line: #e2e8e3;
  --line-strong: #cfd8d1;
  /* brand */
  --brand: #14532d;
  --brand-600: #166534;
  --brand-500: #15803d;
  --brand-50: #ecf7ef;
  --brand-100: #d5eedb;
  --accent: #22c55e;
  --on-brand: #ffffff;
  /* status tones: fg / bg */
  --ok: #15803d;       --ok-bg: #e7f6ec;
  --warn: #a16207;     --warn-bg: #fdf4d8;
  --danger: #b91c1c;   --danger-bg: #fdecec;
  --info: #1d4ed8;     --info-bg: #e8effd;
  --violet: #6d28d9;   --violet-bg: #f1ebfd;
  --neutral: #4b5563;  --neutral-bg: #eef1ef;
  /* shape */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(16, 38, 24, 0.05);
  --shadow-2: 0 1px 2px rgba(16, 38, 24, 0.04), 0 4px 14px -4px rgba(16, 38, 24, 0.08);
  --shadow-3: 0 12px 32px -8px rgba(16, 38, 24, 0.18), 0 2px 6px rgba(16, 38, 24, 0.06);
  --ring: 0 0 0 3px rgba(34, 197, 94, 0.35);
  /* type */
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 220ms;
  /* layout */
  --sidebar-w: 256px;
  --topbar-h: 64px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0c120e;
  --surface: #141b16;
  --surface-2: #19211b;
  --surface-3: #1f2922;
  --overlay: rgba(0, 0, 0, 0.6);
  --ink: #e9f1eb;
  --ink-2: #c3cfc6;
  --muted: #98a69c;
  --faint: #6f7c73;
  --line: #243028;
  --line-strong: #324037;
  --brand: #4ade80;
  --brand-600: #22c55e;
  --brand-500: #22c55e;
  --brand-50: rgba(74, 222, 128, 0.09);
  --brand-100: rgba(74, 222, 128, 0.16);
  --on-brand: #06200f;
  --ok: #4ade80;       --ok-bg: rgba(74, 222, 128, 0.12);
  --warn: #facc15;     --warn-bg: rgba(250, 204, 21, 0.12);
  --danger: #f87171;   --danger-bg: rgba(248, 113, 113, 0.13);
  --info: #93b4fd;     --info-bg: rgba(147, 180, 253, 0.13);
  --violet: #c4b5fd;   --violet-bg: rgba(196, 181, 253, 0.13);
  --neutral: #b8c2bb;  --neutral-bg: rgba(184, 194, 187, 0.1);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 16px -6px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 16px 40px -8px rgba(0, 0, 0, 0.7);
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--brand-100); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.86em; letter-spacing: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -48px; z-index: 100; background: var(--brand); color: var(--on-brand); padding: 8px 14px; border-radius: var(--r-sm); transition: top var(--dur); }
.skip-link:focus { top: 12px; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  overflow-y: auto;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, #173d27, #0c2416); color: #4ade80;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 4px 12px -4px rgba(20, 83, 45, .5);
}
.brand-mark .icon { width: 20px; height: 20px; }
.brand-name { font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.nav-section { font-size: 0.7rem; font-weight: 700; color: var(--faint); letter-spacing: 0.04em; padding: 14px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; font-size: 0.94rem;
  transition: background var(--dur) var(--ease-io), color var(--dur) var(--ease-io);
}
.nav-link .icon { color: var(--faint); transition: color var(--dur); }
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link:hover .icon { color: var(--ink-2); }
.nav-link[aria-current="page"] { background: var(--brand); color: var(--on-brand); font-weight: 600; box-shadow: 0 6px 16px -8px rgba(20, 83, 45, .55); }
.nav-link[aria-current="page"] .icon { color: inherit; }
.nav-link .count { margin-inline-start: auto; font-size: 0.72rem; font-weight: 700; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: var(--r-full); background: var(--surface-3); color: var(--ink-2); }
.nav-link[aria-current="page"] .count { background: rgba(255,255,255,.2); color: inherit; }
.nav-scrim { display: none; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur);
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-title { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.menu-toggle { display: none; }

.search-trigger {
  display: flex; align-items: center; gap: 10px;
  width: min(420px, 38vw); height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-full);
  font-size: 0.9rem; text-align: start;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.search-trigger:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.search-trigger span { flex: 1; }
kbd { font-family: var(--mono); font-size: 0.72rem; padding: 2px 6px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line); color: var(--muted); direction: ltr; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-full);
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
  transition: background var(--dur), border-color var(--dur);
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--canvas); }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface); }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 0.85rem; font-weight: 600; }
.user-chip .who small { font-size: 0.72rem; color: var(--muted); }

.page { padding: 8px 28px 48px; width: 100%; max-width: 1480px; margin-inline: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 22px; }
.page-head h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumbs { display: flex; gap: 6px; align-items: center; font-size: 0.84rem; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a:hover { color: var(--brand); text-decoration: underline; }

/* ---------------------------------------------------------------- grid helpers */
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: grid; gap: 18px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-head .sub { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.card-body { padding: 18px 22px; }
.card-foot { padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.flush .card-body { padding: 0; }
a.card { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur); }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }

/* KPI tiles */
.kpi { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; min-height: 132px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 0.84rem; color: var(--muted); font-weight: 500; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-meta { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: auto; }
.tone-ok { color: var(--ok); background: var(--ok-bg); }
.tone-warn { color: var(--warn); background: var(--warn-bg); }
.tone-danger { color: var(--danger); background: var(--danger-bg); }
.tone-info { color: var(--info); background: var(--info-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-neutral { color: var(--neutral); background: var(--neutral-bg); }
.tone-brand { color: var(--brand); background: var(--brand-50); }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-danger { color: var(--danger); } .text-info { color: var(--info); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  color: var(--b-fg); background: var(--b-bg);
  border: 1px solid var(--b-line); border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease-io), border-color var(--dur), transform 120ms, box-shadow var(--dur);
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn-primary { --b-bg: var(--brand); --b-fg: var(--on-brand); --b-line: var(--brand); box-shadow: 0 6px 14px -8px rgba(20, 83, 45, .7); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-ghost { --b-bg: transparent; --b-line: transparent; --b-fg: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { --b-bg: var(--surface); --b-fg: var(--danger); --b-line: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.84rem; border-radius: 7px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 0.78rem; border-radius: 6px; gap: 5px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--b-fg) transparent var(--b-fg) transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--brand); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 0.75rem; font-weight: 600; line-height: 1.6; white-space: nowrap;
  color: var(--neutral); background: var(--neutral-bg);
}
.badge .icon { width: 13px; height: 13px; }
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px;
  border-radius: var(--r-full); border: 1px solid var(--line); background: var(--surface);
  font-size: 0.84rem; font-weight: 500; color: var(--ink-2);
  transition: all var(--dur) var(--ease-io);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
:root[data-theme="dark"] .chip[aria-pressed="true"], :root[data-theme="dark"] .chip.is-active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.chip .n { font-size: 0.72rem; opacity: .75; font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--r-sm); }
.segmented a, .segmented button { padding: 5px 12px; border-radius: 6px; font-size: 0.84rem; font-weight: 500; color: var(--muted); border: 0; background: none; }
.segmented [aria-current="true"], .segmented .is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.avatar {
  --av: 32px;
  width: var(--av); height: var(--av); flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--av) * 0.38); font-weight: 700; letter-spacing: 0;
  color: var(--brand); background: var(--brand-100);
}
.avatar-sm { --av: 26px; }
.avatar-lg { --av: 44px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-inline-start: -8px; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .label { font-size: 0.83rem; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--danger); margin-inline-start: 2px; }
.hint { font-size: 0.78rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6b62' stroke-width='2' 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: left 10px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input[type="date"], .input[type="time"], .input[type="number"], .input.ltr-input { direction: ltr; text-align: right; }
.input-sm { height: 34px; font-size: 0.88rem; }
.is-invalid, .input.is-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent) !important; }
.is-valid { border-color: var(--ok) !important; }
.field-error { font-size: 0.78rem; color: var(--danger); font-weight: 500; display: flex; gap: 4px; align-items: center; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 10px; background: var(--surface-3); border: 1px solid var(--line-strong); border-inline-start: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); color: var(--muted); font-size: 0.86rem; }
.date-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.date-presets button { height: 26px; padding: 0 10px; font-size: 0.76rem; font-weight: 600; border-radius: var(--r-full); border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); }
.date-presets button:hover { border-style: solid; border-color: var(--brand-500); color: var(--brand); background: var(--brand-50); }
fieldset { border: 0; padding: 0; margin: 0; }
.form-section { font-size: 0.78rem; font-weight: 700; letter-spacing: .03em; color: var(--faint); padding-top: 6px; grid-column: 1 / -1; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }
.context-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--brand-50); color: var(--brand); font-size: 0.85rem; border: 1px solid var(--brand-100); }

/* combobox */
.combo { position: relative; }
.combo-list {
  position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 60;
  max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-3);
}
.combo-opt { padding: 8px 10px; border-radius: 6px; font-size: 0.9rem; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.combo-opt small { color: var(--muted); }
.combo-opt[aria-selected="true"], .combo-opt:hover { background: var(--brand-50); color: var(--brand); }
.combo-empty { padding: 10px; color: var(--muted); font-size: 0.86rem; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table th {
  position: sticky; top: 0;
  font-size: 0.76rem; font-weight: 600; color: var(--muted); text-align: start;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 0.9rem; }
.table tbody tr { transition: background 120ms; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t-end { text-align: end; }
.table .t-num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.is-muted td { color: var(--faint); }
.row-link { font-weight: 600; }
.row-link:hover { color: var(--brand); text-decoration: underline; }

/* ---------------------------------------------------------------- lists */
.list > li, .list-item { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list-title { font-weight: 600; font-size: 0.92rem; }
.list-sub { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sep::before { content: '·'; color: var(--faint); margin-inline: 2px; }

/* task row */
.task { display: flex; align-items: flex-start; gap: 12px; padding: 13px 22px; border-bottom: 1px solid var(--line); transition: background 120ms, opacity var(--dur); }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--surface-2); }
.task-check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px;
  border: 1.8px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: transparent;
  transition: all var(--dur) var(--ease);
}
.task-check:hover { border-color: var(--brand-500); background: var(--brand-50); }
.task-check .icon { width: 14px; height: 14px; stroke-width: 3; }
.task.is-done .task-check { background: var(--brand-500); border-color: var(--brand-500); color: #fff; transform: scale(1.02); }
.task.is-done .task-title { text-decoration: line-through; color: var(--faint); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 0.92rem; line-height: 1.4; }
.task-title a:hover { color: var(--brand); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 5px; font-size: 0.78rem; color: var(--muted); }
.task-meta .icon { width: 13px; height: 13px; }
.task-meta span { display: inline-flex; align-items: center; gap: 4px; }
.prio { width: 4px; align-self: stretch; border-radius: 4px; flex: none; background: transparent; }
.prio-urgent { background: var(--danger); }
.prio-high { background: #ea580c; }

/* ---------------------------------------------------------------- progress (radiant) */
.progress { position: relative; height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
/* The full red → orange → yellow → green scale spans the whole track (0% = red at the
   start, 100% = green at the end); the fill reveals only the part reached so far.
   RTL: the track starts on the right. */
.progress > span {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(to left, #dc2626 0%, #f97316 30%, #eab308 58%, #84cc16 80%, #16a34a 100%);
  clip-path: inset(0 0 0 calc(100% - var(--p, 0%)) round 999px);
  transition: clip-path 700ms var(--ease);
}
:root[dir="ltr"] .progress > span { background: linear-gradient(to right, #dc2626 0%, #f97316 30%, #eab308 58%, #84cc16 80%, #16a34a 100%); clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0 round 999px); }
.progress.progress-plain > span { background: var(--brand-500); }
.progress-lg { height: 10px; }
.ring { --size: 58px; --p: 0; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand-500) calc(var(--p) * 1%), var(--surface-3) 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 0.84rem; font-variant-numeric: tabular-nums; }

/* stage timeline */
.stages { display: grid; gap: 0; }
.stage { position: relative; display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 10px 0; }
.stage::before { content: ''; position: absolute; inset-inline-start: 13px; top: 34px; bottom: -10px; width: 2px; background: var(--line); }
.stage:last-child::before { display: none; }
.stage-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line-strong); background: var(--surface); color: var(--faint); z-index: 1; font-size: 0.72rem; font-weight: 700; }
.stage.is-done .stage-dot { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.stage.is-done::before { background: var(--brand-500); }
.stage.is-active .stage-dot { border-color: var(--brand-500); color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50); }
.stage-name { font-weight: 600; font-size: 0.9rem; }
.stage-meta { font-size: 0.78rem; color: var(--muted); }

/* ---------------------------------------------------------------- project cards */
.project-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.project-card .code { font-family: var(--mono); font-size: 0.74rem; color: var(--faint); }
.project-card h3 { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.project-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 0; border-block: 1px dashed var(--line); }
.project-facts div { display: grid; gap: 2px; }
.project-facts small { font-size: 0.72rem; color: var(--muted); }
.project-facts b { font-size: 0.9rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 600; font-size: 0.9rem; color: var(--muted); border: 0; background: none; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; inset-inline: 10px; bottom: -1px; height: 2.5px; border-radius: 2px 2px 0 0; background: var(--brand); }
.tab .badge { padding: 0 7px; }
.tab-panel { animation: fadeUp 280ms var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- collapsible (details) */
.disclosure { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.disclosure + .disclosure { margin-top: 10px; }
.disclosure > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; font-weight: 600; user-select: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:hover { background: var(--surface-2); }
.disclosure > summary .chev { margin-inline-start: auto; color: var(--faint); transition: transform var(--dur) var(--ease); }
.disclosure[open] > summary .chev { transform: rotate(180deg); }
.disclosure-body { border-top: 1px solid var(--line); }
.cat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }

/* ---------------------------------------------------------------- dialogs */
dialog.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(18px) scale(.98);
  transition: opacity var(--dur) var(--ease), transform 320ms var(--ease), overlay var(--dur) allow-discrete, display var(--dur) allow-discrete;
}
dialog.modal[open] { opacity: 1; transform: none; }
@starting-style { dialog.modal[open] { opacity: 0; transform: translateY(18px) scale(.98); } }
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--dur), overlay var(--dur) allow-discrete, display var(--dur) allow-discrete; }
dialog.modal[open]::backdrop { opacity: 1; }
@starting-style { dialog.modal[open]::backdrop { opacity: 0; } }
dialog.modal.is-closing { opacity: 0; transform: translateY(12px) scale(.985); }
dialog.modal-lg { width: min(880px, calc(100vw - 32px)); }
dialog.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 14px; }
.modal-head h2 { font-size: 1.15rem; font-weight: 800; }
.modal-head p { font-size: 0.86rem; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 6px 24px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-start; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); flex-direction: row-reverse; }
.modal-foot .spacer { flex: 1; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: min(520px, calc(100vw - 32px));
  padding: 11px 14px 11px 12px; border-radius: var(--r-md);
  background: #15201a; color: #f1f7f2; box-shadow: var(--shadow-3); font-size: 0.9rem; font-weight: 500;
  animation: toastIn 360ms var(--ease);
}
:root[data-theme="dark"] .toast { background: #e9f1eb; color: #142019; }
.toast .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
.toast.leaving { animation: toastOut 240ms var(--ease-io) forwards; }
.toast button { margin-inline-start: auto; background: none; border: 0; color: inherit; opacity: .6; padding: 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------------------------------------------------------------- dropdown / popover */
.popover {
  position: absolute; z-index: 70; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3);
  transform-origin: top left; animation: pop 180ms var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; font-size: 0.9rem; text-align: start; color: var(--ink-2); }
.menu-item:hover { background: var(--surface-3); color: var(--ink); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.notif-panel { width: 360px; padding: 0; }
.notif-panel header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; }
.notif-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 0.86rem; }
.notif-item.unread { background: var(--brand-50); }
.notif-item:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- command palette */
.palette { width: min(640px, calc(100vw - 24px)); margin-top: 12vh; margin-inline: auto; }
dialog.palette-dialog { padding: 0; border: 0; background: transparent; max-width: none; width: 100%; height: 100%; max-height: none; margin: 0; }
dialog.palette-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
.palette-box { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); overflow: hidden; border: 1px solid var(--line); animation: pop 200ms var(--ease); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; height: 58px; border: 0; background: none; font-size: 1.05rem; outline: none; }
.palette-results { max-height: min(460px, 60vh); overflow-y: auto; padding: 6px; }
.palette-group { font-size: 0.72rem; font-weight: 700; color: var(--faint); padding: 10px 12px 4px; letter-spacing: .03em; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--brand-50); }
.palette-item .pi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); flex: none; }
.palette-item .pi-title { font-weight: 600; font-size: 0.92rem; }
.palette-item .pi-sub { font-size: 0.78rem; color: var(--muted); }
.palette-item mark { background: none; color: var(--brand); font-weight: 700; }
.palette-foot { display: flex; gap: 14px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 0.76rem; color: var(--muted); background: var(--surface-2); }
.palette-answer { margin: 6px; padding: 14px 16px; border-radius: var(--r-md); background: var(--brand-50); border: 1px solid var(--brand-100); font-size: 0.9rem; line-height: 1.6; white-space: pre-line; }
.palette-answer .src { display: block; margin-top: 8px; font-size: 0.74rem; color: var(--muted); }

/* ---------------------------------------------------------------- empty state */
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--faint); margin-bottom: 4px; }
.empty .empty-icon .icon { width: 24px; height: 24px; }
.empty b { color: var(--ink); font-size: 0.98rem; }

/* ---------------------------------------------------------------- aging bar */
.aging { display: flex; height: 12px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-3); gap: 2px; }
.aging span { display: block; min-width: 3px; transition: flex-grow 600ms var(--ease); }
.aging-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.aging-legend a { display: grid; gap: 3px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); transition: border-color var(--dur), background var(--dur); }
.aging-legend a:hover, .aging-legend a.is-active { border-color: var(--line-strong); background: var(--surface-2); }
.aging-legend small { font-size: 0.74rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.aging-legend small i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.aging-legend b { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.b0 { background: #22c55e; } .b1 { background: #eab308; } .b2 { background: #f97316; } .b3 { background: #dc2626; } .b4 { background: #7f1d1d; }

/* ---------------------------------------------------------------- invoice calc */
.calc { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.calc div { display: flex; justify-content: space-between; padding: 8px 14px; font-size: 0.88rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.calc div:last-child { border-bottom: 0; }
.calc .total { background: var(--brand-50); font-weight: 800; font-size: 0.98rem; color: var(--brand); }

/* ---------------------------------------------------------------- timesheet calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cal-head { font-size: 0.74rem; font-weight: 700; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-day {
  position: relative; min-height: 104px; padding: 9px 10px; text-align: start;
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease);
}
button.cal-day:hover { border-color: var(--brand-500); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.cal-day.is-weekend { background: var(--surface-2); }
.cal-day.is-empty-slot { background: transparent; border-style: dashed; border-color: transparent; }
.cal-day.is-today { border-color: var(--brand-500); box-shadow: inset 0 0 0 1px var(--brand-500); }
.cal-day.is-selected { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.cal-num { font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cal-hours { font-size: 1.08rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: auto; }
.cal-range { font-size: 0.7rem; color: var(--muted); direction: ltr; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day .badge { align-self: flex-start; font-size: 0.68rem; padding: 0 7px; }
.alloc-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 110px minmax(0, 1.2fr) 36px; gap: 8px; align-items: center; }
.alloc-row.has-stage { grid-template-columns: minmax(0, 1.3fr) 96px minmax(0, 1fr) minmax(0, 1.2fr) 36px; }
.alloc-sum { display: flex; justify-content: space-between; font-size: 0.84rem; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.alloc-sum.is-over { background: var(--warn-bg); color: var(--warn); }

/* ---------------------------------------------------------------- permission matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: start; }
.matrix td { padding: 9px 12px; }
.matrix .group-row td { background: var(--surface-2); font-weight: 700; font-size: 0.82rem; color: var(--ink-2); text-align: start; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 22px; background: var(--line-strong); transition: background var(--dur); cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; top: 3px; inset-inline-start: 3px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--brand-500); }
.switch input:checked + span::before { transform: translateX(-16px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.switch input:disabled + span { opacity: .55; cursor: not-allowed; }

/* activity feed */
.feed li { display: flex; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.feed-text { font-size: 0.87rem; line-height: 1.45; }
.feed-text b { font-weight: 600; }
.feed-time { font-size: 0.74rem; color: var(--faint); margin-top: 2px; }

/* key-value */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* login */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(420px, 100%); display: grid; gap: 22px; }
.auth-card h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-art {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 600px at 20% 110%, #1f6b3d 0%, transparent 60%), linear-gradient(160deg, #0d2a19, #0a1f13 60%, #07170e);
  color: #e3f3e8; display: flex; flex-direction: column; justify-content: flex-end; padding: 56px;
}
.auth-art svg.lines { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.auth-art h2 { position: relative; font-size: 2rem; font-weight: 800; line-height: 1.25; max-width: 460px; }
.auth-art p { position: relative; margin-top: 12px; color: #a7cbb2; max-width: 440px; }
.ms-btn { height: 46px; font-size: 0.96rem; gap: 12px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); font-size: 0.88rem; line-height: 1.5; }
.alert .icon { margin-top: 2px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw);
    transform: translateX(100%); transition: transform 320ms var(--ease); box-shadow: var(--shadow-3);
  }
  .shell.nav-open .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
  .shell.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 14px; gap: 8px; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd, .user-chip .who { display: none; }
  .page { padding: 4px 14px 40px; }
  .cal { gap: 4px; }
  .cal-day { min-height: 74px; padding: 6px; }
  .cal-range, .cal-day .badge-text { display: none; }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .aging-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 1.35rem; }
  .alloc-row { grid-template-columns: 1fr 90px 36px; }
  .alloc-row .alloc-desc { grid-column: 1 / -1; order: 5; }
  .alloc-row.has-stage { grid-template-columns: 1fr 90px 36px; }
  .alloc-row .alloc-stage { grid-column: 1 / -1; order: 4; }
  .hide-sm { display: none !important; }
  .table td, .table th { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .board-bar, .w-menu-btn, .ui-resizable-handle { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; }
}

/* theme toggle icon swap (JS also syncs; this prevents a flash) */
:root:not([data-theme="dark"]) .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }


/* ==========================================================================
   Tile boards — a 6-column "lego" grid. One unit = 1 column × 132px row.
   Tiles are 1–3 units wide/high. GridStack drives drag & resize; before it
   loads (or without JS) a CSS grid with the same geometry shows the layout.
   ========================================================================== */
.board { --cell: 132px; --gap: 16px; --half: 8px; margin-bottom: 18px; container-type: inline-size; }
.board-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; min-height: 34px; margin-bottom: 4px; }
.board-bar > .grow { flex: 1 1 0; }
.board-hint { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 14px; font-size: 0.82rem; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-full); max-width: 100%; transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
.board-hint { flex: 0 1 auto; }
.board-hint > span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .board-hint > span { white-space: normal; } }
.board-hint .icon { flex: none; }
.board-hint .link { border: 0; background: none; font-size: 0.82rem; flex: none; }
.board-hint.is-leaving { opacity: 0; transform: translateY(-4px); }
.board-hint-static { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.board-status { min-height: 1em; transition: color var(--dur); }
.board-status.is-ok { color: var(--ok); }
.board-status.is-error { color: var(--danger); }

/* shared geometry: tile edges line up with the page's other cards */
.board-grid { margin-inline: calc(var(--half) * -1); }

/* pre-JS / no-JS fallback: a CSS grid with identical cell geometry */
.board-grid:not(.grid-stack) { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: calc(var(--cell) - var(--gap)); gap: var(--gap); padding: var(--half); grid-auto-flow: row dense; }
.board-grid:not(.grid-stack) > .grid-stack-item { position: relative; min-width: 0; grid-column: calc(var(--x) + 1) / span var(--w); grid-row: calc(var(--y) + 1) / span var(--h); }
.board-grid:not(.grid-stack) > .grid-stack-item > .grid-stack-item-content { position: absolute; inset: 0; }
@container (max-width: 940px) {
  .board-grid:not(.grid-stack) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .board-grid:not(.grid-stack) > .grid-stack-item { grid-column: auto / span var(--w); grid-row: auto / span var(--h); }
}
@container (max-width: 620px) {
  .board-grid:not(.grid-stack) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-grid:not(.grid-stack) > .grid-stack-item { grid-column: auto / span 2; }
  .board-grid:not(.grid-stack) > .grid-stack-item[gs-w="1"] { grid-column: auto / span 1; }
  .board-grid:not(.grid-stack) .w-menu-btn, .board-grid:not(.grid-stack) .w-grip { display: none; }
  .board-grid:not(.grid-stack) .w-head { cursor: default; }
}

/* ---- the tile */
.wcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); overflow: hidden; transition: box-shadow 220ms var(--ease), transform 220ms var(--ease), border-color 220ms var(--ease); }
.grid-stack > .grid-stack-item > .grid-stack-item-content.wcard { overflow: hidden; }
.wcard:hover { border-color: var(--line-strong); }
.w-head { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 46px; padding-inline: 12px 6px; user-select: none; -webkit-user-select: none; }
.grid-stack:not(.grid-stack-static) .w-head { cursor: grab; }
.board.is-narrow .w-head { cursor: default; }
/* the whole header is the drag handle; the grip glyph only appears on hover, over the padding */
.w-grip { position: absolute; inset-inline-start: 0; top: 50%; translate: 0 -50%; display: grid; place-items: center; width: 10px; color: var(--faint); opacity: 0; transition: opacity 160ms; pointer-events: none; }
.w-grip .icon { width: 12px; height: 12px; }
.wcard:hover .w-grip { opacity: .8; }
.board.is-narrow .w-grip { display: none; }
.w-icon { color: var(--muted); flex: none; }
.w-kpi-icon { width: 26px; height: 26px; border-radius: 8px; flex: none; }
.w-title { flex: 1 1 auto; min-width: 0; font-size: 0.9rem; font-weight: 700; color: var(--ink); }
.w-link { flex: none; font-size: 0.8rem; font-weight: 600; color: var(--brand-600); padding: 4px 6px; border-radius: 6px; }
.w-link:hover { background: var(--brand-50); }
.w-menu-btn { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted);
  opacity: 0; transition: opacity 160ms, background 160ms; cursor: pointer; }
.wcard:hover .w-menu-btn, .wcard:focus-within .w-menu-btn, .w-menu-btn[aria-expanded="true"] { opacity: 1; }
.w-menu-btn:hover, .w-menu-btn[aria-expanded="true"] { background: var(--surface-3); color: var(--ink); }
/* KPI tiles: no header link, so the menu floats over the title end instead of taking room */
.wcard.is-kpi .w-menu-btn { position: absolute; inset-inline-end: 6px; top: 8px; background: var(--surface); box-shadow: -8px 0 10px var(--surface); }
.wcard.is-kpi .w-title { font-size: 0.84rem; font-weight: 600; color: var(--muted); }
@media (hover: none) { .w-menu-btn { opacity: 1; } }
.w-body { position: relative; flex: 1 1 auto; min-height: 0; padding: 0 16px 12px; overflow: auto; scrollbar-width: thin; transition: opacity 180ms var(--ease); }
.w-body.is-loading { opacity: .45; }
.w-actions { margin-top: 10px; display: flex; gap: 8px; }
.w-more { display: inline-block; margin-top: 6px; font-size: 0.8rem; font-weight: 600; color: var(--brand-600); }
.w-more-hint { padding-top: 6px; }
.w-empty { height: 100%; min-height: 0; padding: 4px; display: grid; place-content: center; justify-items: center; gap: 4px; text-align: center; }
.w-empty .empty-icon { margin: 0 auto 4px; }
.wsz-h1 .w-empty { grid-auto-flow: column; gap: 8px; }
.w-text { display: grid; min-width: 0; gap: 1px; }
.w-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }

/* ---- lists inside tiles */
.w-list { display: grid; }
.w-list > li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.w-list > li > * { min-width: 0; }
.w-list > li .row.between > :first-child { min-width: 0; }
.w-list > li > b, .w-list > li > .badge, .w-list > li > small { flex: none; }
.wsz-h1 .w-list > li { padding-block: 4px; }
.wsz-h1 .w-list > li:only-child { border-bottom: 0; }
.wsz-w1 .w-link { display: none; }
.w-aging-sum { font-size: 0.84rem; gap: 8px; }
.wsz-h1 .w-aging { gap: 6px; }
.w-fit-more { margin-top: 4px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.w-list > li:last-child { border-bottom: 0; }
.w-list > li.is-unread .list-title { color: var(--brand); }
.w-list.is-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.w-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; font-size: 0.87rem; font-weight: 600; }
.w-line small { flex: none; font-size: 0.74rem; font-weight: 500; }
.w-line:hover { color: var(--brand); }
.w-progress > li { padding: 7px 0; }
.w-progress .progress { margin-top: 5px; }
.w-progress .list-sub { margin-top: 5px; flex-wrap: nowrap; }
.w-tasks .task { padding: 10px 0; }
.w-tasks .task:hover { background: none; }
.w-tasks .task-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.w-tasks .task-meta { flex-wrap: nowrap; overflow: hidden; }
.w-tasks .task-meta > * { flex: none; }
.w-feed li { padding: 8px 0; gap: 10px; }
.w-feed .feed-text.truncate { display: block; }

/* ---- KPI tiles */
.kpi-tile { height: 100%; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kpi-main { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; color: inherit; flex: 1 1 auto; }
.kpi-main:hover .kpi-value { color: var(--brand); }
.kpi-tile .kpi-value { font-size: 1.6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color var(--dur); }
.kpi-tile .kpi-meta { margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.kpi-tile .progress { margin-top: 8px; }
.wsz-w1.wsz-h1 .kpi-tile .kpi-value { font-size: 1.42rem; }
.kpi-details { display: grid; gap: 0; min-width: 0; margin: 0; }
.kpi-details dd, .kpi-details dt { margin: 0; }
.kpi-details > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); min-width: 0; }
.kpi-details dt { flex: 0 1 auto; font-size: 0.78rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-details dd { flex: 0 1 auto; max-width: 62%; min-width: 0; font-size: 0.86rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wsz-h1:not(.wsz-w1) .kpi-details dd, .wsz-h1:not(.wsz-w1) .kpi-details dt { max-width: 100%; }
.wsz-h1:not(.wsz-w1) .kpi-details > div { grid-template-columns: minmax(0, 1fr); }
/* wide & short: breakdown beside the value */
.wsz-h1:not(.wsz-w1) .kpi-tile { flex-direction: row; align-items: center; gap: 16px; }
.wsz-h1:not(.wsz-w1) .kpi-main { flex: 0 1 auto; max-width: 48%; }
.wsz-h1:not(.wsz-w1) .kpi-details { flex: 1 1 0; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; padding-inline-start: 16px; border-inline-start: 1px dashed var(--line); }
.wsz-h1:not(.wsz-w1) .kpi-details > div { display: grid; gap: 2px; padding: 0; border: 0; justify-items: start; }
.wsz-h2 .kpi-tile .kpi-main, .wsz-h3 .kpi-tile .kpi-main { flex: none; justify-content: flex-start; padding-top: 2px; }
.wsz-h2 .kpi-tile .kpi-value, .wsz-h3 .kpi-tile .kpi-value { font-size: 1.9rem; }
.wsz-h3.wsz-w2 .kpi-tile .kpi-value, .wsz-h3.wsz-w3 .kpi-tile .kpi-value { font-size: 2.3rem; }

/* ---- project tiles */
.pc { display: flex; flex-direction: column; gap: 8px; height: 100%; min-width: 0; color: inherit; }
.pc > * { flex: none; }
.pc > .pc-foot { margin-top: auto; }
.pc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge-dot-only .badge-text { display: none; }
.pc-top .code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pc-top > * { min-width: 0; }
.pc-top .code { font-family: var(--mono); font-size: 0.74rem; color: var(--faint); }
.pc-client { font-size: 0.84rem; color: var(--muted); }
.pc-progress .row { margin-bottom: 6px; font-size: 0.82rem; gap: 8px; }
.pc-facts { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); padding: 8px 0; }
.wsz-w1 .pc-facts > div { display: flex; justify-content: space-between; align-items: baseline; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; font-size: 0.8rem; min-width: 0; }
.pc-foot > span { min-width: 0; }
.pc-stages { display: grid; gap: 5px; font-size: 0.8rem; }
.pc-stages li { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.pc-stages li i { width: 9px; height: 9px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong); }
.pc-stages li.is-done i { background: var(--brand-500); border-color: var(--brand-500); }
.pc-stages li.is-active { color: var(--ink); font-weight: 600; }
.pc-stages li.is-active i { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.pc-stages li small { margin-inline-start: auto; flex: none; color: var(--faint); font-weight: 400; }
.wsz-h1 .pc { gap: 6px; justify-content: center; }

/* ---- other tile bodies */
.w-stages .stage { padding: 8px 0; gap: 10px; }
.w-stages .stage::before { top: 32px; bottom: -8px; }
.w-stages.is-compact .stage { padding: 5px 0; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; }
.w-stages.is-compact .stage-dot { width: 22px; height: 22px; font-size: 0.68rem; }
.w-stages.is-compact .stage::before { inset-inline-start: 10px; top: 26px; bottom: -5px; }
.w-kv { display: grid; gap: 0; grid-template-columns: minmax(0, 1fr); margin: 0; }
.w-kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.w-kv dt { color: var(--muted); font-size: 0.82rem; flex: none; }
.w-kv dd { font-weight: 600; font-size: 0.88rem; text-align: end; min-width: 0; overflow-wrap: anywhere; }
.w-kv.is-two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
.w-kv.is-inline { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 16px; }
.w-kv.is-inline > div { display: grid; gap: 2px; border: 0; padding: 0; }
.w-kv.is-inline dd { text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-kv.is-inline dt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-desc { margin-top: 10px; font-size: 0.86rem; white-space: pre-line; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.w-info { margin: 0; line-height: 1.6; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.w-stats { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px; }
.w-stats > div { display: grid; gap: 2px; min-width: 0; }
.w-stats small { font-size: 0.76rem; color: var(--muted); }
.w-stats b { font-size: 1.05rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-stat { display: grid; gap: 4px; align-content: center; height: 100%; color: inherit; }
.w-stat b { font-size: 1.6rem; font-weight: 800; }
.w-stat span { font-size: 0.8rem; }
.w-week { display: flex; gap: 6px; height: 100%; align-items: stretch; }
.w-day { flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 1fr auto auto; justify-items: center; gap: 2px; padding: 4px 2px; border-radius: 10px; color: inherit; }
.w-day:hover { background: var(--surface-2); }
.w-day.is-today { background: var(--brand-50); }
.w-day b { font-size: 0.78rem; font-weight: 700; }
.w-day small { font-size: 0.72rem; color: var(--muted); }
.w-day.is-missing small { color: var(--warn); font-weight: 700; }
.w-day-bar { width: 8px; height: 100%; min-height: 8px; border-radius: 99px; background: var(--surface-3); display: flex; align-items: flex-end; overflow: hidden; }
.w-day-bar > span { width: 100%; height: var(--p); background: var(--brand-500); border-radius: 99px; transition: height 320ms var(--ease); }
.w-week-total { flex: none; display: grid; align-content: center; justify-items: center; padding-inline: 10px; border-inline-start: 1px dashed var(--line); }
.w-week-total b { font-size: 1.1rem; font-weight: 800; }
.w-week-total small { font-size: 0.74rem; color: var(--muted); }
.w-aging { display: grid; gap: 10px; }
.w-aging .aging { height: 12px; }
.w-legend { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 8px; }
.w-legend a { display: grid; gap: 1px; min-width: 0; padding: 6px 8px; border-radius: 8px; color: inherit; }
.w-legend a:hover { background: var(--surface-2); }
.w-legend small { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-legend small i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.w-legend b { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-team { display: flex; align-items: center; gap: 12px; height: 100%; min-width: 0; }
.w-team > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; }
.w-types { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 8px 14px; }
.w-types > div { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.w-types b { margin-inline-start: auto; }
.w-quick { display: grid; gap: 8px; }
.w-quick.is-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.w-quick .btn { justify-content: flex-start; min-width: 0; }

/* ---- motion: fluid drag & resize */
.grid-stack-animate .grid-stack-item { transition: left 320ms var(--ease), right 320ms var(--ease), top 320ms var(--ease), width 320ms var(--ease), height 320ms var(--ease); }
.board .grid-stack-animate > .grid-stack-item.grid-stack-placeholder { transition: left 180ms var(--ease), right 180ms var(--ease), top 180ms var(--ease), width 180ms var(--ease), height 180ms var(--ease); }
.board .grid-stack > .grid-stack-placeholder > .placeholder-content { background: color-mix(in srgb, var(--brand-500) 9%, transparent); border: 2px dashed color-mix(in srgb, var(--brand-500) 50%, transparent); border-radius: var(--r-lg); }
.board .grid-stack-item.ui-draggable-dragging > .wcard,
.board .grid-stack-item.ui-resizable-resizing > .wcard { opacity: 1; box-shadow: var(--shadow-3); border-color: color-mix(in srgb, var(--brand-500) 45%, var(--line)); }
.board .grid-stack-item.ui-draggable-dragging > .wcard { transform: scale(1.02) rotate(-0.35deg); }
.board .grid-stack-item.ui-draggable-dragging .w-head { cursor: grabbing; }
body.board-busy { user-select: none; -webkit-user-select: none; }
body.board-busy .w-body { pointer-events: none; }
.grid-stack-item.is-leaving > .wcard { opacity: 0; transform: scale(.96); }
.grid-stack-item.is-new > .wcard { animation: w-pop 520ms var(--ease); }
@keyframes w-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
/* resize handle: a small corner bracket at the tile's end corner */
.board .grid-stack-item > .ui-resizable-handle { background: none; transform: none; width: 22px; height: 22px; opacity: 0; transition: opacity 160ms; }
.board .grid-stack-item > .ui-resizable-sw { bottom: 8px; left: 8px; cursor: nesw-resize; }
.board .grid-stack-item > .ui-resizable-se { bottom: 8px; right: 8px; cursor: nwse-resize; }
.board .grid-stack-item > .ui-resizable-handle::before { content: ''; position: absolute; inset: 6px; border-bottom: 2.5px solid var(--faint); border-radius: 0 0 0 4px; }
.board .grid-stack-item > .ui-resizable-sw::before { border-left: 2.5px solid var(--faint); }
.board .grid-stack-item > .ui-resizable-se::before { border-right: 2.5px solid var(--faint); border-radius: 0 0 4px 0; }
.board .grid-stack-item:hover > .ui-resizable-handle, .board .grid-stack-item.ui-resizable-resizing > .ui-resizable-handle { opacity: 1; }
.board .grid-stack-item > .ui-resizable-handle:hover::before { border-color: var(--brand-500); }
@media (hover: none) { .board .grid-stack-item > .ui-resizable-handle { opacity: .8; } }
.reduce-motion .grid-stack-item, .reduce-motion .wcard, .reduce-motion .w-body { transition: none !important; animation: none !important; }
.reduce-motion .board .grid-stack-item.ui-draggable-dragging > .wcard { transform: none; }

/* ---- tile menu: standard sizes (3 × 3 picker) */
.w-menu { position: fixed; z-index: 90; width: 218px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-3); animation: w-menu-in 160ms var(--ease); }
@keyframes w-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.w-menu-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.w-menu-cap { color: var(--ink); }
.size-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; direction: rtl; }
.sp-cell { aspect-ratio: 1.35; border-radius: 6px; border: 1.5px solid var(--line-strong); background: var(--surface-2); cursor: pointer; transition: background 120ms, border-color 120ms; }
.sp-cell.is-on { background: var(--brand-100); border-color: var(--brand-500); }
.sp-cell.is-current { box-shadow: inset 0 0 0 2px var(--brand-500); }
.size-picker:hover .sp-cell.is-on:not(.is-hover) { background: var(--surface-2); border-color: var(--line-strong); }
.sp-cell.is-hover { background: color-mix(in srgb, var(--brand-500) 28%, var(--surface)); border-color: var(--brand-500); }
.sp-cell:disabled { opacity: .35; cursor: not-allowed; }
.sp-cell:focus-visible { outline: none; box-shadow: var(--ring); }
.w-menu-note { margin: 8px 0 0; font-size: 0.76rem; }
.w-menu-sep { height: 1px; background: var(--line); margin: 10px -10px 6px; }
.w-menu [role="menuitem"] { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px; border: 0; border-radius: 7px; background: none; font-size: 0.86rem; color: var(--ink-2); text-align: start; cursor: pointer; }
.w-menu [role="menuitem"]:hover, .w-menu [role="menuitem"]:focus-visible { background: var(--surface-3); color: var(--ink); outline: none; }
.rot-up { transform: rotate(90deg); }
.board-add-list { display: grid; gap: 0; }
.board-add-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.board-add-list li:last-child { border-bottom: 0; }
.board-add-list .grow { display: grid; gap: 2px; min-width: 0; }

/* ---- timesheets work area (calendar) below the board */
.ts-work { display: grid; gap: 18px; }

/* ---- profile */
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.profile-grid > * { min-width: 0; }
.profile-id { display: flex; align-items: center; gap: 16px; }
.profile-id h2 { font-size: 1.15rem; font-weight: 800; }
.profile-id .avatar-lg { --av: 56px; font-size: 1.1rem; }
.pref-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.pref-toggle > span:first-child { display: grid; gap: 2px; min-width: 0; }
.pref-toggle b { font-weight: 600; font-size: 0.9rem; }
.pref-toggle small { font-size: 0.78rem; color: var(--muted); }
.pref-toggle .switch { flex: none; }
.pref-seg { align-self: start; }
.pref-status { min-width: 60px; text-align: end; }
.pref-status.is-ok { color: var(--ok); }
.pref-status.is-error { color: var(--danger); }
.plain-list { display: grid; gap: 4px; font-size: 0.86rem; }
.plain-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1024px) { .profile-grid { grid-template-columns: minmax(0, 1fr); } }
a.user-chip { color: inherit; border-radius: var(--r-full); }
a.user-chip:hover .avatar, a.user-chip[aria-current="page"] .avatar { box-shadow: 0 0 0 3px var(--brand-100); }

/* ---- density: compact */
.density-compact .page { padding-top: 0; }
.density-compact .card-head { padding: 12px 18px; }
.density-compact .card-body { padding: 14px 18px; }
.density-compact .list > li, .density-compact .task { padding-block: 9px; }
.density-compact .table td, .density-compact .table th { padding-block: 8px; }
.density-compact .page-head { margin-bottom: 14px; }
.density-compact .w-head { height: 42px; }
.density-compact .w-list > li { padding-block: 6px; }


/* ==========================================================================
   Visual layer v2 — ideas adopted (as concepts, no code copied) from shadcn/ui
   (semantic tokens, Sheet, Tooltip, Kbd, Skeleton, Empty, Sonner, collapsible
   Sidebar), Twenty CRM (relation chips, deterministic colours, tags, side panel,
   Kanban, dense record lists) and Magic/Animate UI (number ticker, sliding tabs).
   ========================================================================== */
:root {
  /* shadcn-style semantic aliases over the existing palette */
  --background: var(--canvas); --foreground: var(--ink);
  --card: var(--surface); --popover: var(--surface);
  --muted-bg: var(--surface-3); --accent-bg: var(--surface-3);
  --border: var(--line); --input: var(--line-strong);
  --radius: 12px; --radius-sm: 8px; --radius-md: 10px; --radius-lg: 12px; --radius-xl: 16px;
  --chart-1: #15803d; --chart-2: #0ea5e9; --chart-3: #f59e0b; --chart-4: #8b5cf6; --chart-5: #ef4444;
  --sidebar-w-icon: 64px;
  --sheet-w: min(520px, 94vw);
  /* Twenty-style tag palette (fg / bg) */
  --tg-blue: #1d4ed8;   --tg-blue-bg: #e6eeff;
  --tg-green: #15803d;  --tg-green-bg: #e3f5e8;
  --tg-amber: #a15c07;  --tg-amber-bg: #fdf1d7;
  --tg-red: #c2261d;    --tg-red-bg: #fde8e6;
  --tg-violet: #6d28d9; --tg-violet-bg: #efe8fd;
  --tg-cyan: #0e7490;   --tg-cyan-bg: #dff4f8;
  --tg-pink: #be185d;   --tg-pink-bg: #fce7f1;
  --tg-teal: #0f766e;   --tg-teal-bg: #dcf4f1;
  --tg-orange: #c2410c; --tg-orange-bg: #fdeadf;
  --tg-indigo: #4338ca; --tg-indigo-bg: #e8e8fd;
}
:root[data-theme="dark"] {
  --chart-1: #4ade80; --chart-2: #38bdf8; --chart-3: #fbbf24; --chart-4: #a78bfa; --chart-5: #f87171;
  --tg-blue: #9cbcff;   --tg-blue-bg: rgba(96, 140, 255, .16);
  --tg-green: #7ee2a0;  --tg-green-bg: rgba(74, 222, 128, .14);
  --tg-amber: #f5c96b;  --tg-amber-bg: rgba(245, 180, 60, .15);
  --tg-red: #fca5a5;    --tg-red-bg: rgba(248, 113, 113, .15);
  --tg-violet: #c9b6fd; --tg-violet-bg: rgba(167, 139, 250, .16);
  --tg-cyan: #7dd8ec;   --tg-cyan-bg: rgba(34, 211, 238, .14);
  --tg-pink: #f9a8d4;   --tg-pink-bg: rgba(244, 114, 182, .15);
  --tg-teal: #7de0d4;   --tg-teal-bg: rgba(45, 212, 191, .14);
  --tg-orange: #fdba8c; --tg-orange-bg: rgba(251, 146, 60, .15);
  --tg-indigo: #b4b8fd; --tg-indigo-bg: rgba(129, 140, 248, .16);
}
.t-blue { --tg: var(--tg-blue); --tgb: var(--tg-blue-bg); }
.t-green { --tg: var(--tg-green); --tgb: var(--tg-green-bg); }
.t-amber { --tg: var(--tg-amber); --tgb: var(--tg-amber-bg); }
.t-red { --tg: var(--tg-red); --tgb: var(--tg-red-bg); }
.t-violet { --tg: var(--tg-violet); --tgb: var(--tg-violet-bg); }
.t-cyan { --tg: var(--tg-cyan); --tgb: var(--tg-cyan-bg); }
.t-pink { --tg: var(--tg-pink); --tgb: var(--tg-pink-bg); }
.t-teal { --tg: var(--tg-teal); --tgb: var(--tg-teal-bg); }
.t-orange { --tg: var(--tg-orange); --tgb: var(--tg-orange-bg); }
.t-indigo { --tg: var(--tg-indigo); --tgb: var(--tg-indigo-bg); }
.avatar[class*="t-"] { color: var(--tg); background: var(--tgb); }
.avatar-xs { --av: 20px; font-size: 0.6rem; }
.icon-xs { width: 12px; height: 12px; }

/* tags (Twenty) — soft pill, colour by meaning */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  color: var(--tg, var(--neutral)); background: var(--tgb, var(--neutral-bg)); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* relation chips (Twenty): avatar/icon + name, hover to reveal it's a record */
.chip-rel { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; height: 24px; padding: 0 8px 0 4px; border-radius: 6px;
  font-size: 0.84rem; font-weight: 500; color: var(--ink-2); vertical-align: middle; transition: background 100ms; }
.chip-rel .avatar { flex: none; }
.chip-rel.is-link:hover { background: var(--surface-3); color: var(--ink); }
.chip-ico { flex: none; width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; color: var(--tg, var(--muted)); background: var(--tgb, var(--surface-3)); }
.task-person { display: inline-flex; align-items: center; gap: 5px; }
.task-meta .tag { height: 20px; font-size: 0.72rem; }

/* ---------------------------------------------------------------- collapsible sidebar (shadcn Sidebar "icon" mode) */
.brand-row { display: flex; align-items: center; gap: 4px; padding-bottom: 12px; }
.brand-row .brand { flex: 1 1 auto; min-width: 0; padding-bottom: 6px; }
.brand-text { min-width: 0; white-space: nowrap; }
.sidebar-toggle { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--faint); opacity: 0; transition: opacity 160ms, background 120ms; }
.sidebar:hover .sidebar-toggle, .sidebar-toggle:focus-visible { opacity: 1; }
.sidebar-toggle:hover { background: var(--surface-3); color: var(--ink); }
.nav-link { position: relative; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .nav-link { border: 0; background: none; width: 100%; }
.sidebar-foot form { margin: 0; }
.nav-kbd { margin-inline-start: auto; font-size: 0.68rem; padding: 0 5px; }
.nav-fav-head { display: flex; align-items: center; gap: 6px; }
.nav-favs { display: grid; gap: 2px; }
.nav-fav { padding-block: 6px; font-size: 0.88rem; }
.shell { transition: grid-template-columns 260ms var(--ease); }
@media (min-width: 961px) {
  .shell.is-collapsed { grid-template-columns: var(--sidebar-w-icon) minmax(0, 1fr); }
  .shell.is-collapsed .sidebar { padding-inline: 10px; overflow-x: hidden; }
  .shell.is-collapsed .brand-text, .shell.is-collapsed .nav-label, .shell.is-collapsed .nav-section, .shell.is-collapsed .nav-kbd,
  .shell.is-collapsed .nav-link .count { display: none; }
  .shell.is-collapsed .brand-row { flex-direction: column; gap: 8px; }
  .shell.is-collapsed .brand { padding: 0; justify-content: center; }
  .shell.is-collapsed .sidebar-toggle { opacity: 1; }
  .shell.is-collapsed .nav-link { justify-content: center; padding: 10px 0; gap: 0; }
  .shell.is-collapsed .nav-link[aria-current="page"] { box-shadow: none; }
  .shell.is-collapsed .nav-favs { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
  .shell.is-collapsed .nav-link:has(.count)::after { content: ''; position: absolute; top: 7px; inset-inline-end: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); box-shadow: 0 0 0 2px var(--surface); }
}
@media (max-width: 960px) { .sidebar-toggle { display: none; } }

/* ---------------------------------------------------------------- tooltip (shadcn Tooltip) */
.tip { position: fixed; z-index: 120; max-width: 260px; padding: 6px 10px; border-radius: 7px; background: var(--ink); color: var(--surface);
  font-size: 0.78rem; font-weight: 500; line-height: 1.35; pointer-events: none; opacity: 0; transform: scale(.96); transition: opacity 120ms, transform 120ms var(--ease); box-shadow: var(--shadow-2); }
.tip.is-on { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- kbd (shadcn Kbd) */
kbd { font-family: var(--font); font-weight: 600; font-size: 0.7rem; min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 5px;
  border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--muted); direction: ltr; vertical-align: middle; }
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 22px; margin: 0; }
.shortcuts > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.shortcuts dt { display: flex; gap: 4px; flex: none; }
.shortcuts dd { margin: 0; color: var(--ink-2); font-size: 0.88rem; }
@media (max-width: 640px) { .shortcuts { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- skeleton (shadcn Skeleton, with shimmer) */
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, color-mix(in srgb, var(--surface-3) 45%, var(--surface)) 50%, var(--surface-3) 100%);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.skeleton-stack { display: grid; gap: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.w-body.is-loading { opacity: 1; }
.w-body.is-loading > * { opacity: .35; transition: opacity 160ms; }
.w-body.is-loading::after { content: ''; position: absolute; inset: 0 16px 12px; border-radius: 8px; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 100%); background-size: 200% 100%; animation: shimmer 1.1s ease-in-out infinite; }

/* ---------------------------------------------------------------- side panel / record peek (shadcn Sheet + Twenty side panel) */
.sheet { position: fixed; inset: 0 auto 0 0; width: var(--sheet-w); max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0;
  border-inline-start: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); display: flex; flex-direction: column; }
.sheet:not([open]) { display: none; }
.sheet[open] { animation: sheet-in 320ms var(--ease); }
.sheet.is-closing { animation: sheet-out 200ms var(--ease-io) forwards; }
.sheet::backdrop { background: color-mix(in srgb, var(--overlay) 55%, transparent); animation: fade-in 200ms ease; }
@keyframes sheet-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateX(-100%); } }
@keyframes fade-in { from { opacity: 0; } }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px 12px 12px; border-bottom: 1px solid var(--line); }
.sheet-head > * { flex: none; }
.sheet-head h2 { flex: 1 1 auto; min-width: 0; font-size: 1.02rem; font-weight: 700; }
.sheet-icon { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--tg, var(--brand)); background: var(--tgb, var(--brand-50)); }
.sheet-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px 28px; }
.icon-btn-sm { width: 32px; height: 32px; }
[data-sheet-fav][aria-pressed="true"] .icon, .btn-fav[aria-pressed="true"] .icon { fill: #f5b301; stroke: #d99a00; }
.btn-fav[aria-pressed="true"] { border-color: color-mix(in srgb, #f5b301 45%, var(--line)); background: color-mix(in srgb, #f5b301 10%, var(--surface)); }
.peek { display: grid; gap: 18px; }
.peek-status { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-height: 28px; }
.peek-status.task { padding: 0; border: 0; }
.peek-status-label { font-weight: 600; font-size: 0.9rem; }
.peek-props { display: grid; gap: 2px; margin: 0; }
.peek-props > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 36px; padding: 2px 6px; border-radius: 8px; }
.peek-props > div:hover { background: var(--surface-2); }
.peek-props dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.84rem; }
.peek-props dd { margin: 0; min-width: 0; font-size: 0.9rem; overflow-wrap: anywhere; }
.peek-section { display: grid; gap: 10px; }
.peek-section h3 { font-size: 0.78rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.peek-text { white-space: pre-line; font-size: 0.9rem; line-height: 1.6; color: var(--ink-2); }
.peek-progress .row { margin-bottom: 8px; font-size: 0.86rem; }
.peek-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.peek-stats > div { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.peek-stats small { font-size: 0.74rem; color: var(--muted); }
.peek-stats b { font-size: 1rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek-people { display: flex; flex-wrap: wrap; gap: 6px; }
.peek-people .chip-rel { background: var(--surface-2); border: 1px solid var(--line); }
.peek-list { display: grid; }
.peek-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.peek-list li:last-child { border-bottom: 0; }
.peek-list a.grow, .peek-list div.grow { display: grid; min-width: 0; }
.peek-list b { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peek-list small { font-size: 0.78rem; }
.peek-list a.grow:hover b { color: var(--brand); }
.peek-tasks .task { padding: 10px 0; }
.peek-feed { display: grid; gap: 12px; }
.peek-feed li { display: flex; gap: 10px; }
.peek-feed-head { display: flex; gap: 8px; align-items: baseline; font-size: 0.84rem; }
.peek-feed p { font-size: 0.88rem; color: var(--ink-2); white-space: pre-line; }
@media (max-width: 640px) { .peek-props > div { grid-template-columns: 104px minmax(0, 1fr); } .sheet-head .btn { width: 32px; padding: 0; font-size: 0; gap: 0; justify-content: center; } .sheet-head .btn .icon { width: 16px; height: 16px; } }

/* ---------------------------------------------------------------- toasts (Sonner): bottom stack, action button */
.toasts { inset-inline-start: 24px; bottom: 24px; transform: none; justify-items: start; }
.toast { min-width: 300px; border-radius: 12px; padding: 12px 12px 12px 14px; border: 1px solid color-mix(in srgb, #fff 8%, transparent); }
.toast-msg { flex: 1 1 auto; min-width: 0; }
.toast .toast-action { margin-inline-start: 0; opacity: 1; padding: 5px 10px; border-radius: 7px; font-size: 0.8rem; font-weight: 700;
  background: color-mix(in srgb, currentColor 14%, transparent); }
.toast .toast-action:hover { background: color-mix(in srgb, currentColor 22%, transparent); }
.toast .toast-close { margin-inline-start: 0; }
.toasts .toast:not(:last-child) { opacity: .92; }
@media (max-width: 640px) { .toasts { inset-inline: 12px; bottom: 12px; justify-items: stretch; } .toast { min-width: 0; } }

/* ---------------------------------------------------------------- tabs: sliding indicator (Animate UI) */
.tabs.has-indicator { position: relative; }
.tabs.has-indicator .tab[aria-selected="true"]::after { display: none; }
.tab-indicator { position: absolute; bottom: 0; right: auto; left: 0; height: 2.5px; border-radius: 2px 2px 0 0; background: var(--brand); transition: transform 280ms var(--ease), width 280ms var(--ease); pointer-events: none; }

/* ---------------------------------------------------------------- empty state (shadcn Empty) */
.empty .empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow-1), inset 0 -2px 0 var(--surface-3); color: var(--muted); }

/* ---------------------------------------------------------------- tables: dense record list (Twenty) */
.table th { font-size: 0.74rem; letter-spacing: .01em; }
.table td { padding-block: 10px; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand-500) 4%, var(--surface)); }
.table td .chip-rel { margin-inline-start: -4px; }
.table td.mono, .table td .mono { white-space: nowrap; }
.table td:has(> .row-link), .table td:has(> .row > .row-link) { min-width: 170px; }

/* ---------------------------------------------------------------- Kanban (Twenty board view) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: start; scroll-snap-type: x proximity; }
.kb-col { display: flex; flex-direction: column; min-height: 240px; max-height: calc(100vh - 240px); background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; scroll-snap-align: start; transition: background 150ms, border-color 150ms; }
.kb-col.is-over { background: color-mix(in srgb, var(--brand-500) 6%, var(--surface-2)); border-color: color-mix(in srgb, var(--brand-500) 35%, var(--line)); }
.kb-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 12px; }
.kb-count { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.kb-add { margin-inline-start: auto; opacity: .7; }
.kb-add:hover { opacity: 1; }
.kb-list { display: grid; gap: 8px; padding: 2px 10px 12px; overflow-y: auto; align-content: start; flex: 1 1 auto; }
.kb-card { position: relative; display: grid; gap: 8px; padding: 11px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-1);
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; transition: box-shadow 150ms, border-color 150ms, opacity 150ms; }
.kb-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.kb-card:focus-visible { box-shadow: var(--ring); }
.kb-card::before { content: ''; position: absolute; inset-block: 10px; inset-inline-start: 0; width: 3px; border-radius: 0 3px 3px 0; background: transparent; }
.kb-card.prio-edge-urgent::before { background: var(--danger); }
.kb-card.prio-edge-high::before { background: var(--warn); }
.kb-card.is-done { opacity: .6; }
.kb-card.is-done .kb-title { text-decoration: line-through; }
.kb-card.is-saving { opacity: .7; }
.kb-title { font-weight: 600; font-size: 0.9rem; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.kb-title:hover { color: var(--brand); }
.kb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.78rem; }
.kb-meta > span:not(.tag) { display: inline-flex; align-items: center; gap: 4px; }
.kb-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.kb-foot .chip-rel { margin-inline-start: -4px; font-size: 0.78rem; }
.kb-placeholder { border: 2px dashed color-mix(in srgb, var(--brand-500) 45%, var(--line)); background: color-mix(in srgb, var(--brand-500) 6%, transparent); border-radius: 10px; }
.kb-ghost { position: fixed; top: 0; left: 0; z-index: 130; margin: 0; pointer-events: none; box-shadow: var(--shadow-3); border-color: color-mix(in srgb, var(--brand-500) 40%, var(--line)); cursor: grabbing; will-change: transform; }
.kb-empty { display: grid; place-items: center; min-height: 64px; border: 1.5px dashed var(--line); border-radius: 10px; color: var(--faint); font-size: 0.8rem; }
body.kb-dragging, body.kb-dragging * { cursor: grabbing !important; user-select: none; }
@media (max-width: 640px) { .kanban { grid-auto-columns: 84%; } .kb-col { max-height: none; } }

/* ---------------------------------------------------------------- connectivity banner */
.net-banner { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 110; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 0.84rem; font-weight: 600; box-shadow: var(--shadow-2); }
.net-banner .link { border: 0; background: none; color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- palette (cmdk): kbd hints */
.palette-item kbd { margin-inline-start: 8px; }

/* motion off */
.reduce-motion .shell, .reduce-motion .tab-indicator, .reduce-motion .sheet, .reduce-motion .skeleton, .reduce-motion .tip { transition: none !important; animation: none !important; }


/* ---------------------------------------------------------------- timesheet calendar: office calendar states */
.cal-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
/* missing report: the whole cell is tinted yellow (not just a dot) */
.cal-day.is-missing { background: color-mix(in srgb, #facc15 22%, var(--surface)); border-color: color-mix(in srgb, #eab308 55%, var(--line)); }
button.cal-day.is-missing:hover { border-color: #ca8a04; }
.cal-missing { display: inline-flex; align-items: center; gap: 3px; font-size: 0.68rem; font-weight: 700; color: #8a5a00; white-space: nowrap; }
:root[data-theme="dark"] .cal-day.is-missing { background: color-mix(in srgb, #facc15 16%, var(--surface)); border-color: color-mix(in srgb, #facc15 45%, var(--line)); }
:root[data-theme="dark"] .cal-missing { color: #fde68a; }
/* statutory holiday / rest day: soft red, not expected */
.cal-day.is-holiday { background: color-mix(in srgb, var(--tg-red-bg) 70%, var(--surface)); border-color: color-mix(in srgb, var(--tg-red) 22%, var(--line)); }
.cal-day.is-holiday .cal-num { color: var(--tg-red); }
/* holiday eve: short day — indigo edge */
.cal-day.is-short { box-shadow: inset 0 3px 0 var(--tg-indigo); }
.cal-day.is-short.is-today { box-shadow: inset 0 3px 0 var(--tg-indigo), inset 0 0 0 1px var(--brand-500); }
.cal-tag { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; align-self: stretch; padding: 1px 6px; border-radius: 5px; font-size: 0.66rem; font-weight: 700; line-height: 1.5;
  color: var(--tg, var(--muted)); background: var(--tgb, var(--surface-3)); }
.cal-tag b { flex: none; font-weight: 800; opacity: .75; }
.cal-tag-holiday, .cal-tag-election { --tg: var(--tg-red); --tgb: color-mix(in srgb, var(--tg-red-bg) 100%, var(--surface)); }
.cal-tag-eve { --tg: var(--tg-indigo); --tgb: var(--tg-indigo-bg); }
.cal-tag-chol { --tg: var(--tg-blue); --tgb: var(--tg-blue-bg); }
.cal-tag-memorial, .cal-tag-fast { --tg: var(--neutral); --tgb: var(--neutral-bg); }
.cal-tag-observance { --tg: var(--tg-teal); --tgb: var(--tg-teal-bg); }
.cal-tag-office { --tg: var(--tg-violet); --tgb: var(--tg-violet-bg); }
.cal-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.cal-legend i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.cal-legend .lg-missing { background: color-mix(in srgb, #facc15 22%, var(--surface)); border-color: #eab308; }
.cal-legend .lg-holiday { background: var(--tg-red-bg); border-color: color-mix(in srgb, var(--tg-red) 30%, var(--line)); }
.cal-legend .lg-short { background: var(--surface); box-shadow: inset 0 3px 0 var(--tg-indigo); }
@media (max-width: 960px) { .cal-tag { font-size: 0.6rem; padding: 0 4px; } .cal-missing { font-size: 0; gap: 0; } .cal-missing .icon { width: 12px; height: 12px; } }
@media (max-width: 640px) { .cal-tag { font-size: 0; padding: 0; height: 4px; border-radius: 2px; background: var(--tg); } .cal-tag b { display: none; } }


/* ---------------------------------------------------------------- admin: office calendar */
.cal-year { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.cal-list li { display: flex; align-items: center; gap: 12px; padding: 9px 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.cal-list li:last-child { border-bottom: 0; }
.cal-list li.is-off { background: color-mix(in srgb, var(--tg-red-bg) 45%, transparent); }
.cal-date { flex: none; display: grid; justify-items: center; width: 44px; line-height: 1.2; }
.cal-date small { font-size: 0.72rem; color: var(--muted); }
.cal-rule select { width: 118px; }
.cal-list .list-sub { gap: 8px; }
/* tone utilities last so they win over component defaults (.badge etc.) */
.tone-ok { color: var(--ok); background: var(--ok-bg); }
.tone-warn { color: var(--warn); background: var(--warn-bg); }
.tone-danger { color: var(--danger); background: var(--danger-bg); }
.tone-info { color: var(--info); background: var(--info-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-neutral { color: var(--neutral); background: var(--neutral-bg); }
.tone-brand { color: var(--brand); background: var(--brand-50); }

.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.modal-foot { flex-wrap: wrap; }
@media (max-width: 960px) {
  .search-trigger { flex: 0 0 auto; width: 40px; padding: 0; justify-content: center; border-radius: var(--r-full); }
  .search-trigger span, .search-trigger kbd { display: none; }
}
@media (max-width: 640px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.cols-4 .kpi { min-height: 0; padding: 14px; }
  .grid.cols-4 .kpi-value { font-size: 1.3rem; }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-actions .btn { height: 34px; padding: 0 12px; }
  .modal-head, .modal-body, .modal-foot { padding-inline: 16px; }
}
.palette-input input:focus-visible { box-shadow: none; }

/* ---------------------------------------------------------------- overflow / overlap guards */
.input, .select, .textarea { min-width: 0; max-width: 100%; }
input[type="time"].input, input[type="date"].input { min-width: 0; }
.field { min-width: 0; }
.field > label, .label { overflow-wrap: anywhere; }
.form-grid > *, .alloc-row > *, .grid > *, .split > * { min-width: 0; }
.modal-body { overflow-x: hidden; }
.alloc-sum { gap: 12px; min-width: 200px; }
.modal-foot .spacer { flex: 1 1 0; min-width: 0; }
.row-wrap.between { justify-content: space-between; }
.kv dt, .kv dd { min-width: 0; }
@media (max-width: 640px) {
  .form-grid-4 { gap: 12px; }
  .modal-foot { flex-direction: row-reverse; justify-content: flex-start; }
  .modal-foot .spacer { display: none; }
  .modal-foot > .btn:last-child:not(.btn-primary) { margin-inline-end: auto; }
  .alloc-sum { min-width: 0; flex: 1 1 100%; }
}
.stack > *, .page > *, .card > * { min-width: 0; }
.rep-head { margin-bottom: 6px; }
.rep-stage { grid-template-columns: minmax(0, 2fr) 80px 150px 120px 90px 130px 36px; }
.rep-plan { grid-template-columns: minmax(0, 2fr) 90px 160px 36px; }
.rep-tpl { grid-template-columns: minmax(0, 2fr) 130px 110px 140px 80px 36px; }
.rep-cell { display: grid; gap: 3px; min-width: 0; }
.rep-lbl { display: none; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
@media (max-width: 760px) {
  .rep-head { display: none; }
  .rep-stage, .rep-tpl, .rep-plan { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; grid-auto-flow: row dense; gap: 8px 10px; padding: 10px 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
  .rep-lbl { display: block; }
  .rep-cell[data-area="name"] { grid-column: 1 / 3; }
  .rep-cell[data-area="a"] { grid-column: 1; }
  .rep-cell[data-area="b"] { grid-column: 2; }
  .rep-remove { grid-column: 3; grid-row: 1; align-self: end; }
}
@media (max-width: 420px) {
  .cal { gap: 3px; }
  .cal-day { min-height: 62px; padding: 5px 4px; border-radius: 9px; }
  .cal-num { font-size: 0.8rem; }
  .cal-hours { font-size: 0.8rem; }
  .cal-day .badge { display: none; }
}
input[type="date"].input-sm, input[type="time"].input-sm { padding-inline: 6px; font-size: 0.82rem; }
input[type="date"].input { padding-inline: 8px 6px; }

/* ================================================================ timesheet management, leave, approvals */
.callout { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); font-size: .88rem; }
.stack-xs { display: grid; gap: 6px; }
.is-neg { color: var(--danger) !important; }
.btn-count { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px; margin-inline-start: 2px; border-radius: 999px; background: rgba(255,255,255,.25); font-size: .72rem; font-weight: 700; }
.form-grid-3 { display: grid; gap: 12px 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.month-jump .input { width: 150px; }

/* overview */
.ov-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 4px; }
.ov-kpis .card { padding: 14px 16px; display: grid; gap: 2px; }
.ov-kpis small { color: var(--muted); font-size: .78rem; font-weight: 600; }
.ov-kpis b { font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.ov-kpis .card.is-warn { background: color-mix(in srgb, #facc15 14%, var(--surface)); border-color: color-mix(in srgb, #eab308 45%, var(--line)); }
.ov-matrix td[style*="--heat"] { background: color-mix(in srgb, var(--brand-500) calc(var(--heat) * 38%), transparent); }
.ov-matrix tfoot th { background: var(--surface-2); }
.miss-dates { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.miss-date { font-size: .74rem; padding: 2px 7px; border-radius: 6px; background: color-mix(in srgb, #facc15 22%, var(--surface)); border: 1px solid color-mix(in srgb, #eab308 45%, var(--line)); color: var(--ink); font-variant-numeric: tabular-nums; }
.miss-date:hover { border-color: #ca8a04; }

/* assignment matrix + required fields */
.assign-wrap { max-height: 70vh; }
.assign-matrix th.assign-user { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; vertical-align: bottom; padding: 10px 6px; font-weight: 600; }
.assign-matrix th.assign-user span { display: inline-flex; align-items: center; gap: 6px; }
.assign-matrix th.assign-user .avatar { transform: rotate(90deg); }
.assign-matrix .assign-cell { text-align: center; }
.assign-matrix .assign-cell input { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }
.assign-matrix tr:hover td { background: var(--surface-2); }
.sticky-col { position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 200px; }
.req-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 22px 16px; }
.req-col { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.req-col legend { display: flex; align-items: center; gap: 8px; padding: 0 6px; font-weight: 700; font-size: .86rem; }
.req-list { display: grid; gap: 6px; max-height: 300px; overflow: auto; padding: 4px 2px; }

/* approvals inbox */
.appr-sec { margin-bottom: 18px; }
.appr-banner { text-decoration: none; color: inherit; align-items: center; }
.appr-list { list-style: none; margin: 0; padding: 0; }
.appr-item { display: grid; grid-template-columns: 190px minmax(0, 1fr) 280px; gap: 16px; padding: 14px 22px; border-top: 1px solid var(--line); align-items: start; }
.appr-item:first-child { border-top: 0; }
.appr-who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.appr-note { margin: 6px 0 0; font-size: .86rem; color: var(--muted); white-space: pre-line; }
.appr-actions { display: grid; gap: 8px; justify-items: start; }
.appr-actions .input { width: 100%; }
.diff-row { display: flex; gap: 8px; align-items: baseline; font-size: .86rem; line-height: 1.6; }
.diff-k { flex: none; width: 52px; font-size: .72rem; font-weight: 700; color: var(--faint); }
.diff-old { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.diff-new { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--ok) 10%, transparent); padding: 0 4px; border-radius: 4px; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); font-size: .76rem; color: var(--ink); text-decoration: none; }
.file-chip:hover { border-color: var(--line-strong); background: var(--surface-3); }

/* balances */
.bal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.bal-card { padding: 18px 20px; display: grid; gap: 14px; }
.bal-head { display: flex; align-items: center; gap: 12px; }
.bal-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.bal-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--tgb); color: var(--tg); }
.bal-big { margin-inline-start: auto; font-size: 2rem; font-weight: 780; letter-spacing: -.03em; line-height: 1; }
.bal-big small { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.bal-bar { display: flex; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bal-bar span { width: var(--w); }
.bal-bar .u { background: var(--brand-500); }
.bal-vacation .bal-bar .u { background: var(--tg-violet, #7c3aed); }
.bal-sick .bal-bar .u { background: var(--tg-amber, #d97706); }
.bal-bar .p { background: repeating-linear-gradient(-45deg, var(--line-strong) 0 4px, transparent 4px 8px); }
.bal-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin: 0; }
.bal-dl div { display: grid; gap: 2px; }
.bal-dl dt { font-size: .74rem; color: var(--muted); }
.bal-dl dd { margin: 0; font-weight: 650; }
.bal-cell { display: grid; gap: 1px; }
.bal-cell b { font-size: 1.05rem; }
.bal-cell small { font-size: .72rem; font-variant-numeric: tabular-nums; }
.bal-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.bal-mini { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: inherit; box-shadow: var(--shadow-1); }
.bal-mini:hover { border-color: var(--line-strong); }
.bal-mini .bal-ic { width: 30px; height: 30px; border-radius: 9px; }
.bal-mini b { font-size: .98rem; }
.bal-req { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line-strong); }

/* leave dialog */
.leave-calc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.leave-calc div { display: grid; gap: 2px; text-align: center; }
.leave-calc small { font-size: .74rem; color: var(--muted); }
.leave-calc b { font-size: 1.25rem; font-weight: 750; }
.dropzone { display: flex; align-items: center; gap: 10px; padding: 16px; border: 2px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; font-size: .86rem; color: var(--muted); transition: border-color var(--dur), background var(--dur); }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand-500); background: color-mix(in srgb, var(--brand-500) 6%, var(--surface)); }
.dropzone b { color: var(--brand); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: .84rem; }
.file-list li { display: flex; gap: 10px; align-items: center; }

/* day editor states */
.day-banner { margin-bottom: 14px; align-items: center; }
.day-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.day-fields:disabled { opacity: .72; }
.change-reason { margin-bottom: 14px; padding: 10px 12px; border-radius: var(--r-md); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line)); }

/* calendar: drafts, pending, change requests */
.cal-day.is-draft { border-style: dashed; border-color: color-mix(in srgb, var(--tg-violet, #7c3aed) 45%, var(--line)); background: color-mix(in srgb, var(--tg-violet-bg, #ede9fe) 35%, var(--surface)); }
.cal-day.is-pending { background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--tg-amber-bg, #fef3c7) 70%, var(--surface)) 0 6px, var(--surface) 6px 12px); border-color: color-mix(in srgb, var(--tg-amber, #d97706) 40%, var(--line)); }
.cal-day.has-change { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--tg-amber, #d97706) 55%, transparent); }
.cal-flag { display: inline-flex; align-items: center; gap: 3px; font-size: .66rem; font-weight: 700; color: var(--tg-amber, #b45309); }
.cal-flag-draft { color: var(--tg-violet, #6d28d9); padding: 0 5px; border-radius: 5px; background: var(--tg-violet-bg, #ede9fe); }
.cal-legend .lg-draft { border-style: dashed !important; border-color: var(--tg-violet, #7c3aed) !important; background: var(--tg-violet-bg, #ede9fe); }
.cal-legend .lg-pending { background: repeating-linear-gradient(-45deg, var(--tg-amber-bg, #fef3c7) 0 3px, var(--surface) 3px 6px); border-color: var(--tg-amber, #d97706) !important; }

/* history timeline */
.timeline { list-style: none; margin: 0; padding: 4px 22px 18px; display: grid; gap: 0; }
.timeline li { position: relative; padding: 10px 0 10px 0; padding-inline-start: 18px; border-inline-start: 2px solid var(--line); }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -6px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand-500); }
.tl-changes { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: .8rem; }
.tl-ch del { color: var(--muted); }
.tl-ch ins { text-decoration: none; font-weight: 600; }

/* printable hours report */
.print-page { background: #eef0f3; }
.rep-toolbar { display: flex; gap: 10px; justify-content: center; padding: 16px; }
.report { max-width: 1000px; margin: 0 auto 40px; background: #fff; color: #111; padding: 34px 38px; border-radius: 10px; box-shadow: 0 2px 20px rgba(0,0,0,.08); font-size: 12.5px; }
.rep-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 14px; margin-bottom: 16px; }
.rep-co { font-weight: 700; color: #555; font-size: 13px; }
.rep-head h1 { font-size: 20px; margin: 4px 0 0; }
.rep-meta { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 18px; margin: 0; }
.rep-meta div { display: flex; gap: 6px; }
.rep-meta dt { color: #666; }
.rep-meta dd { margin: 0; font-weight: 600; }
.rep-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
.rep-kpis div { border: 1px solid #ddd; border-radius: 8px; padding: 8px 10px; display: grid; }
.rep-kpis small { color: #666; font-size: 11px; }
.rep-kpis b { font-size: 16px; }
.rep-table { width: 100%; border-collapse: collapse; }
.rep-table th, .rep-table td { border: 1px solid #ddd; padding: 4px 6px; text-align: start; vertical-align: top; }
.rep-table thead th { background: #f3f4f6; font-size: 11px; }
.rep-table tr.is-off td { background: #fafafa; color: #777; }
.rep-table tr.is-missing td { background: #fff7d6; }
.rep-table tfoot th { background: #f3f4f6; }
.rep-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; }
.rep-cols h2 { font-size: 14px; margin: 0 0 6px; }
.rep-small td { padding: 3px 6px; }
.rep-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 40px; }
.rep-sign div { display: grid; gap: 30px; font-size: 12px; color: #444; }
.rep-sign i { border-bottom: 1px solid #111; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .no-print, .rep-toolbar { display: none !important; }
  .print-page { background: #fff; }
  .report { box-shadow: none; padding: 0; max-width: none; margin: 0; border-radius: 0; }
  .rep-table tr { break-inside: avoid; }
}

@media (max-width: 900px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .req-grid { grid-template-columns: 1fr; }
  .appr-item { grid-template-columns: 1fr; gap: 10px; }
  .bal-grid { grid-template-columns: 1fr; }
  .bal-dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .rep-kpis { grid-template-columns: repeat(2, 1fr); }
  .rep-cols { grid-template-columns: 1fr; }
  .report { padding: 18px; }
  .bal-strip .spacer { display: none; }
}
.t-neutral { --tg: var(--muted); --tgb: var(--surface-3); }
.card-head-wrap { flex-wrap: wrap; gap: 10px; }
.rep-scroll { overflow-x: auto; }

@media print { .rep-scroll { overflow: visible; } }

/* month picker sits right on top of the monthly calendar */
.cal-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.month-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.month-pick { position: relative; display: flex; align-items: center; }
.month-pick .month-pick-ic { position: absolute; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--brand); pointer-events: none; }
.month-select { font-size: 1.12rem; font-weight: 750; height: 42px; min-width: 210px; padding-inline-start: 38px; border-radius: var(--r-md); cursor: pointer; }
@media (max-width: 560px) { .month-select { min-width: 0; font-size: 1rem; } .cal-bar .hint { width: 100%; } }
.month-step { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.cal-bar .hint { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 560px) { .month-nav, .month-step { width: 100%; } .month-pick { flex: 1; } .month-select { width: 100%; } }
.is-switching .cal, .is-switching .cal-bar .month-step { opacity: .55; transition: opacity .15s; pointer-events: none; }
.palette-answer .md p{margin:0 0 4px}.palette-answer .md ul,.palette-answer .md ol{margin:4px 0;padding-inline-start:20px}.palette-answer .md code{font-family:var(--font-mono,monospace);font-size:.9em}

/* ------------------------------------------------------------ step rail (first-run / guided flows) */
.step-rail { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.step-rail .step { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-2, inherit); text-decoration: none; background: var(--surface); font-size: .88rem; }
.step-rail .step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: .78rem; }
.step-rail .step.is-current { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.step-rail .step.is-current .step-n { background: var(--brand); color: #fff; }
.step-rail .step.is-done .step-n { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
@media (max-width: 640px) { .step-rail .step-l { display: none; } .step-rail .step.is-current .step-l { display: inline; } }
.wiz-foot { flex-wrap: wrap; gap: 8px; }
.wiz-foot > .row { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 420px) { .wiz-foot .btn { padding-inline: 10px; } }
