/* Team EKG — light theme is the default; dark is opt-in via the toggle. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --ink: #12151c;
  --ink-2: #474f5f;
  --muted: #737b8c;
  --line: #e1e4ea;
  --line-strong: #cdd2da;
  --accent: #e0334f;
  --accent-hover: #c8233f;
  --accent-soft: #fde8ec;
  --accent-ink: #ffffff;
  --focus: #2a78d6;
  --up: #067a32;
  --up-soft: #e3f5ea;
  --down: #c62828;
  --down-soft: #fdeaea;
  --flat: #737b8c;
  --op: #067a32;
  --dev: #256abf;
  --cpt: #7a4fc9;
  --star: #e8a400;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 4px 14px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* chart tokens (validated reference palette) */
  --chart-surface: #fcfcfb;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #9a9a93;
  --bar: #2a78d6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1015;
  --surface: #171a21;
  --surface-2: #1e222b;
  --surface-3: #272c37;
  --ink: #f1f3f7;
  --ink-2: #c1c7d3;
  --muted: #8d95a5;
  --line: #2a2f3a;
  --line-strong: #3a4150;
  --accent: #f0475f;
  --accent-hover: #ff5e74;
  --accent-soft: #3a1820;
  --focus: #5a9ff0;
  --up: #3ccf6e;
  --up-soft: #12301d;
  --down: #ff6b6b;
  --down-soft: #3a1717;
  --flat: #8d95a5;
  --op: #3ccf6e;
  --dev: #6da7ec;
  --cpt: #b39af0;
  --star: #ffc53d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6);
  --chart-surface: #1a1a19;
  --grid: #2c2c2a;
  --axis: #383835;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #6f6f69;
  --bar: #3987e5;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg);
  min-height: 100vh; font-variant-numeric: normal;
}
a { color: var(--focus); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 18px 0 8px; }
p { margin: 0 0 8px; }
code { font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: 4px; display: block; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 2000; border-radius: 8px; }
.skip-link:focus { left: 8px; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 1000; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 clamp(12px, 3vw, 28px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.2s ease, background 0.2s ease;
}
.topbar.scrolled { background: var(--surface); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-logo { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em; }
.brand-tagline { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.main-nav { display: flex; gap: 4px; margin-left: 12px; }
.nav-link { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.on { color: var(--ink); background: var(--surface-2); }
.nav-badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 0.72rem; padding: 0 7px; line-height: 18px; font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-area { display: flex; align-items: center; gap: 8px; }
.msg-btn { position: relative; }
.dot-badge { position: absolute; top: -2px; right: -4px; background: var(--accent); color: var(--accent-ink); font-size: 0.66rem; font-weight: 800; border-radius: 999px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.new-project-btn {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: var(--accent-ink);
  background: var(--accent); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent); text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease;
}
.new-project-btn .icon { width: 26px; height: 26px; stroke-width: 2.6; }
.new-project-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.avatar-btn { list-style: none; cursor: pointer; border-radius: 999px; display: block; }
.avatar-btn::-webkit-details-marker { display: none; }

/* language selector (AG-WEB-STANDARDS) */
.lang-selector-wrapper { position: relative; }
.lang-selector-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 0.82rem var(--font); cursor: pointer; }
.lang-selector-btn:hover { background: var(--surface-2); }
.lang-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px); width: 250px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 1100; overflow: hidden; }
.lang-dropdown.active { display: block; }
.lang-search { padding: 8px; border-bottom: 1px solid var(--line); }
.lang-search input { width: 100%; }
.lang-list { list-style: none; margin: 0; padding: 4px; max-height: 300px; overflow-y: auto; }
.lang-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.lang-item:hover { background: var(--surface-2); }
.lang-item.active { background: var(--accent-soft); font-weight: 700; }
.lang-endonym { margin-left: auto; color: var(--muted); font-size: 0.82rem; }

/* ---------------------------------------------------------------- base controls */
.btn, .icon-btn, .seg-btn, .th-btn, .val-btn, .star-btn, .person-link, .step-check { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--down); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover, .btn-ghost.on { background: var(--surface-2); }
.btn-ghost.on { border-color: var(--line-strong); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 0.84rem; border-radius: 8px; }
.btn-block { width: 100%; height: 44px; }
.btn-join { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn-join:hover { background: var(--accent-soft); }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent;
  background: transparent; cursor: pointer; color: var(--ink-2); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--down); background: var(--down-soft); }
.icon-btn-sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn-sm .icon { width: 15px; height: 15px; }
#theme-toggle { border: 1px solid var(--line); background: var(--surface); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent); outline-offset: 0; border-color: var(--focus); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
input[type="range"] { accent-color: var(--accent); min-height: 0; padding: 0; border: 0; background: transparent; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.86rem; color: var(--ink-2); text-decoration: none; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-btn input { position: absolute; opacity: 0; pointer-events: none; }
.seg-sm .seg-btn { padding: 5px 8px; }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-btn { flex: 1; justify-content: center; padding: 9px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.chip.need { background: var(--accent-soft); color: var(--accent); }
.chip.need-stalled { background: var(--down-soft); color: var(--down); }
.chip.need-funding { background: color-mix(in srgb, var(--series-4) 18%, var(--surface)); color: color-mix(in srgb, var(--series-4) 70%, var(--ink)); }
.chip.tag { background: var(--surface-2); border: 1px solid var(--line); font-weight: 500; }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: middle; }
.badge-archived { background: var(--surface-3); color: var(--muted); }
.badge-ok { background: var(--up-soft); color: var(--up); }
.count-pill { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: 0.8rem; }
.role-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.role-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 0.72rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.role-tag .icon { width: 12px; height: 12px; }
.role-owner { background: color-mix(in srgb, var(--star) 22%, var(--surface)); color: color-mix(in srgb, var(--star) 55%, var(--ink)); }
.role-manager, .role-admin { background: color-mix(in srgb, var(--dev) 16%, var(--surface)); color: var(--dev); }
.role-lead { background: color-mix(in srgb, var(--cpt) 16%, var(--surface)); color: var(--cpt); }
.role-contact { background: color-mix(in srgb, var(--op) 16%, var(--surface)); color: var(--op); }

.avatar { --av: #6b7280; display: inline-grid; place-items: center; border-radius: 999px; background: var(--av); color: #fff; font-weight: 700; flex: none; letter-spacing: 0.02em; }
.avatar-sm { width: 24px; height: 24px; font-size: 0.66rem; }
.avatar-md { width: 36px; height: 36px; font-size: 0.8rem; }
.avatar-lg { width: 44px; height: 44px; font-size: 0.95rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.5rem; }
.person-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 2px 6px 2px 2px; margin-left: -2px; border-radius: 999px; cursor: pointer; text-align: left; color: var(--ink); }
.person-link:hover { background: var(--surface-2); }
.person-link:hover span:last-child { text-decoration: underline; }

/* menus built on <details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 1100; display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.menu-right { left: auto; right: 0; }
.menu-pop .check { padding: 6px 8px; border-radius: 8px; }
.menu-pop .check:hover { background: var(--surface-2); }
.menu-pop a, .menu-pop button[role="menuitem"] { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; border: 0; background: transparent; cursor: pointer; font: inherit; text-align: left; }
.menu-pop a:hover, .menu-pop button[role="menuitem"]:hover { background: var(--surface-2); }
.menu-pop .nav-badge { margin-left: auto; }
.menu-head { display: flex; gap: 10px; align-items: center; padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head > div { display: flex; flex-direction: column; }
.menu-head .muted { font-size: 0.82rem; }
.menu-danger { color: var(--down) !important; }
.menu-pop > .btn { margin-top: 6px; }

/* ---------------------------------------------------------------- layout */
.view { max-width: 1720px; margin: 0 auto; padding: 20px clamp(12px, 3vw, 28px) 64px; outline: none; }
.loading, .empty, .error { padding: 40px 12px; text-align: center; color: var(--muted); }
.error { color: var(--down); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.panel-head h2 { margin: 0; }
.panel-sub { color: var(--muted); font-size: 0.86rem; margin: 0 0 12px; }
.panel-accent { border-color: var(--accent); background: linear-gradient(0deg, var(--surface), var(--surface)), var(--accent-soft); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; margin-bottom: 18px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.88rem; width: 100%; }
.back-link:hover { color: var(--ink); }
.ph-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; flex: 1 1 auto; min-width: 0; }
.ph-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.ph-title h1 { overflow-wrap: anywhere; }
.ph-value { display: flex; align-items: center; gap: 10px; }
.ph-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mode-pill { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* ---------------------------------------------------------------- value + delta */
.value-block { display: inline-flex; align-items: center; gap: 4px; }
.value-num {
  display: inline-flex; align-items: baseline; border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 0 4px; color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; cursor: default;
}
.value-num.editable { cursor: text; }
.value-num.editable:hover { border-color: var(--line-strong); background: var(--surface-2); }
.value-num:disabled { opacity: 1; }
.value-num .num { font-size: 1.3rem; letter-spacing: -0.02em; }
.value-lg .num { font-size: 1.6rem; }
.value-xl .num { font-size: 2.4rem; }
.cond { font-size: 0.62em; font-weight: 800; margin-left: 2px; vertical-align: sub; letter-spacing: 0.02em; }
.value-num .cond { font-size: 0.72rem; }
.value-xl .cond { font-size: 0.95rem; }
.cond-Op { color: var(--op); } .cond-Dev { color: var(--dev); } .cond-Cpt { color: var(--cpt); }
.cond-label { font-weight: 700; }
.val-btn {
  width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; color: var(--ink-2); flex: none;
}
.val-btn .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.val-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-2); }
.val-btn:active { transform: scale(0.94); }
.value-xl .val-btn { width: 36px; height: 36px; border-radius: 10px; }
.value-xl .val-btn .icon { width: 18px; height: 18px; }
.value-input { width: 84px; font-weight: 800; font-size: 1.1rem; text-align: center; font-variant-numeric: tabular-nums; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 0.86rem; border-radius: 7px; padding: 2px 7px 2px 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .icon { width: 15px; height: 15px; stroke-width: 2.6; }
.delta-up { color: var(--up); background: var(--up-soft); }
.delta-down { color: var(--down); background: var(--down-soft); }
.delta-flat { color: var(--flat); background: var(--surface-2); }
.delta-sm { font-size: 0.74rem; padding: 1px 5px 1px 3px; }
.delta-sm .icon { width: 12px; height: 12px; }
.num-sm { font-weight: 700; font-variant-numeric: tabular-nums; }

.star-btn { border: 0; background: transparent; cursor: pointer; color: var(--line-strong); width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 7px; flex: none; }
.star-btn:hover { color: var(--star); background: var(--surface-2); }
.star-btn.on { color: var(--star); }
.star-lg { width: 38px; height: 38px; }
.star-lg .icon { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- dashboard */
.dock { margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.dock-title { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.dock-title .icon { color: var(--star); width: 15px; height: 15px; }
.dock-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; }
.dock-tile { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 6px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); flex: none; scroll-snap-align: start; max-width: 340px; }
.dock-tile.is-archived { opacity: 0.6; }
.dock-name { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.dock-name:hover { text-decoration: underline; }
.dock-val { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.dock-val .cond { font-size: 0.68rem; }
.dock-empty { margin: 0; color: var(--muted); font-size: 0.88rem; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.dash-side { order: 1; }
@media (min-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .dash-side { order: 0; position: sticky; top: calc(var(--topbar-h) + 16px); }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 200px; min-width: 160px; }
.tb-field { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--ink-2); font-weight: 600; }
.tb-field select { min-height: 34px; padding: 5px 8px; }
.size-field input { width: 120px; }
.tb-check { font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
.tb-count { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--muted); }
.filter-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.fp-item { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fp-item .fi { text-transform: none; letter-spacing: 0; font-weight: 400; }
.fp-item.active > span { color: var(--accent); }
.fi { min-height: 32px; padding: 4px 8px; font-size: 0.84rem; width: 100%; border-radius: 7px; }
.fi-group { display: flex; gap: 4px; }
.fi-group .fi-num { width: 64px; flex: none; }
.fi-group input[type="date"] { flex: 1 1 0; min-width: 0; }
.fp-item .fi-group { flex-wrap: wrap; }
.fi-num { max-width: 90px; }

/* list table */
.ptable { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.9rem; }
.ptable th, .ptable td { padding: 10px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.ptable thead th { background: var(--surface-2); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); white-space: nowrap; }
.ptable thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.ptable thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.ptable tr.is-archived td { opacity: 0.62; }
.ptable tr.is-fav td:first-child { box-shadow: inset 3px 0 0 var(--star); }
.filter-row th { padding: 6px 8px; background: var(--surface) !important; font-weight: 400; text-transform: none; letter-spacing: 0; }
.filter-row th.active .fi { border-color: var(--accent); }
.view-dashboard:not(.filters-open) .filter-row { display: none; }
.th-btn { border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; display: inline-flex; gap: 4px; align-items: center; font-weight: 700; }
.th-btn:hover { color: var(--ink); }
.sort-ind { opacity: 0.35; font-size: 0.7rem; }
.sort-ind.on { opacity: 1; color: var(--accent); }
.col-name { min-width: 200px; }
.col-value { white-space: nowrap; }
.col-description { min-width: 220px; max-width: 360px; }
.col-nextSteps, .col-lastSteps { min-width: 230px; max-width: 320px; }
.col-needs { min-width: 170px; }
.col-needs .chip { white-space: normal; }
.col-actions { white-space: nowrap; width: 1%; }
.name-cell { display: flex; align-items: center; gap: 4px; }
.pname { color: var(--ink); font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.pname:hover { text-decoration: underline; color: var(--accent); }
.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.joined-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 0.74rem; font-weight: 700; color: var(--up); padding: 0 6px; }
.joined-badge .icon { width: 14px; height: 14px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.86rem; }
.steps li { display: flex; gap: 6px; align-items: baseline; }
.steps li time { margin-left: auto; font-size: 0.74rem; white-space: nowrap; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; transform: translateY(-2px); }
.step-ico { width: 13px; height: 13px; color: var(--up); flex: none; transform: translateY(2px); }
.steps-done span { color: var(--ink-2); }
.desc { margin: 0; color: var(--ink-2); font-size: 0.88rem; white-space: pre-line; }
.desc-more summary { list-style: none; cursor: pointer; color: var(--ink-2); font-size: 0.88rem; }
.desc-more summary::-webkit-details-marker { display: none; }
.desc-toggle { color: var(--focus); font-weight: 600; margin-left: 4px; white-space: nowrap; }
.desc-more[open] summary { display: none; }
.ext-link { display: inline-flex; gap: 4px; align-items: center; font-size: 0.86rem; }
.ext-link .icon { width: 14px; height: 14px; }

/* cards */
.card-grid { --card-min: 300px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr)); gap: 14px; }
.pcard { container-type: inline-size; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.15s ease; }
.pcard:hover { box-shadow: var(--shadow); }
.pcard.is-archived { opacity: 0.68; }
.pcard.is-fav { border-color: color-mix(in srgb, var(--star) 55%, var(--line)); }
.pcard-inner { padding: 14px; display: flex; flex-direction: column; gap: 12px; height: 100%; }
.pcard-head { display: flex; flex-direction: column; gap: 8px; }
.pcard-title { display: flex; align-items: flex-start; gap: 4px; min-width: 0; }
.pcard-title .pname { font-size: 1.08rem; line-height: 1.3; padding-top: 2px; }
.pcard-value { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@container (min-width: 340px) {
  .pcard-head { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .pcard-value { flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
}
.pcard-fields { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
@container (min-width: 440px) { .pcard-fields { grid-template-columns: 1fr 1fr; } .pf-description, .pf-nextSteps, .pf-lastSteps { grid-column: 1 / -1; } }
.pf dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.pf dd { margin: 0; font-size: 0.88rem; min-width: 0; }
.pcard-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.pcard-foot .row-actions { justify-content: flex-start; }
.pcard-foot .row-actions > :first-child { margin-right: auto; }

/* chart */
.chart-panel { background: var(--surface); }
.chart-body { position: relative; }
.pie-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
@media (min-width: 700px) and (max-width: 1279px) { .pie-wrap { flex-direction: row; align-items: flex-start; } .pie-wrap .legend { flex: 1; } }
.pie { width: 220px; height: 220px; flex: none; overflow: visible; }
.pie-slice { stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: opacity 0.12s ease; }
.pie:hover .pie-slice { opacity: 0.55; }
.pie .pie-slice:hover, .pie .pie-slice:focus-visible { opacity: 1; outline: none; }
.pie-total { text-anchor: middle; font-weight: 800; font-size: 26px; fill: var(--ink); font-family: var(--font); }
.pie-total-label { text-anchor: middle; font-size: 11px; fill: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font); }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 2px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; cursor: pointer; font-size: 0.86rem; }
.legend li:hover, .legend li:focus-visible { background: var(--surface-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.lg-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.lg-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.lg-pct { color: var(--muted); font-variant-numeric: tabular-nums; width: 38px; text-align: right; }
.bar-wrap { max-height: 560px; overflow-y: auto; }
.bars { width: 100%; height: auto; display: block; }
.bars .grid { stroke: var(--grid); stroke-width: 1; }
.bars .axis { stroke: var(--axis); stroke-width: 1; }
.bars .tick { font-size: 10px; fill: var(--muted); text-anchor: middle; font-family: var(--font); font-variant-numeric: tabular-nums; }
.bar { fill: var(--bar); }
.bar-hit { fill: transparent; }
.bar-row { cursor: pointer; outline: none; }
.bar-row:hover .bar-hit, .bar-row:focus-visible .bar-hit { fill: var(--surface-2); }
.bar-label { font-size: 11.5px; fill: var(--ink-2); text-anchor: end; font-family: var(--font); }
.bar-val { font-size: 11px; fill: var(--ink); font-weight: 700; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); padding: 5px 9px; border-radius: 7px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; z-index: 5; box-shadow: var(--shadow); }
.chart-empty { color: var(--muted); text-align: center; padding: 30px 0; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.chart-table th, .chart-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.chart-table a { color: var(--ink); }

/* ---------------------------------------------------------------- project detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1000px) { .detail-grid { grid-template-columns: minmax(0, 1fr) 360px; } }
.detail-main > .panel + .panel, .detail-side > .panel + .panel { margin-top: 16px; }
.prose { color: var(--ink-2); line-height: 1.6; margin: 0; }
.step-list { list-style: none; margin: 0 0 10px; padding: 0; }
.step-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.step-list li:last-child { border-bottom: 0; }
.step-text { flex: 1; min-width: 0; }
.step-meta { font-size: 0.8rem; white-space: nowrap; }
.step-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); background: transparent; display: grid; place-items: center; cursor: pointer; color: transparent; flex: none; }
.step-check:hover { border-color: var(--up); color: var(--up); }
.step-check .icon { width: 14px; height: 14px; }
.step-list.done .step-text { color: var(--ink-2); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input:not([type="checkbox"]) { flex: 1 1 180px; }
.history { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.history li { display: grid; grid-template-columns: 78px minmax(110px, auto) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.kv-list { margin: 0; display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.people li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.project-form, .manager-panel { margin-top: 0; }
.manager-panel { margin-top: 16px; border-color: color-mix(in srgb, var(--dev) 35%, var(--line)); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; border: 0; padding: 0; margin: 0; }
.fld > span, .fld > legend { font-size: 0.82rem; font-weight: 700; color: var(--ink-2); padding: 0; }
.fld-wide { grid-column: 1 / -1; }
.fld .seg-btn { flex-direction: column; gap: 0; align-items: flex-start; padding: 6px 14px; }
.fld .seg-btn span { font-size: 0.74rem; font-weight: 500; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.form-grid > .form-actions { margin-top: 0; }
.chip-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-pick { position: relative; cursor: pointer; }
.chip-pick input { position: absolute; opacity: 0; }
.chip-pick span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 0.84rem; font-weight: 600; color: var(--ink-2); }
.chip-pick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-pick input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.step-editor { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.step-row { display: flex; gap: 6px; align-items: center; }
.step-row input { flex: 1; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.simple-table th, .simple-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.simple-table th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.simple-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.offer-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.offer-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 10px; background: var(--surface-2); border-radius: 9px; }
.offer-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.danger-zone { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line-strong); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.danger-zone h3 { width: 100%; margin: 0 0 4px; color: var(--down); }
.person-cell { display: flex; align-items: center; gap: 10px; }
.log-details code { white-space: pre-wrap; word-break: break-all; font-size: 0.76rem; }
.tabs { margin-bottom: 16px; }

/* ---------------------------------------------------------------- messages */
.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.msg.unread { border-left: 4px solid var(--accent); }
.msg summary { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer; list-style: none; }
.msg summary::-webkit-details-marker { display: none; }
.msg-head { flex: 1; min-width: 0; }
.msg-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-top time { margin-left: auto; font-size: 0.8rem; }
.msg.unread .msg-subject { font-weight: 700; }
.msg-subject { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-body { padding: 0 14px 14px 62px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.kind-tag { font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.kind-offer { background: color-mix(in srgb, var(--star) 22%, var(--surface)); }
.kind-project { background: color-mix(in srgb, var(--dev) 15%, var(--surface)); color: var(--dev); }
.kind-all { background: var(--accent-soft); color: var(--accent); }
.compose .fld { margin-bottom: 12px; }
.recipient-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 4px; display: flex; flex-direction: column; margin-top: 6px; }
.recipient { padding: 6px 8px; border-radius: 7px; }
.recipient:hover { background: var(--surface-2); }
.recipient-tools { display: flex; gap: 4px; margin-top: 4px; }

/* ---------------------------------------------------------------- profile */
.profile-top { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.profile-top h3 { margin: 0; font-size: 1.2rem; }
.profile-top p { margin: 0; }
.profile-card h4 { margin: 16px 0 8px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.profile-projects { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.profile-projects li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-projects a { font-weight: 700; color: var(--ink); }
.color-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick { width: 32px; height: 32px; border-radius: 50%; background: var(--av); cursor: pointer; position: relative; display: grid; place-items: center; }
.color-pick input { position: absolute; opacity: 0; }
.color-pick:has(input:checked) { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.color-pick:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 4px; }
.passkeys { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.passkeys li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 9px; }
.passkeys li > div { display: flex; flex-direction: column; }
.detail-side form.panel .fld { margin-bottom: 10px; }

/* ---------------------------------------------------------------- login */
.view-login { max-width: 1100px; }
.login-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; min-height: calc(100vh - var(--topbar-h) - 90px); }
@media (min-width: 900px) { .login-wrap { grid-template-columns: 1.15fr 1fr; gap: 48px; } }
.login-hero { text-align: center; }
@media (min-width: 900px) { .login-hero { text-align: left; } }
.login-logo { width: 220px; height: auto; }
.login-hero h1 { font-size: clamp(2.2rem, 5vw, 3.2rem); font-weight: 850; letter-spacing: -0.03em; margin-top: 8px; }
.tagline { color: var(--ink-2); font-size: 1.08rem; margin: 6px 0 22px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; text-align: left; box-shadow: var(--shadow-sm); }
.stat-num { font-size: 1.9rem; font-weight: 850; letter-spacing: -0.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-accent .stat-num { color: var(--accent); }
.login-panel { padding: 22px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------------------------------------------------------- modal / toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.5); display: grid; place-items: center; padding: 16px; z-index: 1500; animation: fade 0.12s ease; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal-wide { width: min(720px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.08rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 2000; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 0.9rem; transition: opacity 0.4s ease, transform 0.4s ease; }
.toast-ok { background: var(--up); color: #fff; }
.toast-error { background: var(--down); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .brand-tagline { display: none; }
  .main-nav { display: none; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 58px; }
  .topbar { gap: 8px; }
  .brand-text { display: none; }
  .top-actions { gap: 6px; }
  .lang-selector-btn { padding: 0 8px; }
  #current-lang-flag { display: none; }
  .new-project-btn { width: 42px; height: 42px; border-radius: 12px; }
  h1 { font-size: 1.35rem; }
  .value-xl .num { font-size: 2rem; }
  .tb-count { margin-left: 0; width: 100%; }
  .toolbar .search { flex-basis: 100%; }
  /* table rows become labelled blocks on phones */
  .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
  .ptable thead tr:first-child { display: none; }
  .ptable thead .filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 8px; }
  .view-dashboard:not(.filters-open) .ptable thead { display: none; }
  .ptable thead .filter-row th { display: block; padding: 0; border: 0; }
  .ptable thead .filter-row th:empty { display: none; }
  .ptable tbody tr { border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .ptable td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 110px 1fr; gap: 8px; max-width: none !important; }
  .ptable td::before { content: attr(data-label); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding-top: 3px; }
  .ptable td.col-name, .ptable td.col-actions { display: block; }
  .ptable td.col-name::before, .ptable td.col-actions::before { content: none; }
  .ptable td.col-name .pname { font-size: 1.05rem; }
  .ptable td.col-actions .row-actions { justify-content: flex-start; margin-top: 4px; }
  .ptable tr.is-fav td:first-child { box-shadow: none; }
  .ptable tr.is-fav { box-shadow: inset 3px 0 0 var(--star); }
  .msg-body { padding-left: 14px; }
  .history li { grid-template-columns: 70px 1fr; }
  .kv { grid-template-columns: 100px 1fr; }
  .dash-side .pie { width: 180px; height: 180px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { .pie-slice, .bar { stroke: CanvasText; } }
