:root {
  --bg: #f4f6fa; --card: #fff; --text: #142033; --muted: #64748b; --line: #e3e8f0;
  --side: #0b1324; --side-text: #c7d2e5; --accent: #2563eb; --accent-soft: #e8efff;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --gray: #94a3b8; --violet: #7c3aed;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.side { width: 220px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.side[hidden] { display: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; color: #fff; }
.brand small { display: block; color: var(--side-text); font-size: 12px; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #3b82f6, #7c3aed); }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { color: var(--side-text); padding: 8px 10px; border-radius: 8px; }
.side nav a:hover { background: #16213a; }
.side nav a.active { background: #1e2c4d; color: #fff; font-weight: 600; }
.me { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; padding: 8px; border-top: 1px solid #1e2a44; }
.link { background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; font: inherit; padding: 0; }

main { flex: 1; padding: 26px 30px 60px; min-width: 0; max-width: 1280px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stack > * + * { margin-top: 16px; }
.kpi .n { font-size: clamp(19px, 2vw, 26px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.hl { background: linear-gradient(135deg, #1d4ed8, #6d28d9); color: #fff; border: 0; }
.kpi.hl .l { color: #dbe4ff; }
.empty { color: var(--muted); text-align: center; padding: 26px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafd; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-active { background: #dcfce7; color: #166534; }
.st-due { background: #fef3c7; color: #92400e; }
.st-grace { background: #ffedd5; color: #9a3412; }
.st-expired, .st-cancelled { background: #fee2e2; color: #991b1b; }
.st-unpaid { background: #e0e7ff; color: #3730a3; }
.st-suspended { background: #f1f5f9; color: #475569; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 13px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: #c5cede; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

form label { display: block; margin-bottom: 12px; }
form label > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #cfd8e6; border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
.err { background: #fee2e2; color: #991b1b; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.note { background: var(--accent-soft); color: #1e3a8a; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.key { font-family: ui-monospace, Menlo, monospace; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.price-box { background: #f8fafd; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.price-box .big { font-size: 22px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 3px 4px 3px 12px; background: #fff; font-size: 13px; }
.chip button { border: 0; background: #f1f5f9; border-radius: 99px; width: 22px; height: 22px; cursor: pointer; color: var(--muted); }
.pubkey { word-break: break-all; background: #0b1324; color: #c7d2e5; padding: 12px; border-radius: 8px; max-height: 120px; overflow: auto; }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 120px; margin-top: 6px; }
.bars div { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars-l { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; }

.auth { margin: auto; width: 100%; max-width: 380px; padding: 20px; }
.auth .card { padding: 26px; }
.auth .brand { color: var(--text); padding: 0 0 18px; }
.auth .brand small { color: var(--muted); }

#modal .bg { position: fixed; inset: 0; background: rgba(11, 19, 36, .45); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow: auto; }
#modal .box { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 520px; }
#modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #0b1324; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; max-width: 360px; }
.toast.bad { background: var(--bad); }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: auto; height: auto; position: static; padding: 12px; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .brand { padding-bottom: 10px; }
  main { padding: 18px 16px 40px; }
  .grid.two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  .hide-sm { display: none; }
}
.narrow { max-width: 110px; }
