:root {
  --bg: #0a0e14;
  --panel: #10161f;
  --edge: #1e2a3a;
  --accent: #58a6c8;
  --accent-hot: #7fc4e0;
  --text: #c9d4de;
  --dim: #6b7a89;
  --ok: #6fc98a;
  --err: #d97a6c;
  --side-w: 220px;
  --topbar-h: 52px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  /* Fixed attachment sizes the gradient to the VIEWPORT, so it stretches
     both axes and never tiles — the body itself sizes to its content. */
  background: radial-gradient(ellipse at 50% -20%, #16202e 0%, var(--bg) 60%) fixed no-repeat;
  background-color: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
}

/* ── Shared components ─────────────────────────────────────────────── */
h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-hot);
  margin-bottom: 4px;
}
.sub { color: var(--dim); font-size: 13px; margin-bottom: 24px; }
label {
  display: block;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 16px 0 4px;
}
input {
  width: 100%;
  background: #0c1219;
  border: 1px solid var(--edge);
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}
input:focus { border-color: var(--accent); }
input.center { letter-spacing: 2px; text-transform: uppercase; text-align: center; }
button {
  padding: 11px 18px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-hot);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s;
}
button.block { width: 100%; margin-top: 24px; }
button:hover:not(:disabled) { background: rgba(88, 166, 200, .12); }
button:disabled { opacity: .4; cursor: default; }
button.small { padding: 4px 10px; font-size: 11px; letter-spacing: 1px; }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row .grow { flex: 1; }
.msg { margin-top: 16px; font-size: 14px; min-height: 21px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }
.hidden { display: none; }
.status { font-size: 12px; color: var(--dim); margin-bottom: 18px; }
.status .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim); margin-right: 6px;
}
.status.ok .dot { background: var(--ok); }
.status.err .dot { background: var(--err); }
table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--edge); }
th {
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
}
td.code { font-family: Consolas, monospace; letter-spacing: 1px; white-space: nowrap; }
td .used { color: var(--dim); }
td .free { color: var(--ok); }
.newcode {
  margin-top: 16px; padding: 12px 14px; background: #0c1219;
  border: 1px dashed var(--accent); font-family: Consolas, monospace;
  font-size: 18px; letter-spacing: 2px; text-align: center; cursor: pointer;
}

/* ── Auth layout: one centered panel ───────────────────────────────── */
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.panel {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 2px solid var(--accent);
  padding: 32px 36px 28px;
}

/* ── Dashboard shell: topbar + sidebar + content ───────────────────── */
.shell-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0c1219;
  border-bottom: 1px solid var(--edge);
}
.brand {
  width: var(--side-w);
  flex: none;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-hot);
  text-decoration: none;
  white-space: nowrap;
}

/* The page's identity and controls live in the topbar, aligned with the
   content area (the brand occupies the sidebar's width). */
.topbar-page {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-left: 16px;
  min-width: 0;
  white-space: nowrap;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }
.page-mode { color: var(--dim); font-size: 13px; font-weight: 400; }
.topbar-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  min-width: 0;
}
.topbar-link {
  color: var(--accent-hot);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-link:hover { text-decoration: underline; }

.account { position: relative; margin-right: 16px; flex: none; }
.account summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--edge);
  color: var(--text);
  font-size: 13px;
  user-select: none;
}
.account summary::-webkit-details-marker { display: none; }
.account summary::after { content: " ▾"; color: var(--dim); }
.account[open] summary { border-color: var(--accent); }
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  background: var(--panel);
  border: 1px solid var(--edge);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.account-menu a, .account-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
}
.account-menu a:hover, .account-menu button:hover { background: rgba(88, 166, 200, .1); color: var(--accent-hot); }
.account-menu form { border-top: 1px solid var(--edge); }

.shell-side {
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: #0c1219;
  border-right: 1px solid var(--edge);
  padding-top: 8px;
  overflow-y: auto;
}
.side-section {
  padding: 14px 16px 6px;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.side-nav a {
  display: block;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  border-left: 2px solid transparent;
}
.side-nav a:hover { background: rgba(88, 166, 200, .08); color: var(--accent-hot); }
.side-nav a.active {
  background: rgba(88, 166, 200, .06);
  border-left-color: var(--accent);
  color: var(--accent-hot);
}
.side-foot {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--edge);
  font-size: 12px;
  color: var(--dim);
}
.side-foot strong { color: var(--text); font-weight: 600; }

.shell-main {
  margin: var(--topbar-h) 0 0 var(--side-w);
  padding: 24px 32px;
}
/* Full-viewport apps (logs, editor, RTS): no padding — the app region
   fills the whole content area under the topbar. */
.shell-main.full {
  padding: 0;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
  display: flex;
}
.shell-main.full > * { flex: 1; min-width: 0; }
.page-title {
  font-size: 26px;
  letter-spacing: 1px;
  text-transform: none;
  color: var(--text);
  margin-bottom: 2px;
}
.page-sub { color: var(--dim); font-size: 13px; margin-bottom: 24px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.tile {
  display: block;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-top: 2px solid var(--accent);
  color: var(--accent-hot);
  letter-spacing: 1px;
  text-decoration: none;
}
.tile:hover { border-color: var(--accent); background: rgba(88, 166, 200, .08); }
.tile .desc { display: block; color: var(--dim); font-size: 12px; letter-spacing: 0; margin-top: 4px; }

@media (max-width: 900px) {
  .shell-side { position: static; width: 100%; height: auto; padding-bottom: 8px; }
  .shell-main { margin-left: 0; }
  .side-foot { display: none; }
  body.shell { padding-top: var(--topbar-h); }
}
