:root {
  --bg: #eef1f4; --panel: #ffffff; --ink: #1b2330; --muted: #5f6b7a; --line: #d9dee5;
  --brand: #0f5e78; --brand-ink: #ffffff; --brand-soft: #e1eef3;
  --ok: #1f8a5b; --ok-soft: #e3f3eb; --wait: #b7800f; --wait-soft: #fbf1dc; --off: #9aa3ae;
  --danger: #b3261e; --danger-soft: #fbe6e4;
  --radius-lg: 14px; --radius-sm: 8px;
  --sans: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171e; --panel: #1a212b; --ink: #e6ebf1; --muted: #93a0b1; --line: #2b3542;
    --brand: #3aa7c9; --brand-ink: #0b1a21; --brand-soft: #173340;
    --ok: #3cc488; --ok-soft: #173427; --wait: #e2b04a; --wait-soft: #3a2f16; --off: #6b7684;
    --danger: #f07167; --danger-soft: #3d1f1d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
h1, h2, h3 { letter-spacing: -0.02em; }

label { display: block; font-weight: 500; font-size: 14px; margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
input[type=text], input[type=password], input[type=url], input[type=tel], input[type=email], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
textarea { resize: vertical; min-height: 72px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; text-decoration: none; display: inline-block; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Tela de entrada */
.gate { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.gate .box { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px; }
.gate h1 { font-size: 26px; margin: 0 0 4px; }
.gate p.lead { margin: 0 0 22px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; margin-bottom: 22px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 7px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button[aria-selected=true] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Escolha de plano */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 520px) { .plans { grid-template-columns: 1fr; } }
.plan-opt { position: relative; }
.plan-opt input { position: absolute; opacity: 0; }
.plan-opt > span { display: block; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; font-weight: 400; }
.plan-opt b { display: block; font-size: 15px; }
.plan-opt .n { font-size: 26px; border: 0; padding: 0; font-weight: 700; line-height: 1.1; display: block; margin: 6px 0 0; }
.plan-opt .p { display: block; font-size: 13px; color: var(--muted); }
.plan-opt input:checked + span { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.plan-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Layout do app */
.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100%; background: linear-gradient(90deg, var(--panel) 0 279px, var(--line) 279px 280px, var(--bg) 280px); }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
aside { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; max-height: 100vh; }
.brand { padding: 20px 20px 4px; }
.brand strong { font-size: 17px; display: block; }
.brand small { color: var(--muted); font-size: 13px; }
nav.menu { padding: 12px 8px; display: grid; gap: 2px; }
nav.menu button { text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; color: var(--muted); }
nav.menu button:hover { background: var(--bg); color: var(--ink); }
nav.menu button[aria-current=true] { background: var(--bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--brand); }
.aside-foot { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--line); font-size: 14px; }
.aside-foot button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
main { padding: 28px clamp(16px, 4vw, 44px) 60px; max-width: 1120px; width: 100%; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  aside { position: static; min-height: 0; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  nav.menu { grid-auto-flow: column; overflow-x: auto; }
}

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h2 { font-size: 30px; margin: 0; line-height: 1.1; }
.page-head .sub { margin-top: 6px; color: var(--muted); }

.banner { border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 22px; display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.banner.info { background: var(--brand-soft); }
.banner.warn { background: var(--wait-soft); }
.banner.bad { background: var(--danger-soft); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
section.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
section.card h3 { margin: 0 0 14px; font-size: 16px; }

.meter { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter.full i { background: var(--wait); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.dot.open { background: var(--ok); }
.dot.connecting { background: var(--wait); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.connecting { animation: none; } }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 500; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.trial { background: var(--brand-soft); color: var(--brand); }
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.past_due { background: var(--wait-soft); color: var(--wait); }
.pill.suspended, .pill.blocked { background: var(--danger-soft); color: var(--danger); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--bg); }
.scroll-x { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.token { display: flex; gap: 8px; align-items: center; }
.token code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--bg); padding: 9px 12px; border-radius: var(--radius-sm); font-family: var(--mono); font-size: 13px; }
pre.code { background: var(--bg); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; margin: 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 50; }
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

.empty { color: var(--muted); padding: 28px 0; }
