/* Alliance DB theme — ported from travian_scanbot's design system (paper/ink).
   Layered ON TOP of Bootstrap 5: tokens + scanbot components first, then a
   mapping section that points the Bootstrap classes our templates already use
   (.card, .btn-*, .table, .form-*, .badge.text-bg-*, .alert, .pagination) at
   the same tokens. Dark theme = [data-theme="ink"] on <html>. */

/* Self-hosted (vendor/geist-1.7.2, SIL OFL): no Google Fonts round trip —
   third-party CDNs are slow or throttled for players in Russia. */
@font-face {
    font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url("vendor/geist-1.7.2/Geist-Variable.dfa48d5a8537.woff2") format("woff2");
}
@font-face {
    font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url("vendor/geist-1.7.2/GeistMono-Variable.308360d8a547.woff2") format("woff2");
}

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
    --bg: #F4F1EA;
    --bg-deep: #EFEBE2;
    --surface: #FBF9F4;
    --surface-2: #F7F4ED;
    --line: #E2DCCE;
    --line-strong: #CFC7B4;
    --ink: #1B1A17;
    --ink-2: #38352E;
    --muted: #75716A;
    --muted-2: #9A958B;
    --accent: oklch(0.42 0.13 254);
    --accent-soft: oklch(0.95 0.03 254);
    --accent-ink: oklch(0.30 0.10 254);
    --good: oklch(0.58 0.13 155);
    --good-soft: oklch(0.95 0.04 155);
    --warn: oklch(0.72 0.14 75);
    --warn-soft: oklch(0.96 0.05 80);
    --bad: oklch(0.58 0.18 25);
    --bad-soft: oklch(0.95 0.04 25);
    --row-bad: oklch(0.96 0.025 20);
    --shadow-sm: 0 1px 0 rgba(27, 26, 23, 0.04);
    --shadow: 0 1px 2px rgba(27, 26, 23, 0.05), 0 0 0 1px var(--line);
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;
    --pad: 14px;
    --transition: 150ms ease;
    --font-sans: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="ink"] {
    --bg: #15161A;
    --bg-deep: #0F1014;
    --surface: #1C1E24;
    --surface-2: #23262E;
    --line: #2A2D36;
    --line-strong: #383C47;
    --ink: #ECEAE2;
    --ink-2: #C8C4B8;
    --muted: #8A8678;
    --muted-2: #6B6859;
    --accent: oklch(0.72 0.13 254);
    --accent-soft: oklch(0.30 0.08 254);
    --accent-ink: oklch(0.85 0.08 254);
    --good: oklch(0.72 0.15 155);
    --good-soft: oklch(0.28 0.06 155);
    --warn: oklch(0.78 0.14 75);
    --warn-soft: oklch(0.30 0.08 75);
    --bad: oklch(0.70 0.18 25);
    --bad-soft: oklch(0.28 0.08 25);
    --row-bad: oklch(0.24 0.04 25);
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.2);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--line);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
body {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink);
    background: var(--bg) !important; /* beat .bg-body-tertiary */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }
/* Travian small unit icon: a 16px window onto the tribe's 16x160 sprite sheet. */
.unit-ico { display: inline-block; width: 16px; height: 16px; overflow: hidden; vertical-align: middle; line-height: 0; }
.unit-ico img { display: block; width: 16px; height: auto; max-width: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
h1, h2, h3, h4, h5, h6 { color: var(--ink); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── App shell (sidebar + topbar; markup lands in base.html) ───────────── */
.app {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}
.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: 28px 32px 64px; max-width: 1480px; width: 100%; }

.sidebar {
    background: var(--bg-deep);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    z-index: 5;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--line);
    color: inherit;
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 7px;
    background: var(--ink); color: var(--bg);
    display: grid; place-items: center;
    font-family: var(--font-mono); font-weight: 600; font-size: 14px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; line-height: 1.2; }
.brand-tag {
    font-size: 11px; color: var(--muted);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em;
    max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-group { padding: 8px 8px 4px; }
.sidebar-label {
    padding: 10px 10px 6px;
    font-size: 10px; color: var(--muted-2);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 500;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--ink-2); font-size: 13px; font-weight: 500;
    cursor: pointer; user-select: none;
    border: 1px solid transparent;
    position: relative;
    text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[data-active="true"] {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: var(--shadow-sm);
}
.nav-item[data-active="true"]::before {
    content: ''; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px;
    background: var(--accent); border-radius: 2px;
}
.nav-icon {
    width: 16px; height: 16px; flex-shrink: 0;
    color: var(--muted);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px;
}
.nav-item[data-active="true"] .nav-icon { color: var(--accent); }
.nav-label { flex: 1; }
.sidebar-footer {
    margin-top: auto; padding: 12px;
    border-top: 1px solid var(--line);
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}

.topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 24px;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar-spacer { flex: 1; }
.icon-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--radius-sm); cursor: pointer;
    display: grid; place-items: center; color: var(--muted);
    font-family: inherit; font-size: 14px;
    text-decoration: none;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.user-chip {
    font-size: 12px; color: var(--muted);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 4px;
}
/* Top-right account menu (profile, language, theme, log out). */
.account-toggle {
    border: 1px solid var(--line); background: var(--surface);
    border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer;
    font-family: inherit; font-size: 12px; color: var(--ink-2);
    display: inline-flex; align-items: center; gap: 6px;
}
.account-toggle:hover, .account-toggle[aria-expanded="true"] { border-color: var(--line-strong); color: var(--ink); }
.account-menu {
    --bs-dropdown-bg: var(--surface); --bs-dropdown-border-color: var(--line);
    --bs-dropdown-link-color: var(--ink); --bs-dropdown-link-hover-bg: var(--surface-2);
    --bs-dropdown-link-hover-color: var(--ink); --bs-dropdown-link-active-bg: var(--accent-soft);
    --bs-dropdown-link-active-color: var(--accent-ink); --bs-dropdown-divider-bg: var(--line);
    min-width: 220px; font-size: 13px;
}
.account-menu .dropdown-item { display: flex; align-items: center; gap: 8px; }
.account-menu-head { padding: 6px 16px 8px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.account-menu-row { padding: 4px 16px 8px; display: flex; gap: 6px; align-items: center; }
.account-menu-label { font-size: 12px; color: var(--muted); margin-right: auto; }
.lang-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 9px; border: 1px solid var(--line);
    border-radius: 999px; font-size: 11px; font-weight: 500;
    background: var(--surface); cursor: pointer;
    color: var(--ink-2); font-family: inherit;
}
.lang-pill[data-active="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Off-canvas drawer ≤900px */
.sidebar-toggle {
    display: none;
    width: 40px; height: 40px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer;
    align-items: center; justify-content: center;
    margin-right: 4px;
}
.sidebar-toggle:hover { background: var(--surface-2); }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 19;
}
.app[data-sidebar-open="true"] .sidebar-backdrop { display: block; }
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar {
        position: fixed; top: 0; left: 0;
        width: 280px; max-width: 85vw;
        height: 100vh; z-index: 20;
        transform: translateX(-100%);
        transition: transform 180ms ease-out;
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.18);
    }
    .app[data-sidebar-open="true"] .sidebar { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }
    .topbar { padding: 8px 12px; gap: 6px; }
}
@media (max-width: 720px) {
    .content { padding: 16px 14px 64px; }
    .page-title { font-size: 18px !important; line-height: 1.2; }
    .page-head { gap: 6px; flex-wrap: wrap; }
}

/* ── Page head ─────────────────────────────────────────────────────────── */
.page-head {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding-bottom: 22px; margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
}
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; margin: 0; }
.page-count {
    font-family: var(--font-mono); font-size: 13px;
    background: var(--accent); color: white;
    padding: 3px 8px; border-radius: 5px; font-weight: 600;
}
.page-meta {
    margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    font-family: var(--font-mono); font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.page-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); }

/* ── Scanbot tables (.tbl) + mapping for Bootstrap .table ──────────────── */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead th, .table thead th {
    text-align: left;
    font-size: 10px; color: var(--muted);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 500;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}
.tbl tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px; vertical-align: middle;
}
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num, .table .num { font-family: var(--font-mono); font-feature-settings: "tnum" 1; text-align: right; }
.tbl .actions, .table .actions { text-align: right; white-space: nowrap; }

/* Bootstrap table → tokens (covers all existing templates untouched) */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--ink);
    --bs-table-striped-bg: var(--surface-2);
    color: var(--ink);
    margin-bottom: 0;
}
.table > :not(caption) > * > * { border-bottom-color: var(--line); }
.table tbody td { font-size: 13px; }
.table-warning { --bs-table-bg: var(--warn-soft); --bs-table-color: var(--ink); }
.table-bordered > :not(caption) > * > * { border-color: var(--line); }

/* ── Filterbar / chips / search ────────────────────────────────────────── */
.filterbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px; color: var(--ink-2); cursor: pointer;
    font-family: inherit;
}
.chip[data-active="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:hover:not([data-active="true"]) { border-color: var(--line-strong); }

/* ── Stat blocks ───────────────────────────────────────────────────────── */
.stat-label {
    font-size: 10px; color: var(--muted);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 500;
}
.stat-value {
    font-size: 30px; font-weight: 600;
    letter-spacing: -0.03em; line-height: 1.05;
    margin-top: 6px;
    font-family: var(--font-mono);
    font-feature-settings: "tnum" 1;
}
.stat-value.good { color: var(--good); }
.stat-value.warn { color: var(--warn); }
.stat-value.bad { color: var(--bad); }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.delta { font-family: var(--font-mono); font-weight: 600; font-size: 11px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 40px 16px;
    color: var(--muted); font-size: 13px;
}
.empty-state .empty-icon { font-size: 26px; display: block; margin-bottom: 8px; }

/* ── Bootstrap component mapping ───────────────────────────────────────── */
/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--line);
    --bs-card-cap-bg: var(--surface-2);
}
.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card-footer { background: var(--surface-2); border-top: 1px solid var(--line); }

/* Buttons */
.btn {
    --bs-btn-font-size: 13px;
    --bs-btn-font-weight: 500;
    --bs-btn-border-radius: var(--radius-sm);
    font-family: inherit;
}
.btn-primary {
    --bs-btn-bg: var(--ink);
    --bs-btn-color: var(--bg);
    --bs-btn-border-color: var(--ink);
    --bs-btn-hover-bg: var(--ink-2);
    --bs-btn-hover-color: var(--bg);
    --bs-btn-hover-border-color: var(--ink-2);
    --bs-btn-active-bg: var(--ink-2);
    --bs-btn-active-color: var(--bg);
    --bs-btn-active-border-color: var(--ink-2);
    --bs-btn-disabled-bg: var(--muted);
    --bs-btn-disabled-border-color: var(--muted);
}
.btn-outline-secondary, .btn-secondary {
    --bs-btn-bg: var(--surface);
    --bs-btn-color: var(--ink-2);
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-border-color: var(--line-strong);
    --bs-btn-active-bg: var(--surface-2);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-border-color: var(--line-strong);
}
.btn-outline-primary {
    --bs-btn-color: var(--accent);
    --bs-btn-border-color: color-mix(in oklab, var(--accent) 35%, var(--line));
    --bs-btn-bg: var(--surface);
    --bs-btn-hover-bg: var(--accent-soft);
    --bs-btn-hover-color: var(--accent-ink);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-bg: var(--accent-soft);
    --bs-btn-active-color: var(--accent-ink);
    --bs-btn-active-border-color: var(--accent);
}
.btn-outline-danger {
    --bs-btn-color: var(--bad);
    --bs-btn-border-color: color-mix(in oklab, var(--bad) 30%, var(--line));
    --bs-btn-bg: var(--surface);
    --bs-btn-hover-bg: var(--bad-soft);
    --bs-btn-hover-color: var(--bad);
    --bs-btn-hover-border-color: var(--bad);
    --bs-btn-active-bg: var(--bad-soft);
    --bs-btn-active-color: var(--bad);
    --bs-btn-active-border-color: var(--bad);
}

/* Forms */
.form-control, .form-select {
    background-color: var(--bg);
    border-color: var(--line);
    color: var(--ink);
    font-size: 13px;
    border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg);
    border-color: var(--accent);
    color: var(--ink);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--muted-2); }
.form-select {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2375716A' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.form-label {
    font-size: 10px; color: var(--muted);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em;
    font-weight: 500;
}
.form-text { color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); }

/* Badges (Bootstrap text-bg-* → scanbot tones) */
.badge {
    font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.02em;
    border-radius: 999px; font-size: 11px; padding: 2px 8px;
    border: 1px solid transparent;
}
.badge.text-bg-secondary {
    background-color: var(--surface-2) !important; color: var(--muted) !important;
    border-color: var(--line);
}
.badge.text-bg-success {
    background-color: var(--good-soft) !important; color: var(--good) !important;
    border-color: color-mix(in oklab, var(--good) 25%, transparent);
}
.badge.text-bg-warning {
    background-color: var(--warn-soft) !important; color: oklch(0.50 0.13 75) !important;
    border-color: color-mix(in oklab, var(--warn) 30%, transparent);
}
[data-theme="ink"] .badge.text-bg-warning { color: var(--warn) !important; }
.badge.text-bg-danger {
    background-color: var(--bad-soft) !important; color: var(--bad) !important;
    border-color: color-mix(in oklab, var(--bad) 25%, transparent);
}
.badge.text-bg-info, .badge.text-bg-primary {
    background-color: var(--accent-soft) !important; color: var(--accent) !important;
    border-color: color-mix(in oklab, var(--accent) 25%, transparent);
}
/* Scanbot tone aliases for new markup */
.badge.good { background: var(--good-soft); color: var(--good); border-color: color-mix(in oklab, var(--good) 25%, transparent); }
.badge.warn { background: var(--warn-soft); color: oklch(0.50 0.13 75); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }
[data-theme="ink"] .badge.warn { color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in oklab, var(--bad) 25%, transparent); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklab, var(--accent) 25%, transparent); }
.badge.muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.badge.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Alerts */
.alert { border-radius: var(--radius); font-size: 13px; }
.alert-success {
    --bs-alert-bg: var(--good-soft); --bs-alert-color: var(--good);
    --bs-alert-border-color: color-mix(in oklab, var(--good) 25%, transparent);
}
.alert-danger {
    --bs-alert-bg: var(--bad-soft); --bs-alert-color: var(--bad);
    --bs-alert-border-color: color-mix(in oklab, var(--bad) 25%, transparent);
}
.alert-warning {
    --bs-alert-bg: var(--warn-soft); --bs-alert-color: oklch(0.50 0.13 75);
    --bs-alert-border-color: color-mix(in oklab, var(--warn) 30%, transparent);
}
.alert-info {
    --bs-alert-bg: var(--accent-soft); --bs-alert-color: var(--accent-ink);
    --bs-alert-border-color: color-mix(in oklab, var(--accent) 25%, transparent);
}

/* Pagination */
.pagination {
    --bs-pagination-bg: var(--surface);
    --bs-pagination-color: var(--ink-2);
    --bs-pagination-border-color: var(--line);
    --bs-pagination-hover-bg: var(--surface-2);
    --bs-pagination-hover-color: var(--ink);
    --bs-pagination-hover-border-color: var(--line-strong);
    --bs-pagination-focus-bg: var(--surface-2);
    --bs-pagination-focus-color: var(--ink);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-disabled-color: var(--muted);
    --bs-pagination-disabled-border-color: var(--line);
    --bs-pagination-active-bg: var(--ink);
    --bs-pagination-active-border-color: var(--ink);
    font-family: var(--font-mono);
}

/* Progress (defense bars) */
.progress {
    --bs-progress-bg: var(--bg-deep);
    --bs-progress-bar-bg: var(--good);
    border-radius: 999px;
}

/* Text utilities → tokens */
.text-muted { color: var(--muted) !important; }
.text-success { color: var(--good) !important; }
.text-danger { color: var(--bad) !important; }
.text-primary { color: var(--accent) !important; }
.text-secondary { color: var(--muted-2) !important; }
.border, .border-bottom, .border-top { border-color: var(--line) !important; }
code { color: var(--accent-ink); font-family: var(--font-mono); }
pre { color: var(--ink-2); }
.font-monospace { font-family: var(--font-mono) !important; }

/* ── Toasts (server-rendered Django messages) ──────────────────────────── */
.toast-stack {
    position: fixed; right: 24px; bottom: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 1000; max-width: 360px;
}
.toast-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 12px;
    font-size: 13px; color: var(--ink);
    animation: toast-in 180ms ease-out;
    transition: opacity 300ms ease;
}
.toast-item.tone-success { border-left-color: var(--good); }
.toast-item.tone-warning { border-left-color: var(--warn); }
.toast-item.tone-error, .toast-item.tone-danger { border-left-color: var(--bad); }
.toast-item.fade-out { opacity: 0; }
.toast-close {
    margin-left: auto;
    border: 0; background: transparent; cursor: pointer;
    color: var(--muted); font-size: 15px; line-height: 1; padding: 0 2px;
}
.toast-close:hover { color: var(--ink); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Map page (standalone, full window) ─────────────────────────────── */
.map-page { margin: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font-sans); }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 12px; background: var(--bg-deep); border-bottom: 1px solid var(--line); font-size: 13px; }
.map-toolbar .form-check { margin: 0; }
.map-toolbar .form-check-label { font-size: 13px; }
.map-toolbar .form-select-sm, .map-toolbar .form-control-sm { font-size: 12px; }
.map-stage { flex: 1; position: relative; min-height: 0; }
.map-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-stage canvas.dragging { cursor: grabbing; }
.map-tip { position: absolute; z-index: 5; max-width: 300px; padding: 6px 8px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius-sm); font: 12px/1.35 var(--font-mono); pointer-events: none; }
.map-tip.pinned { pointer-events: auto; }
.map-tip .tip-head { font-weight: 600; }
.map-tip a { display: inline-block; margin: 4px 8px 0 0; }
.map-status { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.map-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 3px; border: 1px solid rgba(0,0,0,.15); }
