:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #16181d;
  --text-2: #5b6170;
  --text-3: #8a90a0;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefe;
  --danger: #c93636;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;

  --c-gray: #6b7280;   --c-gray-bg: #eef0f3;
  --c-slate: #475569;  --c-slate-bg: #e6e9ef;
  --c-blue: #2563eb;   --c-blue-bg: #e3ecfd;
  --c-teal: #0f8a83;   --c-teal-bg: #dcf3f1;
  --c-green: #15803d;  --c-green-bg: #dcf5e4;
  --c-amber: #a16207;  --c-amber-bg: #fdf1d3;
  --c-orange: #c2410c; --c-orange-bg: #fde8dc;
  --c-red: #c42b2b;    --c-red-bg: #fde3e3;
  --c-purple: #7c3aed; --c-purple-bg: #efe7fd;
  --c-pink: #be185d;   --c-pink-bg: #fce4ef;

  --r1: #c42b2b; --r2: #d9711c; --r3: #8a90a0; --r4: #4c9a52; --r5: #15803d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #2a2f39;
    --border-strong: #3a404c;
    --text: #e8eaee;
    --text-2: #a4aab6;
    --text-3: #747b89;
    --accent: #5b7ff5;
    --accent-soft: #1d2847;
    --danger: #ef6b6b;
    --danger-soft: #3a1d1f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);

    --c-gray: #a4aab6;   --c-gray-bg: #262a32;
    --c-slate: #94a3b8;  --c-slate-bg: #232933;
    --c-blue: #7ea6ff;   --c-blue-bg: #1b2a4a;
    --c-teal: #4fd1c5;   --c-teal-bg: #133331;
    --c-green: #5bd38a;  --c-green-bg: #143222;
    --c-amber: #f2c45a;  --c-amber-bg: #3a2f12;
    --c-orange: #ff9a62; --c-orange-bg: #3d2416;
    --c-red: #ff7a7a;    --c-red-bg: #3d1c1c;
    --c-purple: #b597ff; --c-purple-bg: #2a1f45;
    --c-pink: #f58ab8;   --c-pink-bg: #3b1a2a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.boot { padding: 40px; color: var(--text-3); }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); padding: 7px 12px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.small { padding: 4px 8px; font-size: 13px; }
button.icon { padding: 4px 7px; }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
input[type=checkbox] { width: auto; accent-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 1em; }

/* ---------- chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--c-gray-bg); color: var(--c-gray); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
[data-color=gray]   { --cc: var(--c-gray);   --cb: var(--c-gray-bg); }
[data-color=slate]  { --cc: var(--c-slate);  --cb: var(--c-slate-bg); }
[data-color=blue]   { --cc: var(--c-blue);   --cb: var(--c-blue-bg); }
[data-color=teal]   { --cc: var(--c-teal);   --cb: var(--c-teal-bg); }
[data-color=green]  { --cc: var(--c-green);  --cb: var(--c-green-bg); }
[data-color=amber]  { --cc: var(--c-amber);  --cb: var(--c-amber-bg); }
[data-color=orange] { --cc: var(--c-orange); --cb: var(--c-orange-bg); }
[data-color=red]    { --cc: var(--c-red);    --cb: var(--c-red-bg); }
[data-color=purple] { --cc: var(--c-purple); --cb: var(--c-purple-bg); }
[data-color=pink]   { --cc: var(--c-pink);   --cb: var(--c-pink-bg); }
.pill[data-color] { background: var(--cb); color: var(--cc); }
.swatch[data-color] { background: var(--cc); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card p { margin: 0 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.auth-card .brand { margin-bottom: 22px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 54px; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.profile-switch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 5px 10px; border-radius: 8px; color: var(--text); border: 1px solid var(--border); }
.profile-switch:hover { background: var(--surface-2); text-decoration: none; }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }
.user-menu { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.menu button { width: 100%; justify-content: flex-start; border: 0; background: none; }
.menu button:hover { background: var(--surface-2); }
.menu .menu-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 0; padding: 0; justify-content: center; }

.page { padding: 22px 24px 60px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .search { max-width: 260px; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); }

/* ---------- profile picker ---------- */
.picker { max-width: 760px; margin: 0 auto; padding: 56px 20px; }
.picker h1 { margin-bottom: 6px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 24px; }
.profile-card {
  text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); min-height: 120px;
}
.profile-card:hover { border-color: var(--accent); background: var(--surface); }
.profile-card .initial { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.profile-card.new { border-style: dashed; color: var(--text-2); box-shadow: none; justify-content: center; align-items: center; }
.profile-card strong { font-size: 15px; }

/* ---------- kanban ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; min-height: calc(100vh - 170px); }
.column { flex: 0 0 272px; background: var(--surface-2); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 170px); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; font-weight: 600; font-size: 13px; }
.column-head .count { color: var(--text-3); font-weight: 500; }
.column-head .dot { color: var(--cc, var(--c-gray)); }
.column-body { padding: 4px 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; flex: 1; }
.column.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; cursor: grab;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 7px; color: var(--text);
}
.kcard:hover { border-color: var(--border-strong); text-decoration: none; }
.kcard.dragging { opacity: .4; }
.kcard-title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.kcard-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; align-items: center; font-size: 12px; color: var(--text-2); }
.kcard-foot { display: flex; gap: 10px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--border); padding-top: 7px; }
.drop-line { height: 3px; border-radius: 2px; background: var(--accent); margin: -2px 0; }
.kv { display: inline-flex; gap: 4px; align-items: center; }
.kv b { font-weight: 600; color: var(--text); }

/* ---------- rating ---------- */
.rating { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.rating button { width: 34px; height: 30px; padding: 0; justify-content: center; font-weight: 600; color: var(--text-2); }
.rating button.on { color: #fff; border-color: transparent; }
.rating button.on[data-r="1"] { background: var(--r1); }
.rating button.on[data-r="2"] { background: var(--r2); }
.rating button.on[data-r="3"] { background: var(--r3); }
.rating button.on[data-r="4"] { background: var(--r4); }
.rating button.on[data-r="5"] { background: var(--r5); }
.rating .rlabel { font-size: 12px; color: var(--text-3); margin-left: 6px; min-width: 82px; }
.rbadge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.rbadge i { font-style: normal; width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px; }
.rbadge i[data-r="1"] { background: var(--r1); } .rbadge i[data-r="2"] { background: var(--r2); }
.rbadge i[data-r="3"] { background: var(--r3); } .rbadge i[data-r="4"] { background: var(--r4); }
.rbadge i[data-r="5"] { background: var(--r5); } .rbadge i[data-r="0"] { background: var(--border-strong); }

/* ---------- detail pages ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.title-input {
  font-size: 24px; font-weight: 650; border: 1px solid transparent; background: transparent; padding: 2px 6px; margin-left: -7px;
  letter-spacing: -.01em; width: auto; min-width: 200px; max-width: 100%;
}
.title-input:hover { border-color: var(--border); }
.status-select { width: auto; font-weight: 600; border-radius: 999px; padding: 5px 30px 5px 12px; background: var(--cb, var(--surface)); color: var(--cc, var(--text)); border-color: transparent; }
.detail-grid { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.group + .group { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.group h3 { margin-bottom: 12px; }
.fld { margin-bottom: 14px; }
.fld:last-child { margin-bottom: 0; }
.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.money-hint { font-size: 12px; color: var(--text-3); margin-top: 3px; min-height: 16px; }
.tags-input { display: flex; flex-wrap: wrap; gap: 5px; padding: 5px 6px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); align-items: center; }
.tags-input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.tags-input input { border: 0; outline: 0; padding: 3px 4px; flex: 1; min-width: 90px; width: auto; }
.tags-input .tag { display: inline-flex; align-items: center; gap: 4px; }
.tags-input .tag button { border: 0; background: none; padding: 0 2px; color: var(--text-3); line-height: 1; }
.multi { display: flex; flex-wrap: wrap; gap: 6px; }
.multi label { cursor: pointer; }
.multi input { display: none; }
.multi .pill { opacity: .45; }
.multi input:checked + .pill { opacity: 1; outline: 1.5px solid var(--cc); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.tl-head .date { font-weight: 600; }
.tl-body { margin-top: 6px; white-space: pre-wrap; word-wrap: break-word; }
.tl-extra { margin-top: 6px; display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.tl-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; }
.timeline li:hover .tl-actions, .tl-actions:focus-within { opacity: 1; }
.log-form { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.log-form .form-row { margin-bottom: 10px; }
.inline-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ---------- fields settings ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--text-2); padding: 8px 12px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.badge { white-space: nowrap; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.arr-group-head { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
.arr-group-head h3 { margin: 0; }
.arr-list { display: flex; flex-direction: column; gap: 6px; min-height: 36px; }
.arr-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: grab; }
.arr-row:hover { border-color: var(--border-strong); }
.arr-row.dragging { opacity: .4; }
.arr-handle { color: var(--text-3); letter-spacing: -3px; font-size: 13px; user-select: none; }
.arr-label { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.hist-item:last-child { border-bottom: 0; }
.hist-avatar { width: 28px; height: 28px; font-size: 11px; flex: none; }
.hist-line { font-size: 13px; line-height: 1.5; }
.hist-target { font-weight: 600; }
.hist-when { margin-left: 8px; font-size: 12px; white-space: nowrap; }
.hist-changes { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.hist-changes li { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hist-label { color: var(--text-3); margin-right: 6px; }
.hist-label::after { content: ':'; }
.hist-from { color: var(--text-2); text-decoration-color: var(--text-3); }
.hist-to { color: var(--text); font-weight: 500; }
.dz-list { display: flex; flex-direction: column; min-height: 24px; }
.dz-field { position: relative; padding-left: 22px; margin-left: -22px; border-radius: 8px; }
.dz-field > .fld { margin-bottom: 14px; }
.dz-list > .dz-field:last-child > .fld { margin-bottom: 0; }
.dz-field.dragging, .dz-group.dragging { opacity: .35; }
.drag-handle {
  position: absolute; left: 0; top: 0; width: 18px; height: 20px; padding: 0; border: 0; background: none;
  color: var(--text-3); font-size: 13px; letter-spacing: -3px; cursor: grab; justify-content: center;
  opacity: .45; transition: opacity .1s; border-radius: 4px;
}
.dz-field:hover > .drag-handle, .dz-group-head:hover > .drag-handle, .drag-handle:focus-visible { opacity: 1; }
.drag-handle:hover { color: var(--text); background: var(--surface-2); }
.dz-group-head { position: relative; padding-left: 22px; margin-left: -22px; }
.dz-group-head h3 { margin-bottom: 12px; }
.dz-group-head .drag-handle { top: -2px; }
.card-body:has(.dz-group) { padding-left: 30px; }
@media (hover: none) { .drag-handle { opacity: .6; } }
.th-sort { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--text-3); gap: 4px; }
.th-sort:hover, .th-sort.on { background: none; color: var(--text); }
.sort-arrow { display: inline-block; width: 10px; }
.companies-table td { white-space: nowrap; }
.companies-table td:first-child a { white-space: normal; }
.list-view .group-row td { background: var(--surface-2); padding: 8px 16px; border-bottom: 1px solid var(--border); }
.list-view tbody + tbody .group-row td { border-top: 1px solid var(--border); }
.group-row-inner { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.group-row .dot { color: var(--cc, var(--c-gray)); }
.group-row-inner button { margin-left: auto; }
.small-select { font-size: 12px; padding: 3px 26px 3px 10px; }
.page-head .segmented span { padding: 4px 12px; font-size: 13px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; padding: 3px; gap: 3px; background: var(--surface-2); flex-wrap: wrap; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--text-2); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.opt-row { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.swatch-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer; }
.swatch.on { border-color: var(--text); }
.color-btn { width: 26px; height: 26px; padding: 0; justify-content: center; border-radius: 6px; }
.color-btn .swatch { width: 14px; height: 14px; cursor: inherit; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.wide { max-width: 620px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: opacity .15s, transform .15s; z-index: 200;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid > *, .stack > * { min-width: 0; }
  .page { padding: 16px 16px 60px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .nav a { padding: 6px 7px; }
  .inline-grid, .form-grid { grid-template-columns: 1fr; }
  .profile-switch .pname { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 520px) {
  .topbar { gap: 4px; }
  .profile-switch { padding: 5px 6px; }
  .profile-switch .brand-mark { display: none; }
  .profile-switch .pname { max-width: 84px; }
  .nav a { padding: 6px 5px; font-size: 13px; }
  .page-head .search { max-width: none; }
  .title-input { min-width: 0; font-size: 21px; }
  .range { grid-template-columns: 1fr; }
  .range > span { display: none; }
}
