:root {
  --bg: #f4f6fa; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --navy: #0b1b3b; --accent: #2563eb; --accent-soft: #e8f0fe; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* sign in */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.code-input { letter-spacing: .5em; font-size: 22px; text-align: center; }
.err { color: var(--bad); font-size: 14px; min-height: 1.4em; margin: 6px 0 0; }
.ok-note { color: var(--ok); font-size: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.wide { width: 100%; }

/* shell */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; height: 54px; }
.top .brand { margin: 0; color: #fff; }
.top .brand-mark { background: #16295a; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { color: #cbd5e1; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; background: none; border: 0; cursor: pointer; white-space: nowrap; }
.tab:hover { background: #16295a; color: #fff; }
.tab.on { background: #fff; color: var(--navy); }
.who { font-size: 13px; color: #cbd5e1; white-space: nowrap; }
.who button { color: #fff; background: none; border: 1px solid #334a7c; border-radius: 8px; padding: 4px 10px; cursor: pointer; margin-left: 8px; }
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 14px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.tile .sub { font-size: 13px; color: var(--muted); }
.cols2 { grid-template-columns: 2fr 1fr; }
.cols3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 880px) { .cols2, .cols3 { grid-template-columns: 1fr; } .who span { display: none; } }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; margin-right: 6px; box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
th.sortable { cursor: pointer; }
th.sortable.on { color: var(--accent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafc; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f7; color: #334155; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.lock { background: #e0e7ff; color: #3730a3; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* live feed */
.feed { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: baseline; }
.feed li.new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.feed .t { color: var(--muted); font-size: 12px; min-width: 62px; font-variant-numeric: tabular-nums; }
.feed .p { flex: 1; word-break: break-all; }
.feed .m { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* chart */
.chart { display: block; max-width: 100%; }
.chart .bar { fill: #93b4f5; }
.chart .bar:hover { fill: var(--accent); }
.chart .axis { stroke: var(--line); }
.chart text { font-size: 10px; fill: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.bars { display: grid; gap: 7px; }
.bars .b { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 14px; position: relative; }
.bars .b .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); border-radius: 6px; z-index: 0; }
.bars .b span { position: relative; z-index: 1; padding: 2px 6px; word-break: break-all; }

/* files */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 14px; }
.crumbs a { font-weight: 600; }
.crumbs i { color: var(--muted); font-style: normal; }
.fname { display: flex; align-items: center; gap: 8px; font-weight: 600; word-break: break-all; }
.fname svg { flex: none; }
.acts { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.drop { border: 2px dashed #b6c4dc; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); background: #fbfcfe; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.checks { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; margin: 8px 0; }
.checks label { display: flex; align-items: center; gap: 6px; }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.results { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; }
.results li { padding: 3px 0; }
.results .bad { color: var(--bad); }
.results .good { color: var(--ok); }

/* dialog */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.big { max-width: 900px; }
.modal h2 { margin-bottom: 12px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.editor { width: 100%; min-height: 380px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.note { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* phones */
.tablewrap table { min-width: 620px; }
.pill { white-space: nowrap; }
.fname { overflow-wrap: anywhere; word-break: normal; }
.fname a { min-width: 0; }
@media (max-width: 700px) {
  .top-in { flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 6px 10px; }
  .top .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  .tabs { order: 3; flex: 1 0 100%; padding-bottom: 8px; }
  main { padding: 14px 12px 50px; }
  .tile .num { font-size: 24px; }
  .modal { padding: 16px; }
}
td:first-child { min-width: 170px; }
.tablewrap td.num, .tablewrap th.num { white-space: nowrap; }
@media (max-width: 700px) { .tab { padding: 8px 9px; font-size: 13px; } }
