/* ==== tokens.css ==== */
/* ============================================================
   Beacon CRM design tokens — "candy professional" territory:
   rounded friendly type, approachable card clusters, candy
   palette tuned for enterprise legibility. Bouncy motion is
   reserved strictly for celebratory moments (won deals).
   ============================================================ */

:root {
  /* type */
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-base: 13.5px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 21px; --fs-2xl: 26px;
  --fw-medium: 550; --fw-bold: 700;

  /* candy accents (light-tuned) */
  --berry: #8655f6;      --berry-soft: #efe9ff;   --berry-ink: #5c34c4;
  --bubble: #f0679e;     --bubble-soft: #ffe9f2;
  --mint: #14a37f;       --mint-soft: #defaf0;
  --ocean: #2f80d6;      --ocean-soft: #e3effc;
  --citrus: #de8b12;     --citrus-soft: #fdf1d8;
  --candy: #ef5d75;      --candy-soft: #ffe6eb;

  /* semantic status */
  --ok: #17966b;        --ok-soft: #ddf5ec;
  --warn: #c47f17;      --warn-soft: #fcf0d6;
  --bad: #d64553;       --bad-soft: #fdeaed;
  --info: #2f80d6;      --info-soft: #e3effc;

  /* object identity colors */
  --obj-account: #3573c9;
  --obj-contact: #109a78;
  --obj-lead: #8250df;
  --obj-opportunity: #d97e0b;
  --obj-case: #e4526e;
  --obj-activity: #0f95a5;

  /* neutral ramps (light) */
  --bg: #f4f6fb;
  --bg-glow-a: rgba(134, 85, 246, .07);
  --bg-glow-b: rgba(20, 163, 127, .05);
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --surface-sunken: #eef1f8;
  --ink: #1c2340;
  --ink-soft: #444e73;
  --muted: #69718f;
  --faint: #99a0ba;
  --line: #e3e7f2;
  --line-strong: #cdd4e8;

  /* interactive */
  --accent: var(--berry);
  --accent-ink: var(--berry-ink);
  --accent-soft: var(--berry-soft);
  --on-accent: #ffffff;

  /* shape & depth */
  --r-sm: 7px; --r: 11px; --r-lg: 16px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(28, 35, 64, .05), 0 1px 6px rgba(28, 35, 64, .04);
  --shadow-2: 0 2px 6px rgba(28, 35, 64, .06), 0 10px 26px rgba(28, 35, 64, .09);
  --shadow-3: 0 6px 16px rgba(28, 35, 64, .12), 0 22px 48px rgba(28, 35, 64, .16);
  --shadow-accent: 0 4px 14px rgba(134, 85, 246, .32);

  /* motion — bouncy springs reserved for celebration only */
  --t-fast: 130ms cubic-bezier(.25, .6, .3, 1);
  --t-med: 220ms cubic-bezier(.25, .6, .3, 1);
  --spring: 420ms cubic-bezier(.34, 1.56, .64, 1);

  /* density-driven metrics (comfortable default) */
  --row-h: 40px;
  --pad-y: 9px;
  --pad-x: 13px;
  --topbar-h: 52px;

  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 62%, white);
}

/* accent personalization presets (settings) */
[data-accent="berry"]   { --accent:#8655f6; --accent-ink:#5c34c4; --accent-soft:#efe9ff; }
[data-accent="bubble"]  { --accent:#e25589; --accent-ink:#b03360; --accent-soft:#ffe9f2; }
[data-accent="mint"]    { --accent:#12987a; --accent-ink:#0b6e59; --accent-soft:#defaf0; }
[data-accent="ocean"]   { --accent:#2778ce; --accent-ink:#175a9e; --accent-soft:#e3effc; }
[data-accent="citrus"]  { --accent:#cf7f10; --accent-ink:#8f570b; --accent-soft:#fdf1d8; }
[data-accent="graphite"]{ --accent:#55607e; --accent-ink:#39415a; --accent-soft:#eceff7; }

[data-theme="dark"] {
  --berry: #9d7bff;  --berry-soft: #2b2350; --berry-ink: #c3adff;
  --mint: #2ec498;   --mint-soft: #12332c;
  --bubble: #ff84ae; --bubble-soft: #3d1f30;
  --ocean: #63a9f5;  --ocean-soft: #17293f;
  --citrus: #eeb04c; --citrus-soft: #3a2c12;
  --candy: #ff7f96;  --candy-soft: #401d28;

  --ok: #33bd8d;   --ok-soft: #11302a;
  --warn: #edb24f; --warn-soft: #382b12;
  --bad: #ff7280;  --bad-soft: #421c26;
  --info: #6fb2f8; --info-soft: #17293f;

  --obj-account: #6aa8f0;
  --obj-contact: #3ecfa4;
  --obj-lead: #ab82f5;
  --obj-opportunity: #f0a63c;
  --obj-case: #ff8095;
  --obj-activity: #3cc0cf;

  --bg: #11141d;
  --bg-glow-a: rgba(157, 123, 255, .08);
  --bg-glow-b: rgba(46, 196, 152, .05);
  --surface: #191e2c;
  --surface-2: #1f2537;
  --surface-sunken: #141826;
  --ink: #eaedf8;
  --ink-soft: #c2c8dd;
  --muted: #939bb8;
  --faint: #6b7292;
  --line: #293149;
  --line-strong: #364160;

  --accent-soft: color-mix(in srgb, var(--accent) 24%, #10131c);
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 1px 6px rgba(0,0,0,.32);
  --shadow-2: 0 2px 8px rgba(0,0,0,.42), 0 12px 30px rgba(0,0,0,.38);
  --shadow-3: 0 8px 20px rgba(0,0,0,.5), 0 26px 56px rgba(0,0,0,.45);
  --shadow-accent: 0 4px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* density */
[data-density="compact"] {
  --row-h: 32px;
  --pad-y: 6px;
  --pad-x: 10px;
}

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

/* ==== base.css ==== */
/* Base: reset, typography, primitives (buttons, fields, badges, tables). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--bg-glow-a), transparent 60%),
    radial-gradient(900px 420px at -10% 108%, var(--bg-glow-b), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: var(--fw-bold); letter-spacing: -.01em; }
h1 { font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
svg { display: block; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2.5px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row--stretch { justify-content: space-between; }
.col { display: flex; flex-direction: column; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.bold { font-weight: var(--fw-bold); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  user-select: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: var(--shadow-accent); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); color: var(--on-accent); }
.btn--danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn--danger:hover { background: var(--bad-soft); color: var(--bad); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-sunken); box-shadow: none; }
.btn--sm { padding: 4px 10px; font-size: var(--fs-sm); }
.btn svg { flex: 0 0 auto; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.is-active { color: var(--accent); background: var(--accent-soft); }
.icon-btn[disabled] { opacity: .35; pointer-events: none; }

/* ---------- fields ---------- */
.field-label {
  display: block; font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 4px;
}
.field-label .req-mark { color: var(--bad); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; padding: 7px 11px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  color: var(--ink); font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.textarea { resize: vertical; min-height: 64px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 49%, var(--muted) 50%), linear-gradient(-135deg, transparent 49%, var(--muted) 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[readonly] { background: var(--surface-sunken); color: var(--muted); }
.input[disabled], .textarea[disabled], .select[disabled] { opacity: .55; cursor: not-allowed; }
.input--error { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.field-error { display: block; color: var(--bad); font-size: var(--fs-xs); margin-top: 3px; }
.field-help { color: var(--faint); font-size: var(--fs-xs); margin-top: 3px; }
.checkbox { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto; }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1.6;
  background: var(--surface-sunken); color: var(--ink-soft); white-space: nowrap;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .badge--accent { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--berry-ink); }
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

kbd.kbd {
  display: inline-block; min-width: 18px; text-align: center;
  padding: 1px 5px; border-radius: 5px;
  background: var(--surface-sunken); border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft);
}

/* ---------- avatars & object icons ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: var(--fw-bold);
  font-size: 12px; flex: 0 0 auto; user-select: none;
}
.avatar.sz-20 { width: 20px; height: 20px; font-size: 9px; }
.avatar.sz-26 { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.sz-34 { width: 34px; height: 34px; font-size: 13px; }
.avatar.sz-44 { width: 44px; height: 44px; font-size: 17px; }
.avatar.sq { border-radius: 30%; }

.obj-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: color-mix(in srgb, var(--obj-c, var(--accent)) 14%, transparent);
  color: var(--obj-c, var(--accent));
}
[data-theme="dark"] .obj-badge { background: color-mix(in srgb, var(--obj-c, var(--accent)) 20%, transparent); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px; }
.card-hover { transition: box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast); }
.card-hover:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); border-color: var(--line-strong); }

/* ---------- data table primitive ---------- */
.dtable { width: 100%; border-collapse: separate; border-spacing: 0; }
.dtable th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: .05em; text-transform: uppercase; text-align: left;
  padding: 0 12px; height: 38px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.dtable td {
  height: var(--row-h); padding: 0 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px;
}
.dtable tbody tr { transition: background var(--t-fast); }
.dtable tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.dtable tbody tr.is-selected { background: var(--accent-soft); }
[data-theme="dark"] .dtable tbody tr.is-selected { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.dtable tbody tr.is-keynav { box-shadow: inset 2px 0 0 var(--accent); }
.dtable th.sortable { cursor: pointer; user-select: none; }
.dtable th.sortable:hover { color: var(--ink); }
.th-resizer {
  position: absolute; top: 0; right: 0; width: 6px; height: 100%;
  cursor: col-resize; pointer-events: none; touch-action: none;
}
.th-resizer:hover::after { content: ""; position: absolute; inset: 8px 2px; background: var(--accent); border-radius: 4px; }
th.rel { position: relative; }

/* ---------- tooltip (hover discovery pattern) ---------- */
.tip-host { position: relative; }
.tip {
  position: absolute; z-index: 400; left: 50%; bottom: calc(100% + 7px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 10px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-2);
}
.tip.below { bottom: auto; top: calc(100% + 7px); }
.tip-host:hover > .tip, .tip-host:focus-within > .tip, .tip.show { opacity: 1; transform: translateX(-50%) translateY(0); transition-delay: 260ms; }
.tip.tip-multiline { white-space: normal; text-align: left; max-height: 220px; overflow-y: auto; line-break: anywhere; }

/* ---------- skeleton shimmer (real waits only) ---------- */
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, color-mix(in srgb, var(--surface-sunken) 40%, var(--surface)) 45%, var(--surface-sunken) 65%);
  background-size: 200% 100%;
  animation: shimmer 1.15s infinite linear;
}

/* ---------- misc animation utilities ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.anim-rise { animation: riseIn var(--t-med) both; }
.anim-pop { animation: popIn var(--t-fast) both; }
.anim-fade { animation: fadeIn var(--t-med) both; }

/* celebratory spring — won deals only */
.celebrate-pop { animation: celebratePop var(--spring) both; }
@keyframes celebratePop {
  0% { transform: scale(.72); }
  55% { transform: scale(1.09) rotate(1.2deg); }
  78% { transform: scale(.97) rotate(-.6deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes confettiFall {
  0% { transform: translate3d(0, -10px, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 56vh, 0) rotate(var(--rot, 540deg)); opacity: 0; }
}
.confetti-piece { position: fixed; z-index: 9000; width: 8px; height: 12px; border-radius: 2px; pointer-events: none; animation: confettiFall var(--dur, 1400ms) cubic-bezier(.25,.46,.45,.94) forwards; }

/* progress bar primitive */
.meter { display: block; height: 7px; background: var(--surface-sunken); border-radius: 99px; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width var(--t-med); }

/* ==== components.css ==== */
/* Shared components: modal, drawer, menus, toasts, confirm, empty states, path, savebar. */

/* ---------- modal & overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 800;
  background: color-mix(in srgb, var(--ink) 34%, transparent);
  backdrop-filter: blur(2.5px);
  animation: fadeIn var(--t-fast) both;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px;
}
.modal {
  width: min(640px, 100%); max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); border: 1px solid var(--line);
  animation: popIn var(--t-med) both;
}
.modal--wide { width: min(860px, 100%); }
.modal--narrow { width: min(430px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 9px;
  padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }

/* right slide-in drawer (filter panel etc.) */
.drawer-wrap { position: fixed; inset: 0; z-index: 700; background: color-mix(in srgb, var(--ink) 22%, transparent); animation: fadeIn var(--t-fast) both; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(430px, 94vw);
  background: var(--surface); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  animation: drawerIn var(--t-med) both;
}
@keyframes drawerIn { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-foot { display: flex; gap: 9px; justify-content: space-between; padding: 13px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ---------- dropdown menu ---------- */
.menu {
  position: fixed; z-index: 850; min-width: 210px; max-width: 330px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-3);
  padding: 6px; animation: popIn var(--t-fast) both;
  max-height: 70vh; overflow-y: auto;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: var(--fs-base); text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.menu-item:hover, .menu-item.is-keynav { background: var(--accent-soft); color: var(--accent-ink); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover, .menu-item.danger.is-keynav { background: var(--bad-soft); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }
.menu-title { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding: 7px 10px 3px; }

/* ---------- toasts ---------- */
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 11px; width: 100%;
  background: var(--ink); color: var(--bg);
  padding: 11px 14px; border-radius: var(--r); box-shadow: var(--shadow-3);
  animation: toastIn var(--spring) both;
}
[data-theme="dark"] .toast { background: #262d44; color: var(--ink); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.toast.leaving { transition: opacity var(--t-med), transform var(--t-med); opacity: 0; transform: translateY(8px); }
.toast-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-medium); font-size: var(--fs-base); }
.toast .btn { background: rgba(255,255,255,.14); color: inherit; border-color: transparent; flex: 0 0 auto; }
[data-theme="dark"] .toast .btn { background: rgba(255,255,255,.08); }
.toast .btn:hover { background: rgba(255,255,255,.26); }
.toast-icon { flex: 0 0 auto; color: var(--ok); }
.toast--error .toast-icon { color: var(--bad); }
.toast--info .toast-icon { color: var(--info); }
html[data-theme="dark"] .toast-icon { filter: saturate(1.2); }

/* ---------- empty states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center; padding: 46px 20px;
}
.empty-art { opacity: .9; }
.empty-state h3 { font-size: var(--fs-md); }
.empty-state p { color: var(--muted); max-width: 380px; font-size: var(--fs-base); }

/* ---------- save bar (pending inline edits) ---------- */
.savebar {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 600; display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-pill); padding: 7px 9px 7px 17px;
  box-shadow: var(--shadow-3);
  animation: saveBarUp var(--spring) both;
}
@keyframes saveBarUp { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.savebar-leaving { transition: all var(--t-med); opacity: 0; transform: translateX(-50%) translateY(16px); }

/* ---------- guided path (opportunity stages) ---------- */
.path { display: flex; align-items: stretch; user-select: none; overflow-x: auto; padding-bottom: 2px; }
.path-step {
  --step-c: var(--accent);
  position: relative; display: flex; align-items: center;
  cursor: pointer; border: none; background: none; padding: 0;
}
.path-step:not(:first-child)::before {
  content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 16px;
  background: var(--step-bg-done, var(--surface)); clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
  z-index: 0;
}
.path-step::after {
  content: ""; position: absolute; right: -1px; top: 0; bottom: 0; width: 17px;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
  z-index: 1; transition: background var(--t-med);
}
.path-tab {
  position: relative; z-index: 1;
  min-width: 118px; height: 32px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 15px 0 17px;
  background: var(--step-bg, var(--surface-sunken));
  color: var(--step-fg, var(--muted));
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  transition: background var(--t-med), color var(--t-med);
}
.path-step:first-child .path-tab { border-radius: 7px 0 0 7px; }
.path-step.done::after { background: var(--step-color); }
.path-step.current::after { background: var(--step-color); }
.path-step.current .path-tab { color: #fff; }
.path-step.done .path-tab { color: var(--step-color-deep, currentColor); }
.path-check { width: 13px; height: 13px; border-radius: 50%; background: rgba(255,255,255,.35); display: inline-flex; align-items: center; justify-content: center; }
.path-step.current .path-check { background: rgba(255,255,255,.99); color: var(--step-color); }
.path-guidance {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 11px 15px;
  display: flex; gap: 12px; align-items: flex-start;
  animation: riseIn var(--t-med) both;
}

/* ---------- highlight chips / stage bounce for column counters ---------- */
.stage-total.bounce { animation: celebratePop var(--spring); }

/* kanban drag affordances */
.kan-card.dragging { opacity: .45; rotate: 1.6deg; scale: 1.02; box-shadow: var(--shadow-3); z-index: 5; }
.kan-col.drag-over { outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 4px; background: color-mix(in srgb, var(--accent) 5%, transparent); }
.kan-drop-gap { height: 0 !important; border-top: 2px dashed var(--accent); margin-top: -1px; transition: height var(--t-fast); }

/* ==== shell.css ==== */
/* App shell: topbar, app launcher, tabs, search, utility dock, notifications tray. */

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 500;
}
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 6px 4px 2px; border-radius: var(--r-sm); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ff8fb8));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-accent);
}
.brand-name { font-weight: var(--fw-bold); font-size: var(--fs-md); letter-spacing: -.02em; }
.brand-env { font-size: 9.5px; font-weight: var(--fw-bold); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: -3px; }

.top-search {
  position: relative; width: min(430px, 34vw); margin-left: 6px; transition: width var(--t-med), box-shadow var(--t-fast);
}
.top-search .search-shell {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 11px;
  background: var(--surface-sunken);
  border: 1px solid transparent; border-radius: var(--r-pill);
  color: var(--muted);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.search-hint { font-size: var(--fs-xs); opacity: .75; }
.top-search.open .search-shell { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 16%, transparent); }
.top-search input { flex: 1; border: none; outline: none; background: transparent; color: var(--ink); min-width: 0; }
.search-pop {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 850;
  max-height: min(480px, 62vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3); padding: 7px;
  animation: popIn var(--t-fast) both;
}

/* launcher */
.launcher-btn {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: var(--r-pill);
  color: var(--ink-soft); border: 1px solid transparent;
}
.launcher-btn:hover { background: var(--surface-sunken); }
.launcher-grid {
  position: fixed; z-index: 840;
  width: 420px; max-width: calc(100vw - 20px);
  background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--line); box-shadow: var(--shadow-3);
  padding: 17px; animation: popIn var(--t-fast) both;
}
.launcher-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 13px; }
.app-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 9px; }
.app-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 13px 6px 11px; border-radius: var(--r);
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  cursor: pointer;
}
.app-tile:hover { background: var(--surface-sunken); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.app-tile-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--tc, var(--accent)) 15%, transparent);
  color: var(--tc, var(--accent));
}
[data-theme="dark"] .app-tile-icon { background: color-mix(in srgb, var(--tc, var(--accent)) 22%, transparent); }

/* object tabs row */
.obj-tabs { display: flex; align-items: stretch; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.obj-tabs::-webkit-scrollbar { display: none; }
.obj-tab {
  position: relative; white-space: nowrap;
  padding: 8px 12px; color: var(--muted); font-weight: var(--fw-medium); font-size: var(--fs-base);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: color var(--t-fast), background var(--t-fast);
}
.obj-tab::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: transparent;
  transition: background var(--t-fast), transform var(--t-fast);
  transform: scaleX(.55); transform-origin: bottom;
}
.obj-tab:hover { color: var(--ink); background: var(--surface-sunken); }
.obj-tab.is-active { color: var(--accent-ink); font-weight: var(--fw-bold); }
[data-theme="dark"] .obj-tab.is-active { color: var(--berry-ink); }
.obj-tab.is-active::after { background: var(--accent); transform: scaleX(1); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.dot-badge {
  position: absolute; top: 3px; right: 2px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 99px; background: var(--candy); color: #fff;
  font-size: 9.5px; font-weight: var(--fw-bold);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.tray-panel {
  position: fixed; z-index: 845; top: calc(var(--topbar-h) + 6px);
  right: 10px; width: min(400px, calc(100vw - 18px));
  max-height: min(560px, 74vh); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  animation: popIn var(--t-fast) both;
}
.tray-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.tray-body { overflow-y: auto; padding: 7px; }
.notif-item { display: flex; gap: 11px; padding: 11px 12px; border-radius: var(--r); cursor: pointer; transition: background var(--t-fast); }
.notif-item:hover { background: var(--surface-sunken); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: color-mix(in srgb, var(--accent) 13%, var(--surface)); }
.notif-icon { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.notif-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 99px; flex: 0 0 auto; margin-top: 7px; }

/* ---------- main region ---------- */
#main { flex: 1 1 auto; overflow-y: auto; scroll-behavior: smooth; }
.page { padding: 22px 26px 90px; max-width: 1560px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; flex-wrap: wrap; }
.page-title h1 { line-height: 1.2; }
.page-sub { color: var(--muted); margin-top: 3px; font-size: var(--fs-base); }

/* ---------- utility dock ---------- */
.util-dock {
  position: fixed; left: 0; bottom: 0; z-index: 550;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 5px; border-radius: 0 var(--r-lg) 0 0;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.util-dock .icon-btn { position: relative; }

/* boot splash */
.boot-splash {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 17px;
  background: var(--bg);
  transition: opacity var(--t-med), visibility var(--t-med);
}
.boot-splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }

/* ==== views.css ==== */
/* List views: header bar, filter chips, table grid, kanban board, mass action bar. */

.lv-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 13px; }
.lv-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.view-picker-wrap { position: relative; }
.view-picker-btn { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); font-weight: var(--fw-bold); }
.view-picker-btn:hover { box-shadow: var(--shadow-1); background: var(--surface-2); }

.chips-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: -6px 0 13px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3.5px 10px; border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
[data-theme="dark"] .filter-chip { color: var(--berry-ink); }
.filter-chip button { display: flex; opacity: .7; } .filter-chip button:hover { opacity: 1; }

.list-shell { position: relative; }
.list-head-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.count-pill { font-size: var(--fs-sm); color: var(--muted); font-weight: var(--fw-medium); }
.inline-search { position: relative; width: 210px; }
.inline-search input { padding-left: 30px; height: 32px; font-size: var(--fs-sm); }
.inline-search svg { position: absolute; left: 9px; top: 8px; color: var(--faint); pointer-events: none; }

.grid-card { overflow: hidden; padding: 0; }
.table-scroll { overflow-x: auto; }
.cell-inline-trigger { cursor: cell; }
.row-edit-input { height: 27px; padding: 2px 8px; font-size: var(--fs-sm); border-radius: 6px; width: 100%; min-width: 90px; }
.cell-flash { animation: cellFlash 1s both; }
@keyframes cellFlash { 0% { background: color-mix(in srgb, var(--accent) 25%, transparent); } 100% { background: transparent; } }

.massbar-host { min-height: 54px; }
.massbar-slot { margin-top: 11px; }

.row-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity var(--t-fast); vertical-align: middle; }
tr:hover .row-actions, tr:focus-within .row-actions, tr.is-keynav .row-actions { opacity: 1; }

.pagination { display: flex; align-items: center; gap: 5px; justify-content: flex-end; padding: 11px 3px 2px; }
.page-btn {
  min-width: 28px; height: 28px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  transition: background var(--t-fast), color var(--t-fast);
}
.page-btn:hover:not([disabled]) { background: var(--surface-sunken); color: var(--ink); }
.page-btn.is-current { background: var(--accent); color: #fff; font-weight: var(--fw-bold); }
.page-btn[disabled] { opacity: .35; }

/* column manager */
.colmgr-item { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--r-sm); cursor: grab; user-select: none; }
.colmgr-item:hover { background: var(--surface-sunken); }
.colmgr-item .drag-cursor { cursor: grab; color: var(--faint); }
.drag-follow { position: fixed; z-index: 1000; pointer-events: none; background: var(--surface); box-shadow: var(--shadow-2); border: 1px solid var(--line-strong); border-radius: var(--r-sm); opacity: .95; }

/* ---------------- Kanban board ---------------- */
.kanban-board { display: flex; gap: 14px; align-items: stretch; padding-bottom: 18px; overflow-x: auto; }
.kan-col {
  --col-accent: var(--accent);
  flex: 0 0 292px; max-height: calc(100vh - 250px);
  display: flex; flex-direction: column;
  background: var(--surface-sunken);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  transition: outline var(--t-fast), background var(--t-fast);
}
.kan-col-head { padding: 12px 14px 9px; }
.kan-col-title { display: flex; align-items: center; gap: 8px; font-weight: var(--fw-bold); font-size: var(--fs-base); }
.kan-stage-dot { width: 9px; height: 9px; border-radius: 99px; background: var(--col-accent); flex: 0 0 auto; }
.kan-col-totals { display: flex; gap: 7px; margin-top: 7px; align-items: baseline; }
.stage-total { font-size: var(--fs-md); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.kan-count-chip { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-bold); background: var(--surface); padding: 1px 8px; border-radius: 99px; }
.kan-prob-tag { margin-left: auto; font-size: var(--fs-xs); color: var(--faint); font-weight: var(--fw-bold); }
.kan-cards { flex: 1; overflow-y: auto; padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 9px; }
.kan-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 13px;
  cursor: grab; user-select: none;
  box-shadow: var(--shadow-1);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), background var(--t-med);
}
.kan-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.kan-card.is-selected-kb { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 34%, transparent), var(--shadow-1); }
[data-theme="dark"] .kan-card.is-selected-kb { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.kan-card.flash-drop { animation: celebratePop var(--spring); }
.kan-card-name { font-weight: var(--fw-bold); font-size: var(--fs-base); line-height: 1.35; }
.kan-meta { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.kan-meta-row { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.kan-amount { font-size: var(--fs-md); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.kan-close-flag { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.kan-empty-note { text-align: center; color: var(--faint); font-size: var(--fs-sm); padding: 22px 8px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); }
.closing-soon { color: var(--warn); }
.overdue-close { color: var(--bad); }
.won-glow { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 40%, transparent), var(--shadow-1); }

/* generic fields row in non-opp kanban cards */
.kan-tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* ==== record.css ==== */
/* Record page: highlights panel, path, tabs, related lists, feed, activity timeline. */

.record-layout { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 20px; align-items: start; }
.record-main { min-width: 0; }
.record-side { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 90px); }

.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); margin-bottom: 9px; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--accent-ink); text-decoration: underline; }

/* highlights panel — approachable card cluster */
.highlights {
  background: linear-gradient(160deg, color-mix(in srgb, var(--obj-c, var(--accent)) 9%, var(--surface)) 0%, var(--surface) 46%);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 17px 19px 15px;
}
.hl-head { display: flex; align-items: center; gap: 13px; }
.hl-title-wrap { min-width: 0; }
.hl-name { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.015em; line-height: 1.25; cursor: pointer; border-radius: var(--r-sm); display: inline-block; padding: 1px 3px; margin: -1px -3px; }
.hl-name:hover { background: color-mix(in srgb, var(--obj-c, var(--accent)) 8%, transparent); }
.hl-sub { color: var(--muted); font-size: var(--fs-base); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.hl-fields { display: flex; gap: 22px; row-gap: 13px; flex-wrap: wrap; margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.hl-field { min-width: 118px; max-width: 232px; cursor: pointer; border-radius: var(--r-sm); padding: 4px 7px; margin: -4px -7px; transition: background var(--t-fast); }
.hl-field:hover { background: color-mix(in srgb, var(--obj-c, var(--accent)) 7%, transparent); }
.hl-field .field-label { margin-bottom: 2px; font-size: 10.5px; }
.hl-value { font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-value .placeholder, .empty-val { color: var(--faint); font-style: italic; font-weight: normal; }

.field-lock { color: var(--faint); margin-left: 4px; vertical-align: -2px; display: inline-flex; }

/* tabs */
.tabset { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 21px 0 16px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; padding: 9px 14px; white-space: nowrap;
  color: var(--muted); font-weight: var(--fw-medium); cursor: pointer;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tab::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background var(--t-fast), transform var(--t-fast); transform: scaleX(.55); transform-origin: bottom; }
.tab:hover { color: var(--ink); background: var(--surface-sunken); }
.tab.is-active { color: var(--accent-ink); font-weight: var(--fw-bold); }
[data-theme="dark"] .tab.is-active { color: var(--berry-ink); }
.tab.is-active::after { background: var(--accent); transform: scaleX(1); }
.tab .mini-count { background: var(--surface-sunken); border-radius: 99px; padding: 0 7px; font-size: 10.5px; margin-left: 6px; }
.tab.is-active .mini-count { background: var(--accent-soft); color: inherit; }

/* detail sections */
.detail-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 19px 22px; margin-bottom: 16px; }
.detail-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 15px 26px; }
.detail-field { cursor: pointer; border-radius: var(--r-sm); padding: 5px 8px; margin: -5px -8px; transition: background var(--t-fast); min-width: 0; }
.detail-field:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.detail-field .dv { font-weight: var(--fw-medium); word-break: break-word; overflow-wrap: anywhere; white-space: pre-line; max-width: 100%; }

/* related list cards */
.relcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin-bottom: 16px; overflow: hidden; }
.relcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.relcard-table th { background: var(--surface-2); }

/* feed */
.composer { display: flex; gap: 11px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.composer textarea { border-color: transparent; background: var(--surface-sunken); border-radius: var(--r); min-height: 44px; transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast); }
.composer textarea:focus-visible { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.feed-list { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.feed-post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 14px 16px; animation: riseIn var(--t-med) both; }
.feed-system { background: var(--surface-sunken); border-style: dashed; box-shadow: none; padding: 9px 14px; }
.feed-system .fsys-text { font-size: var(--fs-sm); color: var(--muted); }
.feed-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.feed-body { white-space: pre-line; word-break: break-word; }
.feed-foot { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.feed-action-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); padding: 3px 8px; border-radius: var(--r-sm); }
.feed-action-btn:hover { background: var(--surface-sunken); color: var(--ink); }
.feed-action-btn.liked { color: var(--candy); }
.comment-block { margin-top: 11px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.comment-row { display: flex; gap: 9px; align-items: flex-start; }

/* activity composer + timeline */
.side-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 15px 16px; }
.act-mode-tabs { display: flex; gap: 5px; margin-bottom: 12px; }
.act-mode-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6.5px 4px; font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--muted); background: var(--surface-sunken); border-radius: var(--r-pill); transition: all var(--t-fast); }
.act-mode-tab:hover { color: var(--ink); }
.act-mode-tab.is-active { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .act-mode-tab.is-active { color: var(--berry-ink); }

.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 13px; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 17px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 30px; flex: 0 0 auto; }
.tl-dot { width: 28px; height: 28px; border-radius: 9px; display: flex; align-items: center; justify-content: center; z-index: 1; }
.tl-rail::after { content: ""; flex: 1; width: 2px; background: var(--line); margin-top: 4px; border-radius: 2px; }
.tl-item:last-child .tl-rail::after { display: none; }
.tl-body { min-width: 0; flex: 1; padding-top: 3px; }
.tl-title { font-weight: var(--fw-medium); font-size: var(--fs-base); cursor: pointer; border-radius: 4px; display: inline; padding: 1px 2px; margin: -1px -2px; }
.tl-title:hover { background: var(--surface-sunken); text-decoration: underline; text-decoration-color: var(--faint); }
.tl-meta { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.tl-check {
  margin-left: 6px; width: 17px; height: 17px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: inline-flex; vertical-align: -4px;
  align-items: center; justify-content: center; color: #fff;
  transition: all var(--spring);
}
.tl-check:hover { border-color: var(--ok); }
.tl-check.done { background: var(--ok); border-color: var(--ok); transform: scale(1.08); }

.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-card { background: var(--citrus-soft); border: 1px solid color-mix(in srgb, var(--citrus) 28%, transparent); border-radius: var(--r); padding: 11px 14px; }
[data-theme="dark"] .note-card { background: color-mix(in srgb, var(--citrus) 12%, var(--surface)); }
.note-title { font-weight: var(--fw-bold); font-size: var(--fs-sm); margin-bottom: 3px; }
.note-body { font-size: var(--fs-sm); white-space: pre-line; word-break: break-word; }

/* link-list inside side panels */
.linklist { display: flex; flex-direction: column; gap: 2px; }
.linklist a { display: flex; align-items: center; gap: 9px; padding: 6.5px 8px; border-radius: var(--r-sm); font-size: var(--fs-sm); }
.linklist a:hover { background: var(--surface-sunken); }

/* ==== dashboard.css ==== */
/* Dashboards, reports, home page widgets. */

.dash-controls { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 15px; }
.widget {
  grid-column: span 4;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 16px 17px; min-width: 0; position: relative;
}
.widget--6 { grid-column: span 6; }
.widget--8 { grid-column: span 8; }
.widget--12 { grid-column: span 12; }
.widget-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.widget-title { font-size: var(--fs-base); font-weight: var(--fw-bold); color: var(--ink-soft); letter-spacing: -.01em; }
.widget:hover .widget-drill { opacity: 1; transform: none; }
.widget-drill { position: absolute; top: 12px; right: 13px; opacity: 0; transform: translateY(-3px); transition: all var(--t-fast); background: var(--surface-sunken); border-radius: var(--r-sm); }

.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 13px; margin-bottom: 15px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  padding: 14px 16px; cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  min-width: 0;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.kpi-label { font-size: var(--fs-xs); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; gap: 7px; align-items: center; }
.kpi-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: 5px; line-height: 1.1; }
.kpi-delta { font-size: var(--fs-xs); font-weight: var(--fw-bold); margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; border-radius: 99px; padding: 1.5px 8px; }
.kpi-delta.up { color: var(--ok); background: var(--ok-soft); }
.kpi-delta.down { color: var(--bad); background: var(--bad-soft); }
.kpi-pulse { animation: kpiPulse .9s both; }
@keyframes kpiPulse { 0% { transform: scale(1); } 30% { transform: scale(1.045); } 100% { transform: scale(1); } }

/* charts */
.chart-root { width: 100%; overflow: visible; }
.chart-root svg { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--font); }
.bar-grow { transform-box: fill-box; transform-origin: bottom left; animation: barGrow .55s cubic-bezier(.25,.6,.3,1) both; }
@keyframes barGrow { from { transform: scaleY(.02) scaleX(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.bar-h-left { transform-box: fill-box; transform-origin: left center; animation: barHGrow .55s cubic-bezier(.25,.6,.3,1) both; }
@keyframes barHGrow { from { transform: scaleX(.02); opacity: 0; } to { transform: none; opacity: 1; } }
.line-draw { stroke-dasharray: var(--len, 600); stroke-dashoffset: var(--len, 600); animation: lineDraw .9s cubic-bezier(.4,.2,.2,1) .1s forwards; }
@keyframes lineDraw { to { stroke-dashoffset: 0; } }
.arc-in { transform-box: fill-box; transform-origin: center; animation: arcIn .6s cubic-bezier(.34,1.3,.64,1) both; }
@keyframes arcIn { from { opacity: 0; transform: scale(.86) rotate(-11deg); } to { opacity: 1; transform: none; } }
.chart-seg { cursor: pointer; transition: opacity var(--t-fast), filter var(--t-fast); }
.chart-seg:hover { opacity: .82; filter: saturate(1.18); }
.chart-axis-text { font-size: 10.5px; fill: var(--faint); font-weight: 550; }
.chart-legend { display: flex; gap: 13px; flex-wrap: wrap; margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 550; cursor: default; }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }

/* leaderboard rows */
.lb-row { display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 8.5px 4px; }
.lb-rank { font-weight: var(--fw-bold); color: var(--faint); font-size: var(--fs-sm); text-align: center; }
.lb-row:first-child .lb-rank { color: #eab308; }
.lb-me-badge { font-size: 9px; background: var(--accent-soft); color: var(--accent-ink); padding: 1px 5px; border-radius: 99px; font-weight: var(--fw-bold); margin-left: 5px; vertical-align: 1px; }
.lb-quota-note { font-size: 10.5px; color: var(--faint); margin-top: 3px; }

/* report table */
.report-meta { display: flex; gap: 17px; color: var(--muted); font-size: var(--fs-sm); margin: 4px 0 13px; flex-wrap: wrap; }

/* ---------- home ---------- */
.home-greet { margin-bottom: 19px; }
.home-cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }
.home-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.agenda-row { display: flex; align-items: center; gap: 11px; padding: 9px 4px; }
.agenda-row + .agenda-row { border-top: 1px solid var(--line); }
.agenda-time { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--muted); width: 52px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.onboard-card { border: 1.5px solid color-mix(in srgb, var(--accent) 33%, transparent); background: linear-gradient(150deg, var(--accent-soft), var(--surface) 65%); border-radius: var(--r-lg); padding: 17px 18px; }
.onboard-step { display: flex; gap: 11px; align-items: center; padding: 8px 2px; }
.onboard-check { width: 21px; height: 21px; border-radius: 99px; border: 2px solid var(--line-strong); display: flex; align-items: center; justify-content: center; transition: all var(--spring); flex: 0 0 auto; }
.onboard-step.done .onboard-check { background: var(--ok); border-color: var(--ok); color: #fff; transform: scale(1.05); }

/* settings */
.settings-grid { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 17px; align-items: start; }
.swatch-row { display: flex; gap: 9px; flex-wrap: wrap; }
.accent-swatch { width: 34px; height: 34px; border-radius: 12px; position: relative; transition: transform var(--t-fast); }
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.is-active::after { content: ""; position: absolute; inset: -4.5px; border: 2.5px solid currentColor; border-radius: 16px; }
.seg-group { display: inline-flex; background: var(--surface-sunken); padding: 3.5px; border-radius: var(--r-pill); gap: 3px; }
.seg-btn { padding: 6px 15px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--muted); transition: all var(--t-fast); display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--ink); font-weight: var(--fw-bold); box-shadow: var(--shadow-1); }

/* shortcut help */
.shortcut-cols { column-count: 2; column-gap: 26px; }
@media (max-width: 520px) { .shortcut-cols { column-count: 1; } }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 2px; break-inside: avoid; font-size: var(--fs-base); }
.sc-keys { white-space: nowrap; }

/* ==== responsive.css ==== */
/* Responsive behavior: desktop -> tablet -> phone. */

/* --- Tablet & below (≤1180px) --- */
@media (max-width: 1180px) {
  .record-layout { grid-template-columns: minmax(0, 1fr) 330px; }
  .widget { grid-column: span 6; }
  .widget--12 { grid-column: span 12; }
}

/* --- Narrow tablet (≤1020px): topbar condenses --- */
@media (max-width: 1020px) {
  :root { --topbar-h: 48px; }
  .top-search { width: min(320px, 40vw); }
  .brand-name, .brand-env { display: none; }
  .record-layout { grid-template-columns: 1fr; }
  .record-side { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .record-side > * { flex: 1 1 300px; }
  .home-cols { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* --- Phone (≤760px) --- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .page { padding: 15px 13px 120px; }

  /* topbar becomes two rows on phones */
  #main { overflow-y: visible; }
  .app-scrollwrap { display: block; height: auto !important; min-height: 100vh; }

  .topbar { padding: 0 9px; gap: 5px; flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding-bottom: 0; }
  .obj-tabs-row { order: 10; width: 100%; margin: 0 -4px; border-top: 1px solid var(--line); }
  .page-head .row { flex-wrap: wrap; }
  .record-layout .hl-actions { flex-wrap: wrap; }
  .topbar.is-compact .search-hint { display: none; }
  .top-search { width: 44vw; }
  .hide-phone { display: none !important; }
  .dot-badge { top: 1px; right: 0; }

  .util-dock { left: 50%; transform: translateX(-50%); bottom: 9px;
    flex-direction: row; border-radius: var(--r-pill); border: 1px solid var(--line);
    padding: 4px 8px; box-shadow: var(--shadow-3); background: color-mix(in srgb, var(--surface) 96%, transparent);
  }
  .toast-root-phone {}

  .page-head { flex-direction: column; }
  .hl-fields { gap: 16px; }
  .widget, .widget--6, .widget--8 { grid-column: span 12; }
  .kan-col { flex-basis: min(86vw, 292px); max-height: none; }
  .kan-cards { max-height: 60vh; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .shortcut-cols { column-count: 1; }
  .overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheetUp var(--t-med) both; }
  @keyframes sheetUp { from { transform: translateY(26px); opacity: .55; } to { transform: none; opacity: 1; } }
  .drawer { width: 100vw; }

  /* data tables on phones: name-first stacked rows */
  .table-scroll table.dtable.compactable, .dtable.compactable { border-spacing: 0 8px; display: block; overflow-x: auto; }
  .dtable.compactable th.hide-col { display: none; }
  .dtable td.hide-col { display: none; }
  .savebar { width: calc(100vw - 20px); justify-content: space-between; }
}

/* Touch target enlargement on coarse pointers */
@media (pointer: coarse) {
  .icon-btn { width: 38px; height: 38px; }
  .checkbox { width: 19px; height: 19px; }
  .dtable td, .dtable th { padding-top: 4px; padding-bottom: 4px; }
  .row-edit-input { height: 34px; }
  .tip-host:hover > .tip { opacity: 0; } /* avoid sticky hover tips on touch */
}

@media print { .topbar, .util-dock, .savebar, #toast-root { display: none !important; } }
