:root {
  --bg: #0e0f13;
  --surface: #16181f;
  --surface-2: #1c1f28;
  --line: #272b36;
  --text: #e8eaf0;
  --muted: #8b91a3;
  --accent: #6d5efc;
  --accent-hover: #7f72ff;
  --success: #2fbf71;
  --danger: #e05260;
  --warn: #e0a63a;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
code, pre, .copyable { font-family: var(--mono); }

/* ---------- chrome ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #b06bff);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.brand-mark.lg { width: 46px; height: 46px; font-size: 22px; border-radius: 12px; }

.topnav { display: flex; align-items: center; gap: 16px; }
.topnav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.topnav a:hover { color: var(--text); }
.topnav .who { color: var(--muted); font-size: 13px; padding-right: 4px; border-right: 1px solid var(--line); padding-left: 4px; }

.shell { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 6px; opacity: 0.5; }

.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 12.5px; }
.strong { font-weight: 600; text-decoration: none; }
.strong:hover { color: var(--accent-hover); }
.right { text-align: right; }
.link { color: var(--accent-hover); text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }
.is-hidden { display: none; }
.inline { display: inline; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title { font-size: 14px; font-weight: 650; letter-spacing: 0.01em; }
.panel { border-color: #33384a; }
.empty { text-align: center; padding: 48px 18px; }
.empty h2 { font-size: 17px; margin-bottom: 6px; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.col-side .sticky { position: sticky; top: 84px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col-side .sticky { position: static; }
}

/* ---------- forms ---------- */

.row-form { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
/* Only fields inside a horizontal row share the width; stacked fields keep their height. */
.row-form > .field { flex: 1 1 240px; }
.row-form > .field-sm { flex: 0 1 200px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[name$="_id"], .copyable { font-family: var(--mono); font-size: 13px; }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.18);
}

input[readonly] { color: var(--muted); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.hint { font-size: 11.5px; color: var(--muted); font-style: normal; line-height: 1.4; }
.err { font-size: 12px; color: var(--danger); font-style: normal; }

.row-actions { display: flex; gap: 8px; align-items: flex-end; flex: 0 0 auto; }
.formbar { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 4px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #3b4256; }

.btn-danger { background: transparent; border-color: #47242b; color: var(--danger); }
.btn-danger:hover { background: rgba(224, 82, 96, 0.12); }

/* ---------- table ---------- */

.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table code { font-size: 12.5px; color: var(--muted); }
.table .btn { margin-left: 6px; }

.pill {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill-max { color: #9d8bff; border-color: #37307a; background: rgba(109, 94, 252, 0.12); }
.pill-admob { color: #63b3f5; border-color: #1e4b6e; background: rgba(66, 133, 244, 0.12); }
.pill-both { color: #4fd39a; border-color: #1f5540; background: rgba(47, 191, 113, 0.12); }
.pill-off { opacity: 0.7; }

/* ---------- ad slot ---------- */

.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.slot.is-off .slot-body { display: none; }
.slot.is-off { opacity: 0.72; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui {
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-ui { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.25); }
.switch-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- json preview ---------- */

.json {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #c9d1e4;
  overflow-x: auto;
  margin: 12px 0;
  white-space: pre;
}

.endpoint { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.endpoint .copyable { flex: 1 1 100%; padding: 8px 10px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }

/* ---------- alerts ---------- */

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-bottom: 14px;
  font-size: 14px;
}
.alert-success { border-color: #1f5540; background: rgba(47, 191, 113, 0.1); color: #7fe0b0; }
.alert-error { border-color: #4d2730; background: rgba(224, 82, 96, 0.1); color: #f0959e; }
.alert-info { border-color: #2c3a5a; background: rgba(99, 179, 245, 0.1); color: #9ecbf5; }

/* ---------- auth ---------- */

body.is-auth { display: grid; place-items: center; padding: 24px; }
.authshell { width: 100%; max-width: 380px; }

.authcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.authbrand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; margin-bottom: 4px; }
.authbrand h1 { font-size: 19px; margin: 4px 0 0; }
.authbrand p { font-size: 13px; }
