:root {
  --bg: #0b0d11;
  --panel: #12151b;
  --panel-2: #171a21;
  --line: #232833;
  --line-2: #2c323d;
  --text: #e6e8ec;
  --muted: #8a93a3;
  --faint: #5b6372;
  --accent: #E4683F;
  --accent-ink: #1A1411;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2);
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #1e222b; border-color: #363d4a; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #EC8662; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; }
.input {
  height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--bg); outline: none; width: 100%;
}
.input:focus { border-color: var(--accent); }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.running { background: var(--ok); box-shadow: 0 0 0 3px rgb(74 222 128 / .15); }
.dot.starting, .dot.stopping, .dot.creating { background: var(--warn); animation: pulse 1s infinite alternate; }
.dot.error { background: var(--bad); }
@keyframes pulse { to { opacity: .35; } }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); display: grid; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; }
.brand svg { width: 22px; height: 22px; }

/* ---------- dashboard ---------- */
.shell { max-width: 1200px; margin: 0 auto; padding: 22px 20px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.topbar .right { display: flex; gap: 8px; align-items: center; }
.headline { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; gap: 12px; flex-wrap: wrap; }
.headline h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: -.02em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; transition: border-color .15s;
}
.card:hover { border-color: var(--line-2); }
.thumb {
  aspect-ratio: 16 / 10; background: linear-gradient(160deg, #0e1014, #1b1f27); position: relative; cursor: pointer;
  display: grid; place-items: center; color: var(--faint); border-bottom: 1px solid var(--line);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 12px 14px 14px; display: grid; gap: 10px; }
.card .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card .name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; gap: 12px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty {
  border: 1px dashed var(--line-2); border-radius: var(--radius); padding: 48px 20px; text-align: center; color: var(--muted);
  display: grid; gap: 14px; justify-items: center;
}

/* ---------- dialog ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); color: var(--text);
  padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgb(0 0 0 / .5);
}
dialog::backdrop { background: rgb(5 6 8 / .6); backdrop-filter: blur(3px); }
dialog form, dialog .content { padding: 20px; display: grid; gap: 16px; }
dialog h2 { margin: 0; font-size: 16px; font-weight: 600; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; }
pre.snippet {
  margin: 0; padding: 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line);
  overflow: auto; font-family: var(--mono); font-size: 12px; max-height: 260px; white-space: pre;
}

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr; background: #07080b; }
.vbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line);
  background: rgb(18 21 27 / .92); backdrop-filter: blur(10px); min-width: 0; z-index: 3;
}
.vbar .title { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.vbar .title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22ch; }
.vbar .grow { flex: 1; }
.vbar .tools { display: flex; gap: 4px; align-items: center; }
.stage { position: relative; overflow: hidden; display: grid; place-items: center; min-height: 0; }
.stage .fill { position: absolute; inset: 0; }
.clip { position: relative; overflow: hidden; border-radius: 10px; box-shadow: 0 0 0 1px var(--line-2), 0 24px 60px rgb(0 0 0 / .5); }
.overlay-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.apps-menu { position: relative; }
.popover {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 260px; max-width: 360px; max-height: 60vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 6px; z-index: 10;
  box-shadow: 0 20px 50px rgb(0 0 0 / .5);
}
.popover .sec { padding: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.popover button.item {
  display: flex; width: 100%; text-align: left; gap: 8px; align-items: center; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.popover button.item:hover, .popover button.item[aria-current="true"] { background: var(--panel-2); }
.popover .item small { color: var(--faint); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12ch; }

/* browser mode */
.bchrome { position: absolute; inset: 0; display: grid; grid-template-rows: auto auto 1fr; }
.btabs { display: flex; gap: 4px; padding: 8px 10px 0; overflow-x: auto; }
.btab {
  display: flex; align-items: center; gap: 6px; max-width: 200px; height: 30px; padding: 0 10px; border-radius: 8px 8px 0 0;
  background: transparent; border: 1px solid transparent; border-bottom: 0; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.btab span { overflow: hidden; text-overflow: ellipsis; }
.btab[aria-current="true"] { background: var(--panel); border-color: var(--line); color: var(--text); }
.baddr { display: flex; gap: 6px; align-items: center; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); }
.baddr .input { height: 32px; font-size: 13px; }
.bview { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 0; }
.bview canvas { max-width: 100%; max-height: 100%; background: #fff; outline: none; cursor: default; box-shadow: 0 0 0 1px var(--line-2); }

/* side panel */
.side {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel);
  border-left: 1px solid var(--line); z-index: 5; display: grid; grid-template-rows: auto 1fr; box-shadow: -20px 0 60px rgb(0 0 0 / .4);
}
.side header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.side .scroll { overflow: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.cred { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.cred .who { min-width: 0; flex: 1; }
.cred .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--panel-2); border: 1px solid var(--line-2); padding: 9px 14px; border-radius: 10px; z-index: 100;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { border-color: rgb(248 113 113 / .5); }

@media (max-width: 640px) {
  .vbar { flex-wrap: wrap; }
  .vbar .title span { max-width: 14ch; }
  .hide-sm { display: none !important; }
}

/* ================= accounts & billing ================= */
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.btn.block { width: 100%; justify-content: center; height: 40px; }
.stack { display: grid; gap: 14px; align-content: start; }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* auth */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-pitch {
  padding: 36px 44px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  background:
    radial-gradient(900px 500px at 10% 0%, rgb(228 104 63 / .14), transparent 60%),
    radial-gradient(600px 400px at 90% 100%, rgb(74 222 128 / .06), transparent 60%),
    var(--panel);
  border-right: 1px solid var(--line);
}
.pitch-body { max-width: 460px; }
.pitch-body h2 { font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -.035em; margin: 0 0 16px; font-weight: 600; }
.pitch-body > p { font-size: 15px; margin: 0 0 28px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.features li { display: flex; gap: 12px; align-items: flex-start; }
.features strong { font-weight: 600; }
.features .muted { font-size: 13px; }
.feat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgb(228 104 63 / .12); color: var(--accent); flex: none; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-form { width: min(360px, 100%); display: grid; gap: 16px; }
.auth-title { font-size: 22px; margin: 0; font-weight: 600; letter-spacing: -.02em; }
.auth-form .input { height: 40px; }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-pitch { border-right: 0; border-bottom: 1px solid var(--line); padding: 24px 16px; gap: 20px; }
  .pitch-body h2 { font-size: 28px; }
  .features { display: none; }
  .pitch-body > p { margin: 0; }
}

/* app bar */
.appbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: rgb(11 13 17 / .85); backdrop-filter: blur(10px); }
.appbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; }
.appbar .brand { text-decoration: none; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 11px; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link[aria-current="page"] { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.appbar-right { display: flex; gap: 6px; align-items: center; }
.balance-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--line-2); background: var(--panel); font-variant-numeric: tabular-nums; font-weight: 500;
}
.balance-chip .icon { color: var(--ok); }
.balance-chip.low .icon { color: var(--warn); }
.balance-chip.empty { border-color: rgb(248 113 113 / .45); }
.balance-chip.empty .icon { color: var(--bad); }
.shell { padding-top: 26px; }
@media (max-width: 640px) {
  .appbar-inner { gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
  .appbar .brand span { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .nav-link span { display: inline; }
  .appbar-right { margin-left: auto; }
}

.headline > div { display: grid; gap: 2px; }

/* banners */
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); margin-bottom: 16px; flex-wrap: wrap; }
.banner > span { flex: 1; min-width: 200px; }
.banner.bad { border-color: rgb(248 113 113 / .35); background: rgb(248 113 113 / .07); }
.banner.bad > .icon { color: var(--bad); }
.banner.warn { border-color: rgb(251 191 36 / .35); background: rgb(251 191 36 / .07); }
.banner.warn > .icon { color: var(--warn); }
.banner.ok { border-color: rgb(74 222 128 / .3); background: rgb(74 222 128 / .06); display: grid; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.billing-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.billing-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 860px) { .billing-grid { grid-template-columns: 1fr; } }

.hero { background: radial-gradient(700px 260px at 0% 0%, rgb(228 104 63 / .12), transparent 70%), var(--panel); }
.hero-label { color: var(--muted); font-size: 13px; }
.hero-amount { font-size: clamp(34px, 6vw, 48px); font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: 2px 0 18px; }
.hero-amount.bad { color: var(--bad); }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
@media (max-width: 520px) { .hero-stats { grid-template-columns: 1fr; } }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0; }

.amounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.amount { height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.amount:hover { border-color: #3a4150; }
.amount[aria-pressed="true"] { border-color: var(--accent); background: rgb(228 104 63 / .1); color: var(--text); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; color: var(--faint); font-size: 12px; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .pos { color: var(--ok); }
.table .neg { color: var(--bad); }
.kind { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); white-space: nowrap; }
.kind.topup, .kind.signup { color: var(--ok); border-color: rgb(74 222 128 / .25); }
.kind.grant { color: var(--accent); border-color: rgb(228 104 63 / .3); }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 200px; }
.estimate { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.estimate:empty { display: none; }
.faint.mono { font-size: 11.5px; }

/* brand lockup (outlined SVG) */
.brand .lockup { height: 22px; width: auto; display: block; }
.brand.small .lockup { height: 18px; }
.lnav .brand .lockup { height: 24px; }

/* single-column auth pages (forgot / reset / verify) */
.auth-single { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; justify-items: center; padding: 32px 16px; }
.auth-single .auth-form { width: min(380px, calc(100vw - 32px)); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.link.small { font-size: 12.5px; }

.btn.danger-solid { background: var(--bad); color: #1a0d0d; border-color: transparent; font-weight: 600; }
.btn.danger-solid:hover { background: #fb8a8a; }
.btn.danger-solid:disabled { opacity: .45; }

/* automations panel */
.side.side-wide { width: min(460px, 100%); }
.auto-body { display: grid; grid-template-rows: auto 1fr; min-height: 0; overflow: hidden; }
.auto-tabs { width: 100%; }
.auto-tabs button { flex: 1; }
.side .intro { margin: 0; font-size: 13px; }
.auto-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; background: var(--bg); }
.auto-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.auto-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.auto-name strong { font-weight: 600; }
.cron { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); color: #e8dcd3; }
.auto-action { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12px; color: var(--faint); }
.auto-form { border-top: 1px solid var(--line); padding-top: 16px; gap: 12px; }
.form-title { font-weight: 600; }
.ta { height: auto; padding: 8px 12px; resize: vertical; font-size: 12.5px; line-height: 1.5; }
select.input { appearance: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { margin: 0; font-size: 12px; color: var(--faint); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip:hover { color: var(--text); border-color: #3a4150; }
.pill-status { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.pill-status.ok { color: var(--ok); border-color: rgb(74 222 128 / .35); }
.pill-status.error { color: var(--bad); border-color: rgb(248 113 113 / .4); }
.pill-status.running { color: var(--warn); border-color: rgb(251 191 36 / .4); }
.switch { position: relative; width: 34px; height: 20px; flex: none; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); }
.run { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.run summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; font-size: 13px; }
.run summary::-webkit-details-marker { display: none; }
.run-src { color: var(--text); text-transform: capitalize; }
.run-dur { margin-left: auto; }
.run-out { margin: 0 10px 10px; max-height: 240px; }
.reveal pre { white-space: pre-wrap; word-break: break-all; }
