@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0e1014;
  --panel: #15181e;
  --panel-2: #1b1f27;
  --panel-3: #222733;
  --line: #262b35;
  --line-2: #323846;
  --text: #e7e9ee;
  --muted: #959cab;
  --faint: #636a79;
  --accent: #e5484d;
  --accent-2: #c9393e;
  --accent-soft: #3a1a1c;
  --ok: #3dd68c;
  --ok-soft: #12291f;
  --warn: #f5a524;
  --warn-soft: #2e2412;
  --bad: #f2555a;
  --bad-soft: #321718;
  --info: #6b9cf7;
  --info-soft: #172238;
  --radius: 8px;
  --sidebar: 232px;
  --top: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 'Inter', system-ui, sans-serif;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--info); cursor: pointer; }
a.link:hover, .link:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
code, .mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.hidden { display: none !important; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.sm { width: 15px; height: 15px; }
svg.icon.lg { width: 22px; height: 22px; }

/* layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--top) 1fr; height: 100vh; }
.sidebar { grid-row: 1 / 3; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { height: var(--top); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.brand .name { font-weight: 700; line-height: 1.1; }
.brand .sub { font-size: 11.5px; color: var(--muted); }
.nav { padding: 10px 10px 16px; overflow-y: auto; flex: 1; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--panel-3); color: var(--text); }
.nav a .count { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.me { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.me img, .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-3); flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who div:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; padding-left: 34px; }
.search > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius); z-index: 1200; max-height: 420px; overflow-y: auto; padding: 4px; }
.results button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.results button:hover, .results button.on { background: var(--panel-3); }
.server-chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 20px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }
.btn.menu-toggle { display: none; }

.main { overflow-y: auto; min-width: 0; }
.page { padding: 24px 28px 48px; max-width: 1500px; }
.page.full { max-width: none; padding: 0; height: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow p { margin: 4px 0 0; color: var(--muted); }

/* controls */
input, select, textarea, .input {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--info); }
textarea { resize: vertical; min-height: 80px; width: 100%; }
input[type='datetime-local'] { color-scheme: dark; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.field input, label.field select, label.field textarea { color: var(--text); font-size: 14px; }
label.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: #4a2427; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { color: var(--ok); border-color: #1f4a35; }
.btn.ok:hover { background: var(--ok-soft); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.icon-only { padding: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); font-size: 12.5px; cursor: pointer; user-select: none; }
.chip:hover { color: var(--text); }
.chip.on { color: var(--text); border-color: currentColor; }
.chip .swatch { width: 8px; height: 8px; border-radius: 2px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cat i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card > .head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .head h2, .card > .head h3 { flex: 1; }
.card > .body { padding: 16px; }
.card > .body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 360px; }
.stat { padding: 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stat .stat-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .n { color: var(--faint); margin-left: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--panel-2); }
.table tbody tr.on td { background: var(--panel-3); }
.table td.msg { max-width: 520px; overflow-wrap: anywhere; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 14px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .field input, .filters .field select { min-width: 140px; }
.preset { display: flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.preset button { background: var(--panel-2); border: 0; border-right: 1px solid var(--line-2); color: var(--muted); padding: 7px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.preset button:last-child { border-right: 0; }
.preset button.on { background: var(--panel-3); color: var(--text); }

/* timeline chart */
.chart-box { position: relative; }
.chart { width: 100%; display: block; }
.chart-label { position: absolute; font-size: 10.5px; color: var(--faint); pointer-events: none; white-space: nowrap; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: inherit; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.bars { padding: 10px 16px 4px; border-bottom: 1px solid var(--line); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line-2); z-index: 1500; display: flex; flex-direction: column; }
.drawer .head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer .head h2 { flex: 1; }
.drawer .body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
pre.json { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 0; overflow: auto; max-height: 420px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* modal */
.scrim { position: fixed; inset: 0; background: rgba(5, 6, 8, 0.72); z-index: 2000; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(820px, 100%); }
.modal .head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal .head h2 { flex: 1; }
.modal .body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span { grid-column: 1 / -1; }
.callout { padding: 10px 12px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); font-size: 13px; }
.callout.warn { background: var(--warn-soft); border-color: #4d3b16; color: var(--warn); }
.callout.ok { background: var(--ok-soft); border-color: #1f4a35; color: var(--ok); }
.callout.bad { background: var(--bad-soft); border-color: #4a2427; color: var(--bad); }

/* toast */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 14px; min-width: 240px; max-width: 420px; display: flex; gap: 10px; align-items: flex-start; }
.toast.ok svg { color: var(--ok); }
.toast.bad svg { color: var(--bad); }
.toast.warn svg { color: var(--warn); }

/* lists */
.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item.click { cursor: pointer; }
.list .item.click:hover { background: var(--panel-2); }
.list .item .title { font-weight: 600; }
.feed-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-line .arrow { color: var(--faint); }

.notes { display: flex; flex-direction: column; gap: 10px; }
.note { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel-2); }
.note.internal { border-color: #4d3b16; background: var(--warn-soft); }
.note.system { background: none; border-style: dashed; color: var(--muted); font-size: 13px; padding: 6px 12px; }
.note .meta { font-size: 12px; color: var(--faint); margin-bottom: 4px; display: flex; gap: 8px; }
.note .text { white-space: pre-wrap; overflow-wrap: anywhere; }

.thread { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.thread .msg { font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--panel-2); }
.thread .msg b { font-weight: 600; }

.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.profile-head .big { width: 56px; height: 56px; border-radius: 12px; background: var(--panel-3); display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--muted); }
.char-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.char { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel-2); }
.char.deleted { opacity: 0.55; }
.char .name { font-weight: 600; }
.char .money { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }

.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 8px; background: var(--panel-3); border-radius: 4px; overflow: hidden; display: flex; }
.bar-row .fill { height: 100%; background: var(--ok); }
.bar-row .fill.neg { background: var(--bad); }

/* map */
.map-page { position: relative; height: calc(100vh - var(--top)); }
#map { position: absolute; inset: 0; background: #006dd5; }
.map-panel { position: absolute; top: 14px; left: 14px; bottom: 14px; width: 340px; z-index: 1000; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.map-panel.collapsed { bottom: auto; }
.map-panel .tabs { margin: 0; padding: 0 8px; }
.map-panel .pane { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.map-player { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.map-player:hover { background: var(--panel-2); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }
.leaflet-container { font: inherit; }
.leaflet-tooltip.blip { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; font-size: 12px; padding: 3px 7px; }
.leaflet-tooltip.blip::before { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); }
.leaflet-popup-content-wrapper { border-radius: 8px; }
.leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.45; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line-2) !important; }
.leaflet-control-attribution { display: none; }
.coords-box:empty { display: none; }
.coords-box { position: absolute; right: 14px; bottom: 14px; z-index: 1000; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 9px; font-size: 12px; color: var(--muted); }
.scrub { width: 100%; }
.mini-map { height: 260px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); position: relative; background: #006dd5; }

/* plain pages */
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.notice { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px; text-align: center; }
.notice h1 { margin-bottom: 10px; }
.notice p { color: var(--muted); }
.notice .mark { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; margin: 0 auto 18px; }
.button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 10px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; border: 0; cursor: pointer; font: inherit; }
.button.discord { background: #5865f2; }

@media (max-width: 1100px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three, .grid.side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 1800; transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .btn.menu-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; grid-column: 1; }
  .server-chip .label { display: none; }
  .page { padding: 16px 16px 40px; }
  .grid.two, .grid.four { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 110px 1fr; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .map-panel { width: auto; right: 14px; top: auto; height: 46%; }
  .bar-row { grid-template-columns: 110px 1fr 90px; }
}

@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .no-print, .toasts, .btn { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; }
  .page { padding: 0; max-width: none; }
  .card, .note { border-color: #bbb; background: #fff; color: #000; }
  .muted, .faint, .note .meta, .table th { color: #444; }
  .table th { background: #fff; position: static; }
  .pill, .cat { color: #000; background: #eee; }
  a.link { color: #000; }
}
