:root {
  --bg: #0a0a0b;
  --surface: #1d1d1f;
  --surface-2: #252528;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: #a1a1aa;
  --accent: #d60f5e;
  --accent-2: #fa1571;
  --accent-3: #ff5c9d;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent-3); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 12px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.brand small { font-weight: 500; color: var(--accent-3); margin-left: 4px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-3)); box-shadow: 0 6px 20px rgba(214, 15, 94, 0.35); }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: rgba(10, 10, 11, 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 10px; white-space: nowrap; font-weight: 500; font-size: 0.92rem; }
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: inset 0 -2px 0 var(--accent-2); }
.user-box { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
main.view { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- controls ---------- */
.btn { appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 0.9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: background 0.15s, border-color 0.15s, transform 0.05s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.24); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { background: linear-gradient(135deg, var(--accent-2), var(--accent-3)); }
.btn.danger { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.82rem; }
.btn.lg { padding: 13px 22px; font-size: 1rem; }
label { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 0.93rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(250, 21, 113, 0.18); }
input[type='checkbox'] { width: auto; display: inline-block; margin: 0 6px 0 0; accent-color: var(--accent-2); }
textarea { min-height: 220px; font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.form-row { margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; color: var(--text); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.num-card { cursor: pointer; transition: border-color 0.15s, transform 0.15s; display: flex; flex-direction: column; gap: 10px; }
.num-card:hover { border-color: rgba(250, 21, 113, 0.45); transform: translateY(-1px); }
.num-card .title { font-weight: 600; font-size: 1.05rem; }
.num-card .phone { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; }
.num-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.empty { text-align: center; padding: 48px 20px; }
.empty .btn { margin-top: 8px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.chip.green { color: #4ade80; background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.3); }
.chip.yellow { color: #facc15; background: rgba(234, 179, 8, 0.12); border-color: rgba(234, 179, 8, 0.3); }
.chip.red { color: #f87171; background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.3); }
.chip.pink { color: var(--accent-3); background: rgba(214, 15, 94, 0.14); border-color: rgba(250, 21, 113, 0.35); }
.chip.plain::before { display: none; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent-2); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; background: rgba(255, 255, 255, 0.02); }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: rgba(255, 255, 255, 0.025); }
.kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px 16px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

pre.json { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word; color: #e4e4e7; margin: 8px 0 0; }

/* routes editor */
.route-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(200px, 2.4fr) auto auto; gap: 10px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--border); }
.route-row:last-of-type { border-bottom: 0; }
.route-row input { margin-top: 4px; }

/* notices */
.notice { border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; border: 1px solid var(--border-strong); background: var(--surface-2); margin: 12px 0; }
.notice.info { border-color: rgba(250, 21, 113, 0.35); background: rgba(214, 15, 94, 0.08); }
.notice.ok { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); }
.notice.err { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.08); }
.notice.warn { border-color: rgba(234, 179, 8, 0.45); background: rgba(234, 179, 8, 0.08); }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent-2); padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5); animation: rise 0.2s ease-out; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 80% -10%, rgba(214, 15, 94, 0.18), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 0.8rem; color: var(--muted); }
.auth-foot a { color: var(--muted); margin: 0 6px; }

/* ---------- public docs ---------- */
.doc-header { padding: 18px 24px; border-bottom: 1px solid var(--border); }
.doc { max-width: 780px; margin: 0 auto; padding: 36px 24px 48px; }
.doc h1 { font-size: 1.8rem; margin-bottom: 8px; }
.doc h2 { margin-top: 28px; color: var(--accent-3); }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc-form { margin-top: 24px; display: grid; gap: 12px; max-width: 420px; }
.doc-footer { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; padding: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.doc-footer a { color: var(--muted); }
.doc-footer a:hover { color: var(--accent-3); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .topbar .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; }
  main.view { padding: 20px 16px 48px; }
  .card { padding: 16px; }
  h1 { font-size: 1.35rem; }
  .route-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .doc, .doc-header { padding-left: 16px; padding-right: 16px; }
  .user-box .who { display: none; }
}
