:root {
  color-scheme: light;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

body[data-theme="dark"] {
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #e6edf7;
  --muted: rgba(230, 237, 247, 0.78);
  --faint: rgba(230, 237, 247, 0.55);
  --accent: #79b8ff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;
  --button-bg: rgba(255, 255, 255, 0.08);
  --button-hover-bg: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(0, 0, 0, 0.18);
  --table-head-bg: rgba(255, 255, 255, 0.05);
  --table-row-hover-bg: rgba(255, 255, 255, 0.03);
  --modal-bg: rgba(7, 16, 40, 0.96);
  --toast-bg: rgba(7, 16, 40, 0.92);
  --primary-border: rgba(58, 160, 255, 0.45);
  --primary-bg: rgba(58, 160, 255, 0.18);
  --primary-hover-bg: rgba(58, 160, 255, 0.24);
  --divider: rgba(255, 255, 255, 0.10);
  --pill-border: rgba(255, 255, 255, 0.14);
  --pill-bg: rgba(255, 255, 255, 0.05);
  --pill-dot: rgba(255, 255, 255, 0.28);
  --page-bg:
    radial-gradient(900px 600px at 15% -10%, rgba(58, 160, 255, 0.26), transparent 60%),
    radial-gradient(800px 520px at 90% 10%, rgba(121, 184, 255, 0.16), transparent 55%),
    linear-gradient(180deg, #071028 0%, #0b1220 60%);
  --topbar-bg: rgba(7, 16, 40, 0.74);
  --topbar-border: rgba(255, 255, 255, 0.08);
  --code-bg: rgba(255, 255, 255, 0.09);
}

body[data-theme="cream"] {
  --card: rgba(255, 255, 255, 0.86);
  --card-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(18, 19, 23, 0.12);
  --border-strong: rgba(18, 19, 23, 0.18);
  --text: #14151a;
  --muted: rgba(20, 21, 26, 0.74);
  --faint: rgba(20, 21, 26, 0.52);
  --accent: #0f62fe;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #e11d48;
  --button-bg: rgba(20, 21, 26, 0.04);
  --button-hover-bg: rgba(20, 21, 26, 0.06);
  --input-bg: rgba(255, 255, 255, 0.92);
  --table-head-bg: rgba(20, 21, 26, 0.03);
  --table-row-hover-bg: rgba(20, 21, 26, 0.03);
  --modal-bg: rgba(255, 255, 255, 0.96);
  --toast-bg: rgba(255, 255, 255, 0.92);
  --primary-border: rgba(15, 98, 254, 0.36);
  --primary-bg: rgba(15, 98, 254, 0.11);
  --primary-hover-bg: rgba(15, 98, 254, 0.15);
  --divider: rgba(20, 21, 26, 0.10);
  --pill-border: rgba(20, 21, 26, 0.14);
  --pill-bg: rgba(20, 21, 26, 0.04);
  --pill-dot: rgba(20, 21, 26, 0.32);
  --page-bg:
    radial-gradient(900px 620px at 18% -10%, rgba(15, 98, 254, 0.10), transparent 62%),
    radial-gradient(900px 640px at 100% 0%, rgba(236, 72, 153, 0.06), transparent 56%),
    linear-gradient(180deg, #fbf6ee 0%, #f7f1e8 60%, #f2ebe2 100%);
  --topbar-bg: rgba(251, 246, 238, 0.78);
  --topbar-border: rgba(20, 21, 26, 0.10);
  --code-bg: rgba(20, 21, 26, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
}

code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand__mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(58, 160, 255, 0.85), rgba(121, 184, 255, 0.35));
  box-shadow: 0 14px 34px rgba(58, 160, 255, 0.24);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #041025;
}

.brand__name {
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand__meta {
  font-size: 13px;
  color: var(--faint);
  margin-top: 2px;
}

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

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 26px 18px 42px;
}

.hero {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: -30px -30px auto auto;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle at 30% 30%, rgba(121, 184, 255, 0.24), transparent 65%);
  transform: rotate(12deg);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 10px 0;
  line-height: 1.55;
  color: var(--muted);
  max-width: 64ch;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.card {
  grid-column: span 6;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.26);
}

.card--full {
  grid-column: span 12;
}

.card h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.card__sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.row--tight {
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--pill-border);
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 13px;
}

.pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--pill-dot);
}

.pill--ok .pill__dot {
  background: var(--ok);
}

.pill--warn .pill__dot {
  background: var(--warn);
}

.pill--bad .pill__dot {
  background: var(--bad);
}

button {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--button-bg);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 540;
  cursor: pointer;
}

button:hover {
  background: var(--button-hover-bg);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  border-color: var(--primary-border);
  background: var(--primary-bg);
}

.primary:hover {
  background: var(--primary-hover-bg);
}

input,
select,
textarea {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  min-height: 40px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(230, 237, 247, 0.5);
}

.table-wrap {
  margin-top: 12px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

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

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

th {
  text-align: left;
  color: var(--muted);
  font-weight: 650;
  background: var(--table-head-bg);
  position: sticky;
  top: 0;
}

tr:hover td {
  background: var(--table-row-hover-bg);
}

.muted {
  color: var(--muted);
}

.faint {
  color: var(--faint);
}

.footer {
  padding: 26px 18px 40px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--pill-border);
  background: var(--toast-bg);
  box-shadow: var(--shadow);
  display: none;
}

.toast--show {
  display: block;
}

.toast__title {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.toast__body {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
}

.modal--show {
  display: block;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal__panel {
  position: relative;
  width: min(960px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  margin: 14px auto;
  border-radius: 18px;
  border: 1px solid var(--pill-border);
  background: var(--modal-bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--divider);
}

.modal__title {
  font-weight: 650;
}

.modal pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  flex: 1;
  color: var(--text);
}

@media (max-width: 960px) {
  .card {
    grid-column: span 12;
  }

  .topbar__inner {
    align-items: flex-start;
  }

  .brand {
    min-width: auto;
  }
}

.admin-only {
  display: none;
}

body[data-role="admin"] .admin-only {
  display: block;
}

.segmented {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--pill-bg);
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 9px 11px;
  font-weight: 620;
  font-size: 13px;
  color: var(--muted);
}

.segmented button + button {
  border-left: 1px solid var(--divider);
}

.segmented button:hover {
  background: var(--button-hover-bg);
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--primary-bg);
  color: var(--text);
}
