:root {
  --ink: #142033;
  --muted: #68778a;
  --line: #e0e7f0;
  --paper: #ffffff;
  --bg: #f7f9fc;
  --soft: #eef5ff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #06b6d4;
  --ok: #16885a;
  --warn: #a86900;
  --bad: #b3261e;
  --shadow: 0 24px 70px rgba(20, 32, 51, .10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, textarea { font: inherit; }

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  min-height: 46px;
  font-weight: 700;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, .36);
  box-shadow: 0 10px 22px rgba(20, 32, 51, .08);
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(37, 99, 235, .24);
}

button.danger {
  background: #fff4f3;
  border-color: rgba(179, 38, 30, .28);
  color: var(--bad);
}

button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

button.link-btn {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #93c5fd;
  box-shadow: none;
  font-weight: 800;
  text-align: left;
}

button.link-btn:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  color: #bfdbfe;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: #fbfdff;
  color: var(--ink);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus, textarea:focus {
  border-color: rgba(20, 119, 212, .75);
  box-shadow: 0 0 0 3px rgba(20, 119, 212, .12);
}

label {
  display: grid;
  gap: 7px;
  color: #27384a;
  font-size: 14px;
  font-weight: 650;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, .70);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.user-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(37, 99, 235, .16), transparent 330px),
    radial-gradient(circle at 82% 8%, rgba(6, 182, 212, .14), transparent 320px),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 420px),
    var(--bg);
}

.activation-page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.hero-band {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 18px;
  padding: 18px 0 26px;
}

.hero-band h1 {
  margin: 0;
  font-size: 48px;
  line-height: 1.05;
  letter-spacing: 0;
}

.lede {
  max-width: 720px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
  margin: 14px auto 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.status-strip span {
  background: rgba(255, 255, 255, .78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 700;
  color: #334155;
  box-shadow: 0 8px 24px rgba(20, 32, 51, .06);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(380px, 450px) 1fr;
  gap: 20px;
  align-items: start;
}

.left-stack {
  display: grid;
  gap: 18px;
}

.service-banner {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 14px 32px rgba(20, 32, 51, .08);
  font-weight: 800;
  line-height: 1.5;
}

.service-banner.ok {
  color: var(--ok);
  border-color: rgba(22, 136, 90, .24);
  background: #f1fbf6;
}

.service-banner.bad {
  color: var(--bad);
  border-color: rgba(179, 38, 30, .24);
  background: #fff4f3;
}

.activation-form, .progress-panel, .query-panel, .notice-band, .panel, .stats-grid > div {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.activation-form, .query-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.panel-heading h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}

.panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel-heading span {
  white-space: nowrap;
  border: 1px solid rgba(37, 99, 235, .18);
  background: var(--soft);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.panel-heading.compact h2 {
  font-size: 20px;
}

.hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.linked-email {
  margin-top: -6px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  border: 1px solid rgba(22, 136, 90, .22);
  border-radius: 999px;
  padding: 7px 11px;
  background: #f1fbf6;
  color: var(--ok);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.linked-email.bad {
  border-color: rgba(168, 105, 0, .24);
  background: #fff8e8;
  color: var(--warn);
}

.token-guide {
  display: grid;
  gap: 4px;
  border: 1px solid #d9e6f7;
  border-radius: 14px;
  padding: 13px 14px;
  background: linear-gradient(180deg, #f8fbff, #f2f7ff);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.token-guide b {
  color: #20334d;
}

.token-guide a {
  color: var(--primary-dark);
  font-weight: 750;
  text-decoration: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.query-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}

.inline-check {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 10px;
  align-items: center;
}

.inline-check span {
  color: var(--muted);
  font-weight: 700;
}

.inline-check span.ok { color: var(--ok); }
.inline-check span.bad { color: var(--bad); }

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.feature-row span {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  background: #fbfdff;
}

.feature-row b {
  display: block;
  color: var(--primary-dark);
  font-size: 15px;
  margin-bottom: 2px;
}

.progress-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.progress-head {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
}

.task-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.ring {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  font-weight: 800;
  background: conic-gradient(var(--primary) 0deg, #e8eef7 0deg);
  border: 8px solid #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 14px 26px rgba(37, 99, 235, .14);
}

.steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.steps li {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 8px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  min-height: 42px;
  background: #fbfdff;
}

.steps li.active {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: #eef7ff;
}

.steps li.done {
  color: var(--ok);
  border-color: rgba(22, 136, 90, .35);
  background: #edf9f3;
}

.steps li.bad {
  color: var(--bad);
  border-color: rgba(179, 38, 30, .35);
  background: #fff1f0;
}

.log-box {
  height: 314px;
  overflow: auto;
  background: linear-gradient(180deg, #101827, #0d1420);
  color: #dbeafe;
  border-radius: 16px;
  padding: 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.log-line {
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.log-line.ok { color: #88e1b1; }
.log-line.warn { color: #ffd27a; }
.log-line.fail, .log-line.error { color: #ff9c95; }

.ops-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, #fbfdff, #f3f8ff);
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.ops-grid div {
  border: 1px solid #dbe8f7;
  border-radius: 14px;
  padding: 13px 12px;
  background: #fff;
}

.ops-grid b {
  display: block;
  color: #142033;
  font-size: 24px;
  line-height: 1.1;
}

.ops-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.runtime-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.runtime-row b {
  color: var(--primary-dark);
  font-weight: 850;
}

.message {
  min-height: 22px;
  color: var(--muted);
  line-height: 1.5;
}

.message.ok { color: var(--ok); }
.message.bad { color: var(--bad); }

.notice-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
  padding: 22px 24px;
}

.notice-band h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.notice-band p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.admin-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.monitor-shell {
  color: #dbeafe;
  background:
    radial-gradient(circle at 16% 8%, rgba(37, 99, 235, .28), transparent 360px),
    radial-gradient(circle at 82% 0%, rgba(6, 182, 212, .18), transparent 340px),
    linear-gradient(135deg, #07111f 0%, #0d1628 46%, #101827 100%);
}

.admin-login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 18%, rgba(37, 99, 235, .34), transparent 360px),
    radial-gradient(circle at 78% 0%, rgba(6, 182, 212, .20), transparent 340px),
    rgba(7, 17, 31, .96);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 24px;
  padding: 28px;
  background: rgba(15, 23, 42, .88);
  color: #dbeafe;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .35);
}

.login-card h1 {
  margin: 0;
  color: #f8fbff;
  font-size: 34px;
}

.login-card p:not(.eyebrow) {
  margin: -8px 0 0;
  color: #93a4ba;
}

.login-card label {
  color: #cbdaf0;
}

.login-card input {
  background: rgba(7, 17, 31, .72);
  border-color: rgba(148, 163, 184, .26);
  color: #eef6ff;
}

.monitor-shell > .monitor-nav,
.monitor-shell > .monitor-page {
  visibility: hidden;
}

.monitor-shell.admin-authed > .admin-login {
  display: none;
}

.monitor-shell.admin-authed > .monitor-nav,
.monitor-shell.admin-authed > .monitor-page {
  visibility: visible;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 22px;
  background: #102033;
  color: #fff;
}

.monitor-nav {
  background: rgba(7, 17, 31, .82);
  border-right: 1px solid rgba(148, 163, 184, .18);
  box-shadow: 16px 0 40px rgba(0, 0, 0, .20);
}

.monitor-nav strong {
  font-size: 18px;
  letter-spacing: 0;
}

.monitor-nav a, .monitor-nav button {
  border-radius: 12px;
  background: rgba(15, 23, 42, .78);
}

.nav-status {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 16px;
  padding: 14px;
  background: rgba(15, 23, 42, .72);
}

.nav-status span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 18px rgba(179, 38, 30, .7);
}

.nav-status span.on {
  background: #22c55e;
  box-shadow: 0 0 18px rgba(34, 197, 94, .78);
}

.nav-status span.off {
  background: #ef4444;
}

.nav-status b {
  color: #e5f0ff;
}

.nav-status small {
  color: #93a4ba;
  line-height: 1.5;
}

.side-nav a, .side-nav button {
  color: #fff;
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .08);
  text-decoration: none;
  border-radius: 6px;
  padding: 10px 12px;
}

.admin-page {
  padding: 28px;
  display: grid;
  gap: 18px;
}

.monitor-page {
  gap: 22px;
  padding: 30px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.monitor-header {
  align-items: center;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 22px;
  padding: 22px;
  background: rgba(15, 23, 42, .62);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .22);
}

.monitor-header .eyebrow {
  background: rgba(37, 99, 235, .14);
  border-color: rgba(96, 165, 250, .26);
  color: #93c5fd;
}

.monitor-header h1 {
  color: #f8fbff;
}

.monitor-header p:not(.eyebrow) {
  margin: 8px 0 0;
  color: #93a4ba;
}

.security-warn {
  color: #fbbf24 !important;
  font-weight: 850;
}

.monitor-header .admin-key {
  color: #dbeafe;
}

.admin-session {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.admin-session span {
  color: #93a4ba;
  font-weight: 800;
}

.admin-session input {
  display: none;
}

.monitor-header input,
.monitor-panel input,
.monitor-panel textarea {
  background: rgba(15, 23, 42, .74);
  border-color: rgba(148, 163, 184, .24);
  color: #eef6ff;
}

.monitor-header input::placeholder,
.monitor-panel input::placeholder {
  color: #71839a;
}

.monitor-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.monitor-metrics > div,
.monitor-cards > div {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 20px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(15, 23, 42, .86), rgba(15, 23, 42, .58));
  box-shadow: 0 18px 54px rgba(0, 0, 0, .20);
}

.monitor-metrics > div::after,
.monitor-cards > div::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(37, 99, 235, .22);
}

.monitor-metrics span,
.monitor-cards span {
  color: #93a4ba;
  font-weight: 800;
}

.monitor-metrics b,
.monitor-cards b {
  display: block;
  margin: 8px 0 4px;
  color: #f8fbff;
  font-size: 34px;
  line-height: 1;
}

.monitor-metrics small {
  color: #64748b;
  font-weight: 700;
}

.monitor-cards {
  grid-template-columns: repeat(5, 1fr);
}

.monitor-config-grid {
  grid-template-columns: 1.1fr .9fr;
}

.live-log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.monitor-panel,
.monitor-table-panel,
.live-log-panel {
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .72);
  color: #dbeafe;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .18);
}

.monitor-panel h2,
.monitor-table-panel h2,
.live-log-panel h2 {
  color: #f8fbff;
}

.live-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.live-log-head h2 {
  margin: 0;
  font-size: 20px;
}

.live-log-head p {
  margin: 6px 0 0;
  color: #93a4ba;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.live-log-head span {
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(148, 163, 184, .10);
  color: #dbeafe;
  font-size: 12px;
  font-weight: 900;
}

.live-log-head span.ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, .32);
  background: rgba(34, 197, 94, .12);
}

.live-log-head span.bad {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, .34);
  background: rgba(239, 68, 68, .12);
}

.admin-log-box {
  height: 340px;
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 16px;
  background: rgba(2, 6, 23, .55);
  padding: 10px;
  font-family: Consolas, "SFMono-Regular", monospace;
}

.admin-log-line {
  display: grid;
  grid-template-columns: 72px 44px minmax(120px, .75fr) minmax(0, 1.4fr);
  gap: 8px;
  align-items: start;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
  padding: 7px 4px;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.45;
}

.admin-log-line:last-child {
  border-bottom: 0;
}

.admin-log-line span {
  color: #94a3b8;
}

.admin-log-line b {
  color: #93c5fd;
}

.admin-log-line em {
  color: #f8fbff;
  font-style: normal;
  overflow-wrap: anywhere;
}

.admin-log-line p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.admin-log-line.ok b {
  color: #86efac;
}

.admin-log-line.warn b {
  color: #facc15;
}

.admin-log-line.bad b {
  color: #fca5a5;
}

.admin-log-line.muted {
  display: block;
  color: #64748b;
}

.monitor-panel label {
  color: #cbdaf0;
}

.monitor-panel .message {
  color: #93a4ba;
}

.monitor-panel .message.ok {
  color: #86efac;
}

.monitor-panel .message.bad {
  color: #fca5a5;
}

.table-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.table-title span {
  color: #93a4ba;
  font-weight: 800;
}

.table-search {
  width: min(340px, 100%);
  color: #93a4ba;
  font-size: 12px;
}

.table-search input {
  margin-top: 6px;
  background: rgba(15, 23, 42, .74);
  border-color: rgba(148, 163, 184, .24);
  color: #eef6ff;
}

.table-scroll {
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, .14);
  border-radius: 16px;
}

.monitor-table-panel table {
  min-width: 880px;
  color: #dbeafe;
}

.monitor-table-panel th {
  color: #93c5fd;
  background: rgba(15, 23, 42, .88);
  border-bottom-color: rgba(148, 163, 184, .18);
}

.monitor-table-panel td {
  border-bottom-color: rgba(148, 163, 184, .12);
}

.monitor-table-panel tr:hover td {
  background: rgba(37, 99, 235, .08);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(148, 163, 184, .10);
  color: #dbeafe;
  font-weight: 800;
}

.status-pill.ok {
  color: #86efac;
  border-color: rgba(34, 197, 94, .32);
  background: rgba(34, 197, 94, .12);
}

.status-pill.bad {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, .34);
  background: rgba(239, 68, 68, .12);
}

.admin-header h1 {
  margin: 0;
  font-size: 34px;
}

.admin-key {
  width: min(320px, 100%);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.stats-grid > div {
  padding: 18px;
}

.stats-grid b {
  display: block;
  font-size: 30px;
  margin-bottom: 4px;
}

.stats-grid span {
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 18px;
}

.panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 20px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .hero-band, .workbench, .admin-shell, .admin-grid, .stats-grid, .monitor-metrics, .notice-band, .live-log-grid {
    grid-template-columns: 1fr;
  }
  .side-nav {
    position: static;
    height: auto;
  }
  .hero-band h1 {
    font-size: 38px;
  }
}

@media (max-width: 640px) {
  .activation-page {
    width: min(100% - 20px, 1160px);
    padding: 18px 0;
  }
  .hero-band {
    min-height: auto;
  }
  .progress-head, .inline-check, .actions.two, .query-actions, .feature-row {
    grid-template-columns: 1fr;
  }
  .ops-grid {
    grid-template-columns: 1fr 1fr;
  }
  .runtime-row {
    display: grid;
  }
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
}
