/* Self-hosted typefaces (no third-party requests). */
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("/static/fonts/barlow-700.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 800; font-display: swap; src: url("/static/fonts/barlow-800.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/plexmono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/plexmono-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/plexmono-600.woff2") format("woff2"); }

/* 711 — operator's routing ledger.
   Palette is semantic: red = action, green = online, orange = price, white = base. */
:root {
  --paper: #ffffff;
  --panel: #f6f7f9;
  --ink: #14161a;
  --muted: #5b6472;
  --faint: #8b94a3;
  --hair: #e6e8ec;
  --hair-strong: #d3d7de;
  --red: #d21f3c;
  --red-dark: #ad1730;
  --green: #17914f;
  --green-dark: #0f6f3c;
  --orange: #e07b1a;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--paper); color: var(--ink);
  line-height: 1.55; font-size: 15px;
  min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(210, 31, 60, .14); }

/* ---- Header: the single signature element is the tri-color rule ---- */
header { background: var(--paper); position: relative; }
header::after {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--red) 0 33.33%, var(--orange) 33.33% 66.66%, var(--green) 66.66% 100%);
}
.nav { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 58px; padding: 0 24px; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand b { font-size: 22px; font-weight: 800; letter-spacing: -0.6px; color: var(--ink); }
.brand span { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .04em; }
.nav-links { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--red); }
.nav-links a:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px; border-radius: 3px;
}

/* ---- Layout ---- */
main { flex: 1; max-width: 1240px; margin: 0 auto; padding: 34px 24px 48px; width: 100%; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--hair-strong); padding-bottom: 14px; margin-bottom: 20px; }
h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.sub { color: var(--muted); font-size: 14px; max-width: 62ch; }
.rule-label { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--faint); }

/* ---- Ledger stats strip ---- */
.ledger { display: flex; gap: 0; border: 1px solid var(--hair-strong); border-radius: 3px; overflow: hidden; margin-bottom: 22px; }
.ledger div { flex: 1; padding: 14px 16px; border-right: 1px solid var(--hair); }
.ledger div:last-child { border-right: 0; }
.ledger .n { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: -0.5px; }
.ledger .k { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---- Buttons ---- */
.btn { display: inline-block; padding: 9px 16px; background: var(--red); color: #fff; text-decoration: none; border-radius: 3px; font-size: 14px; font-weight: 600; border: 1px solid var(--red); cursor: pointer; font-family: var(--sans); }
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--hair-strong); }
.btn-ghost:hover { background: var(--panel); border-color: var(--faint); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Forms ---- */
.form-container { max-width: 380px; margin: 44px auto; }
.form-container h1 { text-align: left; margin-bottom: 6px; }
form { display: flex; flex-direction: column; gap: 12px; }
input, textarea, select {
  padding: 10px 12px; border: 1px solid var(--hair-strong); border-radius: 3px;
  font-size: 14px; font-family: var(--sans); background: #fff; color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--ink); }
textarea { resize: vertical; min-height: 96px; }

/* ---- Messages ---- */
.error, .notice, .success, .warn { padding: 10px 12px; border-radius: 3px; margin-bottom: 14px; font-size: 14px; border-left: 3px solid; }
.error { background: #fdf1f3; border-color: var(--red); color: #8f1428; }
.notice, .success { background: #eef7f1; border-color: var(--green); color: #0f6f3c; }
.warn { background: #fdf4e8; border-color: var(--orange); color: #8a4a10; }

/* ---- Map ---- */
.map-wrap { position: relative; border: 1px solid var(--hair-strong); border-radius: 3px; background: var(--paper); }
#worldmap { width: 100%; height: auto; display: block; }
.country-path { fill: #f0f2f5; stroke: #fff; stroke-width: .5; cursor: pointer; transition: fill .12s; }
#tooltip { position: absolute; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 3px; font-family: var(--mono); font-size: 12px; pointer-events: none; display: none; z-index: 20; white-space: nowrap; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 10px; font-family: var(--mono); }
.legend .dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: baseline; }
.map-stats { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 10px; }

/* ---- Tables: the product's real content ---- */
.table-wrap { border: 1px solid var(--hair-strong); border-radius: 3px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--hair); font-size: 13.5px; vertical-align: middle; }
thead th {
  position: sticky; top: 0; background: var(--panel);
  font-family: var(--mono); font-weight: 600; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--hair-strong); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfbfc; }
.mono, td.mono { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.tag { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--hair-strong); border-radius: 3px; padding: 1px 5px; color: var(--muted); white-space: nowrap; }
.empty { font-family: var(--mono); font-size: 13px; color: var(--muted); padding: 34px 12px; text-align: center; }
/* Keep the buy action reachable while the ledger scrolls horizontally */
.table-wrap th.col-action, .table-wrap td.col-action {
  position: sticky; right: 0; background: var(--paper); border-left: 1px solid var(--hair-strong);
}
.table-wrap thead th.col-action { background: var(--panel); }

/* ---- Signal swatches (online/offline/available) ---- */
.signal { display: inline-block; width: 8px; height: 8px; vertical-align: 1px; margin-right: 7px; }
.signal.on { background: var(--green); }
.signal.off { background: var(--hair-strong); }
.signal.warn { background: var(--orange); }
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border: 1px solid var(--hair-strong); border-radius: 3px; font-size: 13px; color: var(--ink); text-decoration: none; background: #fff; white-space: nowrap; margin: 0 6px 6px 0; font-family: var(--mono); }
.chip:hover { border-color: var(--ink); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .cnt { color: var(--faint); margin-left: 6px; }
.chip.active .cnt { color: rgba(255,255,255,.65); }

/* Price reads in orange, never as decoration */
.price { font-family: var(--mono); color: var(--orange); font-weight: 600; }
.price small { color: var(--faint); font-weight: 400; margin-left: 2px; }

/* ---- Admin: denser, dashboard profile ---- */
.admin-wrap { display: flex; gap: 28px; align-items: flex-start; margin-top: 8px; }
.admin-side { flex: 0 0 168px; position: sticky; top: 20px; }
.admin-side a { display: block; padding: 7px 11px; color: var(--muted); text-decoration: none; border-radius: 3px; margin-bottom: 2px; font-size: 14px; }
.admin-side a:hover { background: var(--panel); color: var(--ink); }
.admin-side a.active { background: var(--ink); color: #fff; }
.admin-content { flex: 1; min-width: 0; }
.credit-form { display: flex; gap: 6px; }
.credit-form input { width: 100px; padding: 6px 8px; }

/* ---- Tickets / chat ---- */
.chat { border: 1px solid var(--hair-strong); border-radius: 3px; padding: 14px; margin: 14px 0; }
.chat-msg { padding: 9px 12px; border-radius: 3px; margin-bottom: 8px; max-width: 72%; font-size: 14px; }
.chat-msg.admin { background: var(--ink); color: #fff; margin-left: auto; }
.chat-msg.user { background: var(--panel); color: var(--ink); }
.chat-meta { font-family: var(--mono); font-size: 11px; color: var(--faint); margin: 2px 0 10px; }
.ticket-head { border: 1px solid var(--hair-strong); border-radius: 3px; padding: 14px; margin: 14px 0; }
.ticket-head .meta { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,22,26,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal { background: #fff; border-radius: 4px; padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 18px 50px rgba(20,22,26,.22); }
.modal h2 { margin-bottom: 4px; }
.conn { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--hair); font-size: 13px; }
.conn:last-of-type { border-bottom: 0; }
.conn .k { color: var(--muted); }
.conn .v { font-family: var(--mono); font-size: 12px; text-align: right; word-break: break-all; }
.hint { background: var(--panel); border: 1px solid var(--hair); border-radius: 3px; padding: 10px; margin: 12px 0; font-family: var(--mono); font-size: 11.5px; overflow-x: auto; white-space: pre; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ---- Footer ---- */
footer { border-top: 1px solid var(--hair-strong); padding: 16px 24px; color: var(--faint); font-size: 12px; font-family: var(--mono); }
footer .inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; gap: 16px; }

@media (max-width: 820px) {
  .admin-wrap { flex-direction: column; }
  .admin-side { position: static; width: 100%; display: flex; flex-wrap: wrap; gap: 4px; }
  .ledger { flex-wrap: wrap; }
  .ledger div { flex: 1 1 45%; border-bottom: 1px solid var(--hair); }
  .page-head { flex-direction: column; align-items: flex-start; }
}

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