/* WA Gateway dashboard */
:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-2: #f9faf9;
  --text: #17201c;
  --muted: #64716b;
  --line: #e2e7e4;
  --accent: #0f7a5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ec;
  --side: #10201a;
  --side-text: #c9d6d0;
  --side-active: #1c3a2f;
  --ok: #157f4a;   --ok-bg: #e2f5ea;
  --warn: #9a6400; --warn-bg: #fdf1d8;
  --bad: #b42318;  --bad-bg: #fde8e6;
  --info: #1d5fa8; --info-bg: #e5effa;
  --mut-bg: #eef1ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 26, .06), 0 1px 1px rgba(16, 32, 26, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1512; --panel: #141f1b; --panel-2: #18251f; --text: #e4ece8; --muted: #93a49c;
    --line: #24342d; --accent: #2bb586; --accent-ink: #06130e; --accent-soft: #163428;
    --side: #08100d; --side-text: #a9bab2; --side-active: #15291f;
    --ok: #4fd18d; --ok-bg: #133524; --warn: #f0b84a; --warn-bg: #3a2c0e;
    --bad: #ff8a80; --bad-bg: #3d1714; --info: #79b4f5; --info-bg: #12263d; --mut-bg: #1d2a25;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 650; }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 15px; }
.brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); margin-bottom: 2px; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; }
.side-foot button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; font: inherit; }
.side-foot button:hover { color: #fff; text-decoration: underline; }
.main { padding: 26px 32px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12.5px; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.nowrap, .nowrap { white-space: nowrap; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.badge-bad { color: var(--bad); background: var(--bad-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-muted { color: var(--muted); background: var(--mut-bg); }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; font-size: 11.5px; color: var(--muted); margin-right: 4px; }

/* forms */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 0 0 5px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.row > .shrink { flex: 0 0 auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; cursor: pointer; font: inherit; }
.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }
.flash-info { background: var(--info-bg); color: var(--info); }
.note { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

/* key box */
.keybox { display: flex; gap: 8px; align-items: center; }
.keybox code { flex: 1; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; white-space: nowrap; }

/* QR */
.qr-box { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.qr-img { width: 260px; height: 260px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; color: #666; font-size: 13px; text-align: center; padding: 10px; }
.qr-img img { width: 100%; height: 100%; }
.steps { margin: 0; padding-left: 18px; color: var(--muted); }
.steps li { margin-bottom: 4px; }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; }
.auth h1 { margin-bottom: 4px; }

pre.code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px 12px; }
  .brand { padding: 4px 10px 4px 4px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 8px; margin: 0; }
  .side-foot { margin: 0 0 0 auto; padding: 4px; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .g21 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
