:root {
  /* from the Horizon logo: navy #0c182c, ice #cce0fa, blue #3784fb -> violet #8158fd */
  --bg: #08111f;
  --card: #0c182c;
  --card-2: #0a1424;
  --line: #1c2b45;
  --text: #e4eefc;
  --muted: #8a96ad;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --grad: linear-gradient(100deg, #3784fb, #8158fd);
  --violet: #a78bfa;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* brand + top bar */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; color: var(--text); letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  padding: 12px 16px; background: rgba(8, 17, 31, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
#nav a:hover { color: var(--text); background: var(--card); text-decoration: none; }
#nav a.active { color: var(--text); background: var(--card); box-shadow: inset 0 -2px 0 var(--accent); }
.who { display: flex; gap: 10px; align-items: center; }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }
h1 { font-size: 22px; font-weight: 650; margin: 4px 0 4px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 30px 0 10px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-end; }
.lede { color: var(--muted); margin: 0; max-width: 70ch; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }

.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.prepaid { color: var(--accent); border-color: rgba(91, 140, 255, .4); }
.badge.postpaid { color: var(--violet); border-color: rgba(167, 139, 250, .35); }
.badge.unlimited { color: var(--ok); border-color: rgba(52, 211, 153, .35); }
.badge.suspended, .badge.revoked { color: var(--bad); border-color: rgba(248, 113, 113, .35); }
.badge.legacy { color: var(--warn); border-color: rgba(251, 191, 36, .35); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num input { text-align: right; }
.empty { color: var(--muted); padding: 18px 8px; text-align: center; }

/* chart */
.chart { margin-top: 10px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 10px 10px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.bar { flex: 1; min-width: 3px; max-width: 28px; height: 100%; display: flex; flex-direction: column-reverse; position: relative; }
.bar .fill { background: linear-gradient(180deg, #8158fd, #3784fb); opacity: .8; border-radius: 3px 3px 0 0; min-height: 0; }
.bar .fill.err { background: var(--bad); opacity: .9; border-radius: 0; }
.bar:hover .fill { opacity: 1; }
.axis { display: flex; justify-content: space-between; padding: 6px 10px; font-size: 11px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* forms */
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(91, 140, 255, .5); outline-offset: 0; border-color: transparent; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input.narrow { width: 110px; }
button { cursor: pointer; background: var(--grad); color: var(--accent-ink); border: 0; font-weight: 650; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.danger { background: transparent; color: var(--bad); border: 1px solid rgba(248, 113, 113, .4); font-weight: 500; }
button.small, .small button { padding: 4px 10px; font-size: 12px; }
.form { display: grid; gap: 12px; }
.form label, .field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.mode { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--text); font-size: 13px; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode span { color: var(--muted); font-size: 12px; }
.mode.on { border-color: var(--accent); background: rgba(91, 140, 255, .08); }

/* login */
#login { max-width: 380px; margin: 14vh auto 0; padding: 0 16px; }
#login { text-align: center; }
.login-logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 12px 40px rgba(55, 132, 251, .25); }
.login-title { justify-content: center; font-size: 22px; margin-top: 14px; }
#login-form { text-align: left; }
#login-form { display: grid; gap: 12px; margin-top: 20px; }
#login-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
#login-form input { width: 100%; }

/* modal + toast */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(3, 7, 15, .7); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(560px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.keybox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px; word-break: break-all; }
.keybox code { flex: 1; font-size: 13px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .35); }
.toast.bad { border-color: rgba(248, 113, 113, .5); color: var(--bad); }

@media (max-width: 560px) {
  .card .value { font-size: 18px; }
  th, td { padding: 6px 5px; }
  .who #who { display: none; }
  .top { justify-content: space-between; }
  #nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; }
  #nav a { white-space: nowrap; }
}
