/* ---- vendored fonts (self-contained, variable weight) ---- */
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../vendor/fonts/public-sans-wght.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('../vendor/fonts/jetbrains-mono-wght.woff2') format('woff2');
}

/* ---- palette (matches the reference design) ---- */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --sidebar: #fbfbfd;
  --panel: #ffffff;
  --panel-2: #f0f2f6;
  --panel-3: #fafbfd;
  --border: #eaecef;
  --border-2: #eef0f3;

  --text: #2a2f3a;
  --text-body: #3a4150;
  --text-2: #4a5262;
  --muted: #8a92a0;
  --faint: #a6adb8;

  --accent: #5b7cfa;
  --accent-ink: #3a49c9;
  --accent-soft: #eef1ff;
  --grad-a: #5b7cfa;
  --grad-b: #7d6bf0;

  --teal: #1d9e88;
  --teal-2: #3bbfa9;
  --teal-soft: #e9f7f3;
  --red: #c9503d;
  --red-2: #ef7a6b;
  --red-soft: #fdeeeb;
  --amber: #b57e1e;
  --amber-2: #e0a23b;
  --amber-soft: #fbf3e4;
  --purple: #7a52c9;
  --purple-2: #9b7bf0;
  --purple-soft: #f2edfd;

  --shadow: 0 1px 2px rgba(20, 25, 40, .03);
  --shadow-md: 0 4px 14px rgba(20, 25, 40, .08);
  --shadow-btn: 0 2px 6px rgba(91, 124, 250, .32);
  --radius: 13px;
  --radius-sm: 9px;
  --pill: 20px;

  --font: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.layout { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
  width: 236px; flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 20px 20px 16px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border-2);
}
.brand .logo {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: linear-gradient(140deg, var(--grad-a), var(--grad-b));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(91, 124, 250, .35); flex: none;
}
.brand .logo::after { content: ''; width: 11px; height: 11px; border-radius: 50%; background: #fff; }
.brand .name { font-weight: 800; font-size: 15px; letter-spacing: -.2px; color: var(--text); line-height: 1.1; }
.brand .sub { font-size: 10.5px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav .group {
  font-size: 10px; font-weight: 700; letter-spacing: .9px; color: var(--faint);
  padding: 6px 10px; text-transform: uppercase;
}
.nav .group:not(:first-child) { padding-top: 16px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 2px;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a .ico { width: 15px; height: 15px; flex: none; opacity: .85; }
.nav a.active .ico { opacity: 1; }

.side-foot {
  padding: 12px 16px; border-top: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px;
}
.side-foot .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 700; font-size: 12px; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.side-foot .who { line-height: 1.2; flex: 1; min-width: 0; }
.side-foot .who b { font-size: 12.5px; font-weight: 600; color: var(--text); }
.side-foot .who span { font-size: 10.5px; color: var(--muted); display: block; }
.side-foot .live { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-2); flex: none; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: none;
  background: rgba(251, 251, 253, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 26px;
  position: sticky; top: 0; z-index: 5;
}
.topbar .title { font-weight: 700; font-size: 16.5px; letter-spacing: -.3px; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .status {
  display: flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--muted); font-family: var(--mono);
}
.topbar .status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal-2); }

.main { padding: 22px 26px; max-width: 1440px; width: 100%; }

/* page head: title now lives in the topbar, so hide the generic h1 and keep
   only dynamic (mono) ids like a sender msisdn */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { display: none; }
.page-head h1.mono { display: block; font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.tile .k { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 27px; font-weight: 750; margin-top: 7px; line-height: 1; color: var(--text); letter-spacing: -.5px; }
.tile .v.small { font-size: 18px; }

/* ---- KPI stat cards (reference) ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .1px; }
.stat-ico { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.stat-val { font-size: 27px; font-weight: 800; letter-spacing: -.7px; font-family: var(--mono); line-height: 1; color: var(--text); }
.stat-delta { font-size: 11.5px; margin-top: 8px; font-weight: 600; }

/* ---- overview panels ---- */
.ptitle { font-size: 13.5px; font-weight: 700; color: var(--text); }
.psub { font-size: 11px; color: var(--faint); margin-top: 2px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.ov-grid-a { display: grid; grid-template-columns: 1.65fr 1fr; gap: 16px; margin-bottom: 16px; }
.ov-grid-b { display: grid; grid-template-columns: 1fr 1.65fr; gap: 16px; }
@media (max-width: 900px) { .ov-grid-a, .ov-grid-b { grid-template-columns: 1fr; } }

.legend { display: flex; gap: 14px; font-size: 11.5px; font-weight: 600; }
.legend span { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.volbars { display: flex; align-items: flex-end; gap: 5px; height: 150px; margin-top: 14px; }
.volbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 100%; }
.vol-in { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.vol-out { width: 100%; background: var(--teal-2); border-radius: 0 0 3px 3px; min-height: 2px; }
.vol-axis { display: flex; justify-content: space-between; font-size: 10px; color: #b4bac4; margin-top: 8px; }

.toplist { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.topitem b { font-weight: 700; font-size: 12.5px; color: var(--text); }
.barmini { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.barmini > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-2)); border-radius: 4px; }

.guard-nums { display: flex; align-items: flex-end; gap: 22px; margin: 16px 0 14px; }
.gnum { font-size: 26px; font-weight: 800; line-height: 1; font-family: var(--mono); }
.glbl { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.guard-split { height: 10px; border-radius: 6px; overflow: hidden; display: flex; background: var(--panel-2); }

.feed { display: flex; flex-direction: column; }
.feed-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-2); }
.feed-row:last-child { border-bottom: none; }
.ftime { font-size: 10.5px; color: var(--faint); width: 42px; flex: none; }
.fsender { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.freason { font-size: 11.5px; }

/* ---- panels ---- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--border-2); font-weight: 700; font-size: 13.5px; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-body { padding: 15px 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ---- chart ---- */
.chart { width: 100%; height: 300px; }
.chart.sm { height: 220px; }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border-2); white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-3); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-3); }
td.wrap, th.wrap { white-space: normal; }

/* ---- badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: var(--pill); font-size: 11px; font-weight: 700; line-height: 1.4; }
.badge.green { background: var(--teal-soft); color: var(--teal); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: var(--panel-2); color: var(--muted); }
.badge.blue { background: var(--accent-soft); color: var(--accent-ink); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

/* ---- controls ---- */
input, select, button, textarea { font-family: inherit; font-size: 13px; color: inherit; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px; outline: none; color: var(--text-body);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 8px 15px; font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-btn); transition: filter .12s;
}
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--panel); color: var(--text-2); border: 1px solid var(--border); box-shadow: none; }
.btn.ghost:hover { background: var(--panel-2); filter: none; }
.btn.danger { background: var(--red); box-shadow: 0 2px 6px rgba(201, 80, 61, .28); }
.btn.sm { padding: 5px 11px; font-size: 12px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .spacer { flex: 1; }

.progress { height: 8px; background: var(--panel-2); border-radius: var(--pill); overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--pill); }
.progress > span.warn { background: var(--amber-2); }
.progress > span.over { background: var(--red); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.error { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 22%, transparent); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.up { background: var(--teal-2); }
.dot.down { background: var(--red); }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 25, 40, .38); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); width: min(480px, 92vw); box-shadow: var(--shadow-md); }
.modal .panel-body { display: grid; gap: 11px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.spin { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- login gate ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.login-card {
  width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 28px 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand .logo {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: linear-gradient(140deg, var(--grad-a), var(--grad-b));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(91, 124, 250, .35);
}
.login-brand .logo::after { content: ''; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.login-brand .name { font-weight: 800; font-size: 19px; letter-spacing: -.3px; color: var(--text); }
.login-sub { font-size: 12.5px; color: var(--muted); margin-top: -6px; }
.login-card input { padding: 10px 12px; font-size: 14px; }
.login-card input.bad { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.login-card .btn { padding: 10px; font-size: 14px; margin-top: 2px; }
.login-err { font-size: 12px; color: var(--red); margin-top: -6px; }
.side-foot .logout { color: var(--faint); font-size: 16px; text-decoration: none; padding: 2px 4px; border-radius: 6px; }
.side-foot .logout:hover { color: var(--red); background: var(--red-soft); }
