/* CoTrac design system v3
   Type scale: 12 / 14 / 16 / 20 / 28 / 48      Spacing: 4 8 12 16 24 32 (8px grid)
   Radii: 8 (small) 12 (controls) 20 (panels)   Click targets: 44px minimum */
:root {
  --navy-900: #0f2140;
  --navy-800: #152c52;
  --navy-700: #1d3964;
  --navy-600: #2a4a7a;
  --teal-700: #1d5b55;
  --teal-600: #24706a;
  --teal-500: #2f8a80;
  --teal-300: #5fa896;
  --teal-100: #cfe5df;
  --teal-50: #e6f2ef;
  --ink: #101827;
  --ink-2: #2b3545;
  --muted: #45505f;
  --line: rgba(16, 24, 39, .14);
  --line-2: rgba(16, 24, 39, .08);
  --paper: #e9eeec;
  --card: rgba(255, 255, 255, .6);
  --amber: #7a4a05;
  --amber-bg: #fbecd0;
  --red: #8f241a;
  --red-bg: #fbe3de;
  --green: #1f5a36;
  --green-bg: #dcefe1;
  --grey-bg: rgba(16, 24, 39, .07);
  --orange: #c2470f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --radius: 20px;
  --t-xs: 12px;
  --t-sm: 14px;
  --t-md: 16px;
  --t-lg: 20px;
  --t-xl: 28px;
  --t-2xl: 48px;
  --glass-blur: blur(20px) saturate(150%);
  --shadow: 0 8px 24px rgba(18, 34, 68, .08);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); font-size: var(--t-md); line-height: 1.45; -webkit-font-smoothing: antialiased; }
/* Soft coloured backdrop that the frosted panels sit on */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(640px circle at 96% -4%, rgba(47, 143, 127, .42), transparent 62%),
    radial-gradient(600px circle at 24% 72%, rgba(58, 95, 176, .24), transparent 62%),
    radial-gradient(560px circle at 86% 104%, rgba(224, 138, 78, .28), transparent 62%),
    var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-700); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
svg { flex: none; }

/* ---------- Shell ---------- */
.shell { display: flex; gap: 24px; padding: 24px; min-height: 100vh; align-items: flex-start; }
.sidebar { position: sticky; top: 24px; flex: 0 0 248px; height: calc(100vh - 48px); display: flex; flex-direction: column; gap: 24px; padding: 24px 12px 12px; border-radius: var(--r-lg); color: #fff; overflow-y: auto;
  background: rgba(18, 34, 68, .86); -webkit-backdrop-filter: blur(22px) saturate(140%); backdrop-filter: blur(22px) saturate(140%); border: 1px solid rgba(255, 255, 255, .14); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--teal-600); display: grid; place-items: center; color: #fff; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand b { display: block; font-size: var(--t-lg); color: #fff; letter-spacing: -.01em; line-height: 1.2; }
.brand small { display: block; font-size: var(--t-xs); letter-spacing: .14em; color: #b9c4dc; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label { padding: 0 12px; font-size: var(--t-xs); font-weight: 600; letter-spacing: .14em; color: #b9c4dc; text-transform: uppercase; }
.nav button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-md); background: transparent; color: #dce3f1; font-size: var(--t-md); font-weight: 500; text-align: left; width: 100%; }
.nav button svg { width: 18px; height: 18px; }
.nav button .grow { flex: 1; }
.nav button .count { font-family: var(--mono); font-size: var(--t-xs); color: #b9c4dc; }
.nav button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav button.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.nav .chev { width: 16px; height: 16px; transition: transform .18s ease; }
.nav [aria-expanded="true"] .chev { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 4px; margin-left: 20px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .18); }
.nav-sub button { font-size: var(--t-sm); }
.nav-sub button svg { width: 16px; height: 16px; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 12px; padding: 8px 4px 8px 12px; border-radius: var(--r-md); background: rgba(255, 255, 255, .08); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--teal-600); color: #fff; display: grid; place-items: center; font-size: var(--t-xs); font-weight: 600; flex: none; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; color: #fff; font-size: var(--t-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who small { display: block; color: #b9c4dc; font-size: var(--t-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: var(--r-md); background: transparent; color: inherit; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: rgba(127, 140, 160, .18); }
.icon-btn svg { width: 18px; height: 18px; }

.main { flex: 1; min-width: 0; max-width: 1280px; display: flex; flex-direction: column; gap: 24px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar .menu { display: none; background: var(--card); border: 1px solid rgba(255, 255, 255, .75); }
.topbar .titles { flex: 1 1 260px; min-width: 0; }
.eyebrow { font-size: var(--t-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: var(--t-xl); line-height: 1.15; letter-spacing: -.02em; margin: 4px 0 0; font-weight: 700; }
h2 { font-size: var(--t-lg); margin: 0; letter-spacing: -.01em; font-weight: 600; }
.lede { color: var(--ink-2); margin: 8px 0 0; max-width: 640px; font-size: var(--t-md); }
.sub { color: var(--muted); font-size: var(--t-sm); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.label { font-size: var(--t-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.label.warn { color: var(--red); }
.label.good { color: var(--teal-700); }

.kbtn { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px 0 12px; border-radius: var(--r-md); border: 1px solid rgba(255, 255, 255, .75); background: var(--card); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); color: var(--muted); font-size: var(--t-sm); }
.kbtn:hover { color: var(--ink); }
.kbtn svg { width: 16px; height: 16px; }
kbd { font-family: var(--mono); font-size: var(--t-xs); padding: 4px 8px; border-radius: var(--r-sm); background: rgba(16, 24, 39, .08); color: var(--ink); white-space: nowrap; }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--r-md); font-size: var(--t-sm); }
.banner.trial { background: rgba(230, 242, 239, .8); border: 1px solid var(--teal-100); color: #143d36; }
.banner.blocked { background: var(--red-bg); border: 1px solid #f0c4bc; color: var(--red); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); padding: 0 16px; border-radius: var(--r-md); font-weight: 600; font-size: var(--t-sm); white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #fff; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn.primary:hover { background: var(--teal-600); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 0 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
select.btn { font-weight: 500; justify-content: flex-start; }

/* The one primary action per screen, with its hover "win" */
.btn.cta { background: var(--orange); border-color: var(--orange); color: #fff; font-size: var(--t-md); padding: 0 20px; box-shadow: 0 8px 20px rgba(160, 56, 10, .26); transition: background .2s ease, border-color .2s ease; }
.cta-ic { display: flex; width: 18px; height: 18px; overflow: hidden; }
.cta-ic svg { width: 18px; height: 18px; stroke-width: 2.4; }
.cta-l { display: grid; }
.cta-l > span { grid-area: 1 / 1; text-align: center; transition: opacity .15s ease; }
.cta-l .l2 { opacity: 0; }
.btn.cta:hover, .btn.cta:focus-visible { background: var(--teal-700); border-color: var(--teal-700); }
.btn.cta:hover .l1, .btn.cta:focus-visible .l1 { opacity: 0; }
.btn.cta:hover .l2, .btn.cta:focus-visible .l2 { opacity: 1; }
.btn.cta[data-anim="add"]:hover svg, .btn.cta[data-anim="add"]:focus-visible svg { animation: ct-add 1s ease-in-out infinite; }
.btn.cta[data-anim="drop"]:hover svg, .btn.cta[data-anim="drop"]:focus-visible svg { animation: ct-drop .9s ease-in infinite; }
@keyframes ct-add { 0% { transform: scale(.6) rotate(0); opacity: .4; } 45% { transform: scale(1.15) rotate(90deg); opacity: 1; } 100% { transform: scale(.6) rotate(180deg); opacity: .4; } }
@keyframes ct-drop { 0% { transform: translateY(-12px); opacity: 0; } 25% { opacity: 1; } 70% { transform: translateY(2px); opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }

/* ---------- Panels ---------- */
.card { background: var(--card); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid rgba(255, 255, 255, .75); border-radius: var(--r-lg); box-shadow: var(--shadow); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .card, .kbtn { background: rgba(255, 255, 255, .94); } .sidebar { background: var(--navy-800); } }
.card-pad { padding: 24px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 24px; flex-wrap: wrap; }
.panel { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 24px; flex-wrap: wrap; }
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.big { font-size: var(--t-2xl); font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.big-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.big-row span { color: var(--muted); }

/* Parts of one whole on one bar */
.stack { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: rgba(16, 24, 39, .12); }
.stack i { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 16px; font-size: var(--t-sm); color: var(--muted); }
.legend > div { display: flex; flex-direction: column; gap: 4px; }
.legend .k { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend b { font-family: var(--mono); font-size: var(--t-md); font-weight: 500; color: var(--ink); }
.c-paid { background: #173f38; }
.c-appr { background: var(--teal-300); }
.c-rest { background: rgba(16, 24, 39, .18); }
.c-over { background: var(--red); }
.c-prog { background: var(--teal-500); }
.c-plan { background: #7d8da8; }
.c-hold { background: #c98a2b; }
.c-done { background: var(--navy-800); }

/* Start-here rows */
.todo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 24px; }
.todo-col { display: flex; flex-direction: column; gap: 8px; }
.todo { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: rgba(255, 255, 255, .6); text-align: left; width: 100%; }
.todo:hover { background: #fff; }
.todo.warn { border-color: rgba(143, 36, 26, .28); background: rgba(255, 244, 238, .85); }
.todo.warn > svg:first-child { color: var(--red); width: 20px; height: 20px; }
.todo .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.todo .txt b { font-weight: 600; font-size: var(--t-md); }
.todo .txt small { font-size: var(--t-sm); color: var(--muted); }
.todo .days { min-width: 48px; font-family: var(--mono); font-size: var(--t-sm); font-weight: 500; color: var(--teal-700); }
.todo .amt { font-family: var(--mono); font-size: var(--t-sm); white-space: nowrap; }
.todo .go { width: 16px; height: 16px; color: var(--muted); }

/* Accordions */
details.acc { overflow: hidden; }
details.acc > summary { list-style: none; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 24px; cursor: pointer; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary .acc-t { font-size: var(--t-lg); font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
details.acc > summary .acc-s { flex: 1; min-width: 0; font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.acc > summary .chev { width: 18px; height: 18px; transition: transform .18s ease; }
details.acc[open] > summary .chev { transform: rotate(180deg); }
details.acc > .acc-b { border-top: 1px solid var(--line-2); }
.acc-pad { padding: 16px 24px 24px; }

/* Tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-md); background: rgba(16, 24, 39, .07); align-self: flex-start; }
.tab { min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--r-sm); background: transparent; font-size: var(--t-sm); font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.tab svg { width: 16px; height: 16px; }
.tab.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 39, .12); }

/* ---------- Pills, chips, bars ---------- */
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: var(--t-xs); font-weight: 600; white-space: nowrap; }
.pill.on_hold, .pill.approved { background: var(--amber-bg); color: var(--amber); }
.pill.completed { background: #173f38; color: #fff; }
.pill.planning, .pill.inactive, .pill.planned { background: #e3e7ee; color: var(--ink-2); }
.pill.in_progress { background: var(--teal-100); color: #143d36; }
.pill.active, .pill.paid { background: var(--green-bg); color: var(--green); }
.pill.soft { background: var(--grey-bg); color: var(--ink-2); font-family: var(--mono); font-weight: 500; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; border: 1px solid var(--line); background: rgba(255, 255, 255, .6); padding: 0 16px; border-radius: 999px; font-size: var(--t-sm); color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.chip:hover { background: #fff; }
.chip .n { font-family: var(--mono); font-size: var(--t-xs); color: var(--muted); }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.on .n { color: #cfd6e2; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7); border-radius: var(--r-md); padding: 0 12px; min-height: 44px; width: 220px; }
.search svg { width: 16px; height: 16px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: var(--t-sm); height: 44px; }

.bar { height: 8px; background: rgba(16, 24, 39, .12); border-radius: 4px; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--teal-700); border-radius: 4px; }
.bar.used > i { background: #3a5fb0; }
.bar.warn > i { background: #a8650c; }
.bar.over > i { background: var(--red); }
.bar.thick { height: 8px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
th { text-align: left; font-size: var(--t-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line-2); vertical-align: middle; height: 60px; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: rgba(255, 255, 255, .6); }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
th.num { font-family: var(--font); }
.cell-title { font-weight: 600; font-size: var(--t-md); }
.cell-sub { font-size: var(--t-xs); color: var(--muted); }
.cell-sub.mono, .cell-code { font-family: var(--mono); }
.prog { display: flex; align-items: center; gap: 12px; min-width: 128px; }
.prog .bar { max-width: 88px; }
.prog span { font-family: var(--mono); font-size: var(--t-sm); min-width: 40px; }

/* ---------- Entity cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ecard { padding: 24px; display: flex; flex-direction: column; gap: 16px; text-align: left; }
.ecard.click { cursor: pointer; transition: background .15s; }
.ecard.click:hover { background: rgba(255, 255, 255, .85); }
.ecard .top { display: flex; gap: 12px; align-items: flex-start; }
.initials { width: 44px; height: 44px; border-radius: var(--r-md); background: var(--grey-bg); display: grid; place-items: center; font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); flex: none; }
.ecard .title { flex: 1; min-width: 0; }
.ecard .title b { display: block; font-size: var(--t-md); font-weight: 600; }
.ecard .title small { color: var(--muted); font-size: var(--t-sm); }
.code { font-family: var(--mono); font-size: var(--t-xs); color: var(--muted); letter-spacing: .06em; }
.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--t-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.contact { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-sm); color: var(--ink-2); }
.contact span, .contact a { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
.contact a { min-height: 44px; padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: rgba(255, 255, 255, .6); }
.contact a:hover { background: #fff; }
.contact svg { width: 16px; height: 16px; color: var(--muted); }
.ecard .foot { border-top: 1px solid var(--line-2); padding-top: 16px; margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--t-sm); }
.star { display: inline-flex; align-items: center; gap: 4px; }
.star svg { width: 14px; height: 14px; color: #a8650c; }
.edit-btn { width: 44px; height: 44px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; }
.edit-btn:hover { background: var(--grey-bg); color: var(--ink); }
.edit-btn svg { width: 18px; height: 18px; }
.loc { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: var(--t-sm); }
.loc svg { width: 16px; height: 16px; color: var(--muted); }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: var(--t-sm); }
.split .mono { font-family: var(--mono); }
.empty { padding: 32px 24px; text-align: center; color: var(--muted); font-size: var(--t-sm); }

/* ---------- Legacy strip (owner panel) ---------- */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); }
.strip > div { padding: 24px; border-right: 1px solid var(--line-2); }
.strip > div:last-child { border-right: 0; }
.strip small { font-size: var(--t-xs); font-weight: 600; letter-spacing: .12em; color: var(--muted); display: block; text-transform: uppercase; }
.strip b { display: block; font-size: var(--t-xl); letter-spacing: -.02em; margin: 8px 0 4px; }
.strip span { color: var(--muted); font-size: var(--t-sm); }

/* ---------- Map ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 24px; height: calc(100vh - 220px); min-height: 520px; }
#map { border-radius: var(--r-lg); border: 1px solid rgba(255, 255, 255, .75); overflow: hidden; height: 100%; z-index: 1; }
.map-list { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.map-list .ecard { cursor: pointer; }
.map-list .ecard.sel { outline: 2px solid var(--teal-500); outline-offset: -2px; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content { font-size: var(--t-sm); margin: 16px; }
.leaflet-popup-content b { font-size: var(--t-md); }
.pop-kv { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin-top: 8px; }
.pop-kv span:nth-child(odd) { color: var(--muted); }
.pick-map { height: 232px; border-radius: var(--r-md); border: 1px solid var(--line); margin-top: 8px; }
.leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; }

/* ---------- Modal, palette, drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 22, 44, .38); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal { background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: blur(28px) saturate(160%); backdrop-filter: blur(28px) saturate(160%); border: 1px solid rgba(255, 255, 255, .85); border-radius: var(--r-lg); width: min(680px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(12, 22, 44, .35); animation: pop .18s ease-out; }
.modal header { padding: 16px 16px 8px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal .body { padding: 8px 24px 16px; overflow-y: auto; }
.modal footer { padding: 16px 24px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.modal footer .left { margin-right: auto; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .full { grid-column: 1 / -1; }
label.f { min-width: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); }
label.f input, label.f select, label.f textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 12px; min-height: 44px; background: rgba(255, 255, 255, .85); font-size: var(--t-md); font-weight: 400; outline: none; color: var(--ink); }
label.f input:focus, label.f select:focus, label.f textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-100); }
label.f textarea { min-height: 88px; padding: 12px; resize: vertical; }
label.f input:disabled { color: var(--muted); background: var(--grey-bg); }
.hint { font-size: var(--t-xs); color: var(--muted); font-weight: 400; }
.err { color: var(--red); font-size: var(--t-sm); min-height: 20px; }
.geo { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.geo input { min-height: 44px; width: 128px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 12px; background: rgba(255, 255, 255, .85); font-size: var(--t-sm); }

.overlay.pal { align-items: flex-start; padding-top: 12vh; }
.palette { width: min(560px, 100%); border-radius: var(--r-lg); background: rgba(255, 255, 255, .78); -webkit-backdrop-filter: blur(28px) saturate(160%); backdrop-filter: blur(28px) saturate(160%); border: 1px solid rgba(255, 255, 255, .85); box-shadow: 0 30px 80px rgba(12, 22, 44, .35); overflow: hidden; animation: pop .18s ease-out; }
.pal-in { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.pal-in svg { width: 18px; height: 18px; color: var(--muted); }
.pal-in input { flex: 1; min-width: 0; height: 56px; border: 0; background: transparent; font-size: var(--t-md); outline: none; }
.pal-list { display: flex; flex-direction: column; gap: 4px; padding: 8px; max-height: 52vh; overflow-y: auto; }
.pal-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-md); background: transparent; font-size: var(--t-sm); text-align: left; width: 100%; }
.pal-item .kind { min-width: 56px; font-size: var(--t-xs); font-weight: 600; letter-spacing: .1em; color: var(--muted); }
.pal-item .lbl { flex: 1; min-width: 0; font-size: var(--t-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-item .hint { white-space: nowrap; }
.pal-item.sel, .pal-item:hover { background: rgba(16, 24, 39, .08); }
.pal-none { padding: 16px 12px; font-size: var(--t-sm); color: var(--muted); }

.drawer-bg { position: fixed; inset: 0; background: rgba(12, 22, 44, .3); z-index: 90; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(620px, 100%); z-index: 91; overflow-y: auto; box-shadow: -10px 0 40px rgba(0, 0, 0, .15); animation: slide .2s ease;
  background: rgba(233, 238, 236, .84); -webkit-backdrop-filter: blur(28px) saturate(150%); backdrop-filter: blur(28px) saturate(150%); border-left: 1px solid rgba(255, 255, 255, .7); }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer .dh { padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); display: flex; flex-direction: column; gap: 8px; }
.drawer .dh h2 { font-size: var(--t-xl); letter-spacing: -.02em; }
.drawer .dh-top { display: flex; justify-content: space-between; align-items: center; }
.drawer .dh-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.drawer .db { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 24px; border-radius: var(--r-md); z-index: 200; font-size: var(--t-sm); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: fade .2s; }
.toast.bad { background: var(--red); }
.loading { display: grid; place-items: center; height: 60vh; color: var(--muted); }
.scrim { display: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 420px; }
  .strip { grid-template-columns: 1fr 1fr; }
  .strip > div:nth-child(2) { border-right: 0; }
  .strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
}
@media (max-width: 860px) {
  .shell { padding: 16px; }
  .sidebar { position: fixed; left: 8px; top: 8px; bottom: 8px; height: auto; width: 272px; z-index: 120; transform: translateX(-110%); transition: transform .2s; background: rgba(18, 34, 68, .96); }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0, 0, 0, .3); }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(12, 22, 44, .38); border: 0; }
  .topbar .menu { display: grid; }
  .topbar .titles { flex-basis: calc(100% - 60px); }
  .topbar .kbtn, .topbar .btn { flex: 1 1 auto; justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .big { font-size: 40px; }
  details.acc > summary { flex-wrap: wrap; padding: 12px 16px; gap: 4px 12px; }
  details.acc > summary .acc-s { flex-basis: 100%; order: 3; white-space: normal; }
  details.acc > summary .acc-t { flex: 1; white-space: normal; }
}
