:root {
  --bg: #0a0f1c;
  --bg2: #0e1526;
  --card: #131c30;
  --card2: #16203a;
  --line: #243149;
  --text: #e9eef7;
  --muted: #8ca0bf;
  --accent: #22c55e;
  --accent2: #16a34a;
  --accenttext: #04210f;
  --danger: #ef4444;
  --warn: #f59e0b;
  --blue: #3b82f6;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: system-ui, -apple-system, "Segoe UI", Rubik, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(1200px 600px at 85% -10%, #182544 0%, var(--bg) 55%); color: var(--text); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
a { color: var(--accent); }
button { font-family: inherit; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 12px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn:hover { border-color: #38507a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accenttext); border-color: transparent; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: transparent; color: #fda4a4; border-color: #5b2330; }
.btn.danger:hover { background: #2a1620; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }

/* inputs */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
input, select, textarea { width: 100%; background: #0c1324; border: 1px solid var(--line); color: var(--text); border-radius: 11px; padding: 11px 13px; font-size: 15px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login .card { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 20px; }
.brand .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; color: var(--accentext); font-size: 24px; font-weight: 800; }
.brand h1 { font-size: 20px; margin: 0; }

/* layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--bg2), #0a1020); border-inline-end: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side .brand { justify-content: flex-start; margin-bottom: 18px; }
.side .brand h1 { font-size: 17px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: var(--muted); padding: 11px 13px; border-radius: 11px; cursor: pointer; font-size: 14.5px; text-align: start; font-weight: 600; }
.nav button:hover { background: #16203a; color: var(--text); }
.nav button.active { background: rgba(34, 197, 94, .14); color: #a7f3c6; }
.side .spacer { flex: 1; }
.main { padding: 26px 30px; max-width: 1180px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 22px; }
.who { font-size: 13px; color: var(--muted); }

.banner { background: #3b2a08; border: 1px solid #6b4e12; color: #fcd77f; border-radius: 12px; padding: 10px 14px; margin-bottom: 18px; font-size: 13.5px; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat .value.good { color: var(--accent); }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* table */
.tablewrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; background: #0e1626; color: var(--muted); font-weight: 600; padding: 12px 14px; white-space: nowrap; }
td { border-top: 1px solid var(--line); padding: 12px 14px; white-space: nowrap; }
tr:hover td { background: #121c30; }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.pill.succeeded { background: rgba(34,197,94,.16); color: #7ff0a9; }
.pill.pending, .pill.processing { background: rgba(245,158,11,.16); color: #fcd77f; }
.pill.failed, .pill.cancelled, .pill.expired { background: rgba(239,68,68,.16); color: #fca5a5; }
.pill.sbx { background: rgba(59,130,246,.16); color: #93c5fd; }
.pill.on { background: rgba(34,197,94,.16); color: #7ff0a9; }
.pill.off { background: rgba(148,163,184,.16); color: #cbd5e1; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(4,8,16,.66); display: grid; place-items: center; padding: 18px; z-index: 50; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; gap: 10px; margin-top: 8px; }

.toast { position: fixed; inset-block-end: 22px; inset-inline-start: 50%; transform: translateX(-50%); background: #10213a; border: 1px solid var(--line); color: var(--text); padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { border-color: #5b2330; color: #fca5a5; }
.toast.ok { border-color: #1f5137; color: #7ff0a9; }

.linkbox { display: flex; gap: 8px; align-items: center; background: #0c1324; border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px; }
.linkbox input { border: 0; background: transparent; padding: 4px; font-size: 13px; }

/* mobile chrome — hidden on desktop */
.mtop, .mbottom { display: none; }

@media (max-width: 820px) {
  .shell { display: block; }
  .side { display: none; }
  .mtop {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
    padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(10, 15, 28, .82); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .mtop .brand { margin: 0; }
  .mtop .brand h1 { font-size: 17px; }
  .mtop .who { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 16px 14px calc(94px + env(safe-area-inset-bottom)); max-width: 100%; }
  .mbottom {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 40;
    background: rgba(12, 18, 34, .94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .mbottom button {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: transparent; border: 0; color: var(--muted); cursor: pointer;
    padding: 7px 4px; border-radius: 12px; font-size: 11px; font-weight: 600; min-height: 48px;
  }
  .mbottom button .ic { font-size: 20px; line-height: 1; }
  .mbottom button.active { color: var(--accent); }

  .topbar h2 { font-size: 19px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 22px; }
  input, select, textarea { font-size: 16px; } /* keep iOS from zooming */
}

/* data tables become readable stacked cards on phones */
@media (max-width: 680px) {
  .tablewrap { border: 0; overflow: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
  tbody tr:hover td { background: transparent; }
  td { border: 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 14px; white-space: normal; text-align: start; }
  tbody tr td:first-child { border-top: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex: none; }
  td[data-label=""]::before { display: none; }
  td.actions { justify-content: flex-end; gap: 8px; }
  td.actions .btn { flex: 1; }
  td[colspan] { justify-content: center; }
}

/* modal becomes a bottom sheet on small phones */
@media (max-width: 560px) {
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: 20px 20px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal .actions .btn { flex: 1; }
}
