:root {
  --bg: #f7f4ee;
  --paper: #fffdf8;
  --paper-strong: #ffffff;
  --table: #f8f3ea;
  --table-head: #f0e8da;
  --ink: #201c1a;
  --muted: #6b635d;
  --accent: #4e46a6;
  --accent-soft: #ebe8ff;
  --accent-edge: #cfc9ff;
  --info-soft: #e6f0ff;
  --warn: #bc5a34;
  --warn-soft: #fdebe4;
  --success-soft: #edf7dd;
  --success-ink: #325d19;
  --edge: #ded4c5;
  --edge-strong: #cfc1ae;
  --shadow: #54453b10;
  --shadow-strong: #54453b1d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

.admin-page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at top left, #efebff 0%, transparent 34%),
    radial-gradient(circle at top right, #f4efe5 0%, transparent 28%),
    linear-gradient(180deg, #faf7f2 0%, #f7f4ee 100%);
  z-index: -1;
}

.admin-shell {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 18px 18px 10px;
  background: #f7f4eede;
  backdrop-filter: blur(10px);
}

.admin-shell-surface {
  max-width: 1420px;
  margin: 0 auto;
  border: 1px solid #e7dfd2;
  border-radius: 24px;
  background: #fffdf9d6;
  box-shadow: 0 16px 40px var(--shadow);
  padding: 18px;
}

.admin-shell-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-shell-brand {
  min-width: 0;
}

.admin-shell-eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3ede2;
  color: #6b5b45;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-shell-brand h1 {
  margin: 12px 0 6px;
  font-size: 2.1rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.admin-shell-brand p {
  margin: 0;
  max-width: 58rem;
  color: var(--muted);
  font-size: 1rem;
}

.admin-shell-side {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  min-width: min(420px, 100%);
}

.admin-status-card {
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: #f5efe5;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.admin-status-card span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.admin-status-card strong {
  font-size: 1rem;
}

.admin-status-card-warning {
  background: var(--warn-soft);
  border-color: #f0c9b8;
  color: #8d3514;
}

.admin-status-card-info {
  background: var(--info-soft);
  border-color: #c7d8ff;
  color: #24539f;
}

.admin-status-card-danger {
  background: #fbe7e7;
  border-color: #eab7b7;
  color: #a13232;
}

.admin-logout-btn {
  align-self: stretch;
  min-height: 52px;
}

.admin-primary-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--edge);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 16px;
  background: #fff;
}

.admin-primary-tab {
  min-height: 64px;
  border: 0;
  border-right: 1px solid var(--edge);
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: #3e3934;
  font-size: 1.05rem;
  font-weight: 700;
}

.admin-primary-tab:last-child {
  border-right: 0;
}

.admin-primary-tab-step {
  color: inherit;
  opacity: 0.8;
}

.admin-primary-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-edge);
}

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

.admin-nav-panel {
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: #fffefb;
  padding: 16px;
  box-shadow: 0 6px 18px var(--shadow);
}

.admin-nav-panel.active {
  border-color: var(--accent-edge);
  background: linear-gradient(180deg, #f8f6ff 0%, #fffefb 100%);
}

.admin-nav-panel-header {
  margin-bottom: 12px;
}

.admin-nav-panel-header h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.admin-nav-panel-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-nav-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-nav-button {
  position: relative;
}

.container {
  max-width: 1420px;
  margin: 10px auto 28px;
  padding: 0 18px 28px;
}

@media (max-width: 1180px) {
  .admin-shell-header,
  .admin-nav-grid {
    grid-template-columns: 1fr 1fr;
  }

  .admin-shell-header {
    display: grid;
  }

  .admin-nav-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .admin-shell {
    padding: 14px 14px 10px;
  }

  .admin-shell-surface {
    border-radius: 18px;
    padding: 14px;
  }

  .admin-shell-side,
  .admin-primary-nav,
  .admin-nav-grid {
    grid-template-columns: 1fr;
  }

  .admin-primary-tab {
    min-height: 56px;
    justify-content: flex-start;
    padding-inline: 16px;
  }
}

/* ── Compact shell (non-home pages) ─────────────────────── */
.admin-shell-surface.compact {
  padding: 10px 14px 8px;
  box-shadow: 0 4px 16px var(--shadow);
}

.admin-shell-surface.compact .admin-shell-header {
  margin-bottom: 8px;
  align-items: center;
}

.admin-shell-surface.compact .admin-shell-eyebrow {
  display: none;
}

.admin-shell-surface.compact .admin-shell-brand h1 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.admin-shell-surface.compact .admin-shell-brand p {
  display: none;
}

.admin-shell-surface.compact .admin-shell-side {
  display: none;
}

.admin-shell-surface.compact .admin-primary-nav {
  margin-bottom: 6px;
  display: flex;
  flex-wrap: nowrap;
  border-radius: 14px;
}

.admin-shell-surface.compact .admin-primary-tab {
  min-height: 36px;
  font-size: 0.9rem;
}

.admin-shell-surface.compact .admin-primary-tab-step {
  display: none;
}

.admin-shell-surface.compact .admin-nav-grid {
  display: block;
}

.admin-shell-surface.compact .admin-nav-panel {
  display: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  background: transparent;
}

.admin-shell-surface.compact .admin-nav-panel.active {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-shell-surface.compact .admin-nav-panel-header {
  display: none;
}

.admin-shell-surface.compact .admin-nav-buttons {
  flex-wrap: nowrap;
  gap: 6px;
}

.admin-shell-surface.compact .admin-nav-button {
  font-size: 0.88rem;
  padding: 5px 12px;
  min-height: 30px;
}

/* ── Home shell (landing/menu page) ─────────────────────── */
.admin-shell-surface.home .admin-primary-nav,
.admin-shell-surface.home .admin-nav-grid {
  display: none;
}

/* ── Home page content grid ──────────────────────────────── */
.home-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 4px 0;
}

.home-section-card {
  border: 1px solid var(--edge);
  border-radius: 22px;
  background: #fffefb;
  padding: 20px;
  box-shadow: 0 6px 18px var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
  text-align: left;
}

.home-section-card:hover {
  border-color: var(--accent-edge);
  background: linear-gradient(180deg, #f8f6ff 0%, #fffefb 100%);
  box-shadow: 0 10px 28px var(--shadow);
}

.home-section-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.home-section-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.home-section-header h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  line-height: 1.2;
}

.home-section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.home-section-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.home-section-item {
  font-size: 0.86rem;
  padding: 5px 12px;
  min-height: 30px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fff;
}

.home-section-item:hover {
  border-color: var(--accent-edge);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Hide home button in full (home page) shell */
.admin-home-tab {
  display: none;
}
.admin-shell-surface.compact .admin-home-tab {
  display: inline-flex;
  font-size: 0.88rem;
  min-height: 36px;
  border-right: 1px solid var(--edge);
  border-radius: 0;
  color: var(--accent);
  font-weight: 700;
}

.page-loading {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #0000001f;
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.page-loading-card {
  min-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--edge);
  background: var(--paper-strong);
  border-radius: 12px;
  box-shadow: 0 10px 30px #00000014;
  padding: 12px 14px;
}

.page-loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #bfdccf;
  border-top-color: var(--accent);
  animation: page-spin 0.7s linear infinite;
}

.page-loading-text {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
}

body.is-loading-page .top-actions button {
  cursor: progress;
}

.card {
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 10px 30px var(--shadow);
  animation: rise 0.45s ease;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-header-main {
  min-width: 0;
}

.section-header-main .section-title {
  margin: 0;
}

.section-header-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: auto;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--edge);
  color: var(--ink);
}

.section-refresh-btn svg {
  width: 14px;
  height: 14px;
}

.section-refresh-btn.is-refreshing svg {
  animation: page-spin 0.8s linear infinite;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi {
  background: #ffffff;
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 12px;
}

.kpi.kpi-wide {
  grid-column: span 2;
}

.kpi .label {
  color: var(--muted);
  font-size: 0.8rem;
}

.kpi .value {
  font-size: 1.55rem;
  font-weight: 700;
}

.kpi .value.small {
  font-size: 1rem;
  line-height: 1.3;
}

.top-list {
  margin: 0 0 20px;
  padding-left: 20px;
}

.top-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--edge);
}

.top-list .name {
  font-weight: 500;
}

.top-list .count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.top-chart {
  display: grid;
  gap: 10px;
  margin: 0;
}

.top-chart-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.top-chart-label {
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-chart-track {
  height: 12px;
  border-radius: 999px;
  background: #efe7d8;
  border: 1px solid var(--edge);
  overflow: hidden;
}

.top-chart-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    hsl(var(--bar-h, 156) 76% 32%) 0%,
    hsl(calc(var(--bar-h, 156) + 10) 72% 47%) 100%
  );
}

.top-chart-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}

.busy-hours-chart {
  margin: 0 0 20px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.busy-hours-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.busy-hours-grid {
  stroke: #d7cfbf;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.busy-hours-grid-vertical {
  stroke: #ece4d6;
  stroke-width: 1;
}

.busy-hours-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.busy-hours-point {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2;
}

.busy-hours-y-label,
.busy-hours-x-label {
  fill: var(--muted);
  font-size: 9px;
  font-family: "Manrope", sans-serif;
}

.busy-hours-x-label-category {
  font-size: 8px;
}

.busy-hours-summary {
  margin-top: 8px;
  font-size: 0.9rem;
}

.users-trend-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.users-trend-line-total {
  stroke: #1a1a1a;
}

.users-trend-line-paid {
  stroke: #0f8a5f;
}

.users-trend-line-free {
  stroke: #c4542f;
}

.users-trend-point {
  fill: #fff;
  stroke-width: 2;
}

.users-trend-point-total {
  stroke: #1a1a1a;
}

.users-trend-point-paid {
  stroke: #0f8a5f;
}

.users-trend-point-free {
  stroke: #c4542f;
}

.users-trend-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.9rem;
}

.users-trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.users-trend-swatch {
  width: 14px;
  height: 3px;
  border-radius: 999px;
  display: inline-block;
}

.users-trend-swatch-total {
  background: #1a1a1a;
}

.users-trend-swatch-paid {
  background: #0f8a5f;
}

.users-trend-swatch-free {
  background: #c4542f;
}

.outage-duration-chart {
  margin-bottom: 14px;
}

.outage-duration-line {
  fill: none;
  stroke: hsl(var(--line-h, 160) 68% 38%);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.outage-duration-point {
  fill: #fff;
  stroke: hsl(var(--line-h, 160) 68% 38%);
  stroke-width: 2;
}

.outage-duration-legend {
  margin-top: 10px;
  display: flex;
  gap: 10px 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

.outage-duration-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.outage-duration-swatch {
  width: 14px;
  height: 3px;
  border-radius: 999px;
  background: hsl(var(--line-h, 160) 68% 38%);
  display: inline-block;
}

.crash-signature-columns {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.crash-signature-columns h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.crash-signature-columns .top-list {
  margin-bottom: 0;
}

button {
  font-family: inherit;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  background: linear-gradient(180deg, #6058c2 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 8px 18px #4e46a61a;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px #4e46a624;
}

input[type="text"],
input[type="number"],
select {
  font-family: inherit;
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  background: #fffefc;
  color: var(--ink);
  min-width: 180px;
  box-shadow: inset 0 1px 2px #00000005;
}

input[type="number"] {
  min-width: 74px;
}

textarea {
  padding: 10px 12px;
  font-size: 0.92rem;
  border-radius: 14px;
  border: 1px solid var(--edge);
  background: #fffefc;
  color: var(--ink);
  width: 100%;
  box-shadow: inset 0 1px 2px #00000005;
}

button.ghost {
  background: #fffefb;
  color: var(--ink);
  border-color: var(--edge);
  box-shadow: none;
}

button.ghost:hover {
  box-shadow: 0 10px 22px #54453b12;
}

button.ghost.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-edge);
}

button.is-loading-nav {
  transform: translateY(1px) scale(0.98);
  opacity: 0.78;
  box-shadow: inset 0 0 0 2px #00000014;
}

button#navAlerts {
  position: relative;
}

button#navAlerts.has-alert::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #d90429;
  box-shadow: 0 0 0 2px #fff;
}

button#navExternalApis {
  position: relative;
}

button#navExternalApis.has-api-degraded::after,
button#navExternalApis.has-api-down::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px #fff;
}

button#navExternalApis.has-api-degraded::after {
  background: #f59e0b;
}

button#navExternalApis.has-api-down::after {
  background: #d90429;
}

button.warn {
  background: linear-gradient(180deg, #d17049 0%, var(--warn) 100%);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-card {
  margin: 10px 0 16px;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--table);
  overflow: hidden;
  box-shadow: 0 8px 20px var(--shadow);
}

.table-empty {
  padding: 12px 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.data-table {
  min-width: 100%;
  width: max-content;
  background: var(--table);
}

.data-table thead {
  background: var(--table-head);
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--edge);
  padding: 9px 10px;
  font-size: 0.9rem;
  vertical-align: top;
}

th {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #333333;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

td {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.cell-nowrap {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.cell-tight {
  width: 1%;
}

.cell-wide {
  min-width: 22rem;
}

tbody tr:nth-child(even) {
  background: #fffdf9;
}

a {
  color: var(--accent);
}

.section-title {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.section-subtitle {
  margin: 18px 0 8px;
  font-size: 1rem;
}

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

.grid-images {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.grid-images img {
  width: auto;
  max-width: 40%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--edge);
}

pre.json {
  margin: 0;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
}

td code {
  font-size: 0.85rem;
}

.audio-link-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-link-group audio {
  max-width: 320px;
}

.page-list {
  display: grid;
  gap: 12px;
}

.page-card {
  padding: 12px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--table);
}

.page-card h4 {
  margin: 0 0 8px;
}

.page-card p {
  margin: 0;
  white-space: pre-wrap;
}

.prompt-card {
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--table);
  padding: 12px;
  margin-bottom: 12px;
}

.prompt-card h4 {
  margin: 0 0 8px;
}

.prompt-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-header-row h3 {
  margin: 0;
}

.signed-image-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scroll-snap-type: x proximity;
}

.signed-image-thumb {
  width: 160px;
  min-width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: #fff;
  scroll-snap-align: start;
}

.signed-image-thumb-btn {
  width: 160px;
  min-width: 160px;
  height: 160px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.signed-image-thumb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.inline-list {
  margin: 0;
  padding-left: 18px;
}

.inline-list li {
  margin: 2px 0;
}

.modal-image-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-image-wrap-actual {
  overflow: auto;
  max-height: calc(92vh - 120px);
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: #fff;
}

.modal-image {
  width: auto;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: #fff;
  object-fit: contain;
}

.modal-image-actual {
  width: auto;
  max-width: min(100%, 1200px);
  max-height: calc(92vh - 160px);
  height: auto;
  border: 0;
  border-radius: 0;
  display: block;
  object-fit: contain;
}

.prompt-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
  font-size: 0.84rem;
  line-height: 1.45;
  font-family: "IBM Plex Mono", monospace;
}

.prompt-pre-compact {
  max-height: 180px;
  overflow: auto;
}

.external-api-summary {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
}

.model-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 680px) {
  .model-config-grid {
    grid-template-columns: 1fr;
  }
}

.model-config-input {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.4;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: #fafafa;
  color: inherit;
  padding: 10px;
}

.api-status-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.8rem;
  border: 1px solid var(--edge);
  background: #f5f5f5;
  color: #3a3a3a;
}

.api-status-up {
  background: #e6f6ef;
  border-color: #9bd5bc;
  color: #0b6b49;
}

.api-status-degraded {
  background: #fff6df;
  border-color: #ead08e;
  color: #7a5a0a;
}

.api-status-down {
  background: #fcebe7;
  border-color: #e9b2a8;
  color: #9f2f1e;
}

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

.window-filters {
  margin-bottom: 10px;
}

.dashboard-search-row,
.users-toolbar {
  margin-bottom: 10px;
}

.voice-status-stack {
  display: grid;
  gap: 6px;
}

.voice-row-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.voice-avatar-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.voice-avatar-thumb,
.voice-avatar-thumb-compact {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--edge);
  background: #fff;
}

.voice-avatar-thumb-compact {
  width: 42px;
  height: 42px;
}

.voice-avatar-fallback,
.voice-avatar-fallback-compact {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: #efe7d8;
  color: var(--ink);
  font-weight: 700;
}

.voice-avatar-fallback-compact {
  width: 42px;
  height: 42px;
}

.voice-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.voice-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.voice-admin-grid textarea {
  margin-top: 6px;
}

.voice-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.voice-editor-grid-bottom {
  align-items: start;
}

.voice-editor-preview {
  min-height: 56px;
  display: flex;
  align-items: center;
}

.voice-audio-grid {
  display: grid;
  gap: 8px;
  min-width: 180px;
}

.voice-audio-item {
  display: grid;
  gap: 4px;
}

.voice-audio-item-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.voice-audio-links {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .voice-admin-grid,
  .voice-form-grid,
  .voice-editor-grid {
    grid-template-columns: 1fr;
  }
}

.users-pagination {
  margin-top: 10px;
}

.user-subscription-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.user-subscription-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  border: 1px solid var(--edge);
  background: #f4f4f4;
  color: #3a3a3a;
}

.user-subscription-pill-paid {
  background: #e6f6ef;
  border-color: #9bd5bc;
  color: #0b6b49;
}

.user-subscription-pill-trial {
  background: #fff6df;
  border-color: #ead08e;
  color: #7a5a0a;
}

.user-subscription-pill-free {
  background: #ebf0ff;
  border-color: #b7c9eb;
  color: #24539f;
}

.user-subscription-pill-unknown {
  background: #f5f5f5;
  border-color: #d9d9d9;
  color: #4d4d4d;
}

.user-subscription-pill-plan {
  background: #f7f5ef;
  border-color: #e2d8c5;
  color: #5a4d35;
}

.bonus-grant-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  max-width: 760px;
  margin: 10px 0 18px;
}

.bonus-grant-form label {
  display: grid;
  gap: 4px;
}

.bonus-grant-form label:nth-child(3),
.bonus-grant-form label:nth-child(4),
.bonus-grant-message,
.bonus-grant-form .inline-actions {
  grid-column: 1 / -1;
}

.bonus-grant-message {
  min-height: 22px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--muted);
}

.bonus-grant-message-success {
  background: var(--success-soft);
  color: var(--success-ink);
}

.bonus-grant-message-error {
  background: var(--warn-soft);
  color: var(--warn);
}

.subscription-grant-form label:nth-child(3),
.subscription-grant-form label:nth-child(4) {
  grid-column: auto;
}

.subscription-grant-form label:nth-child(5),
.subscription-grant-form label:nth-child(6),
.subscription-grant-details {
  grid-column: 1 / -1;
}

.subscription-grant-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px 12px;
  padding: 8px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: #f7fbf9;
}

.subscription-grant-details div {
  display: grid;
  gap: 2px;
}

.subscription-grant-details span {
  color: var(--muted);
  font-size: 0.82rem;
}

.ledger-history {
  margin: 12px 0 18px;
}

.private-message-history {
  margin: 12px 0 18px;
}

.private-message-history-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.private-message-history-title-row h3 {
  margin-bottom: 2px;
}

.private-message-history-list {
  display: grid;
  gap: 10px;
  max-width: 900px;
}

.private-message-history-card {
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fbf9ff;
  padding: 12px;
}

.private-message-history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.private-message-history-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #efe7ff;
  color: #5c3499;
  border: 1px solid #d8c2ff;
  font-size: 0.82rem;
  font-weight: 700;
}

.private-message-history-card h4 {
  margin: 0 0 6px;
}

.private-message-history-body {
  white-space: pre-wrap;
  margin: 0 0 10px;
}

.private-message-history-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.private-message-history-meta div {
  display: grid;
  gap: 2px;
}

.private-message-history-meta dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.private-message-history-meta dd {
  margin: 0;
}

.ledger-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 8px 0 10px;
}

.ledger-toolbar label {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.ledger-table code {
  white-space: nowrap;
}

@media (max-width: 700px) {
  .bonus-grant-form {
    grid-template-columns: 1fr;
  }

  .subscription-grant-form label:nth-child(3),
  .subscription-grant-form label:nth-child(4) {
    grid-column: 1 / -1;
  }

  .subscription-grant-details {
    grid-template-columns: 1fr;
  }

  .private-message-history-title-row {
    display: grid;
  }

  .private-message-history-meta {
    grid-template-columns: 1fr;
  }
}

.latency-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}

.latency-bar {
  width: 4px;
  border-radius: 2px;
  background: #c5c5c5;
}

.latency-bar:nth-child(1) {
  height: 6px;
}

.latency-bar:nth-child(2) {
  height: 10px;
}

.latency-bar:nth-child(3) {
  height: 14px;
}

.latency-bars.latency-fast .latency-bar {
  background: #0f8a5f;
}

.latency-bars.latency-mid .latency-bar {
  background: #cf7b11;
}

.latency-bars.latency-slow .latency-bar {
  background: #c4542f;
}

.latency-bars.latency-unknown .latency-bar {
  background: #a8a8a8;
}

.settings-form {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.settings-row > span {
  color: var(--muted);
}

.settings-row input {
  width: 100%;
  min-width: 0;
}

.settings-row.checkbox-row {
  grid-template-columns: minmax(220px, 1.2fr) auto;
}

.settings-row.checkbox-row input[type="checkbox"] {
  width: auto;
  justify-self: start;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.message-editor {
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  margin-bottom: 14px;
}

.message-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.message-editor-header h3 {
  margin: 0;
}

.message-editor-grid {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.message-editor-grid label {
  display: grid;
  gap: 6px;
}

.character-skin-editor-layout {
  display: grid;
  gap: 14px;
}

@media (min-width: 980px) {
  .character-skin-editor-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
    align-items: start;
  }
}

.asset-age-groups,
.character-skin-age-groups {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: #fffdf9;
}

.asset-age-group-option,
.character-skin-age-group-option {
  align-items: flex-start;
}

.asset-age-group-option span,
.character-skin-age-group-option span {
  display: grid;
  gap: 2px;
}

.asset-age-group-option small,
.character-skin-age-group-option small {
  color: var(--muted);
}

.asset-age-group-field,
.character-skin-enabled-field,
.character-skin-age-group-field {
  align-content: start;
}

.character-skin-preview-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: #fffdf9;
}

.character-skin-preview-panel > span {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #333333;
}

.character-skin-preview-frame {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--edge);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.character-skin-preview-frame img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}

.dlq-editor {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  padding: 12px;
}

.trace-status {
  display: inline-block;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--edge);
  background: #f5f5f5;
}

.trace-status-success {
  background: #e6f6ef;
  color: #0b6b49;
  border-color: #9bd5bc;
}

.trace-status-failed {
  background: #fcebe7;
  color: #9f2f1e;
  border-color: #e9b2a8;
}

.trace-status-retry {
  background: #fff6df;
  color: #7a5a0a;
  border-color: #ead08e;
}

.trace-status-started {
  background: #e8f1ff;
  color: #24539f;
  border-color: #b7c9eb;
}

.trace-status-warning {
  background: #fff6df;
  color: #7a5a0a;
  border-color: #ead08e;
}

.flow-card {
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--table);
  padding: 12px;
  margin-bottom: 14px;
}

.flow-card h3,
.flow-card h4 {
  margin: 0 0 8px;
}

.flow-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

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

.trace-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fafafa;
  font-size: 0.82rem;
}

.timeline-table .cell-time {
  min-width: 11rem;
}

.timeline-table .cell-message {
  min-width: 34rem;
}

.alerts-table .cell-message {
  min-width: 30rem;
}

.book-details-table th:first-child,
.book-details-table td:first-child {
  min-width: 18rem;
  width: 18rem;
  white-space: nowrap;
}

.book-details-table td:first-child code {
  white-space: nowrap;
}

.image-reports-table .cell-failure-reasons {
  min-width: 26rem;
}

.monitor-settings-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--edge);
}

.monitor-settings-block .inline-actions {
  margin-top: 10px;
}

.ai-route-summary {
  margin: 14px 0;
}

.ai-route-summary h4 {
  margin-bottom: 8px;
}

.trace-summary-panel {
  margin-bottom: 16px;
}

.trace-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.trace-summary-card {
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--table);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.trace-summary-card strong {
  font-size: 1.1rem;
}

.trace-summary-table h3 {
  margin: 0 0 4px;
}

.queue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.queue-card {
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--table);
  padding: 12px;
}

.queue-card h3 {
  margin: 0 0 8px;
}

.queue-card-actions {
  margin-top: 12px;
}

.queue-message {
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fcfcfc;
}

.queue-message:last-child {
  margin-bottom: 0;
}

.crash-stack {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px;
  background: #fafafa;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: #00000070;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 14px;
}

.modal-card-image {
  width: min(1400px, 96vw);
  max-height: 92vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  margin-top: 10px;
}

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

.hidden {
  display: none;
}

.timestamp-area {
  width: min(460px, 100%);
  min-height: 82px;
  resize: vertical;
  font-family: monospace;
  font-size: 0.8rem;
}

@keyframes rise {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes page-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi.kpi-wide {
    grid-column: span 2;
  }

  .crash-signature-columns {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .top-chart-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .top-chart-count {
    text-align: left;
  }

  .busy-hours-y-label,
  .busy-hours-x-label {
    font-size: 10px;
  }

  .grid-images {
    display: block;
  }

  .grid-images img {
    max-width: 40%;
    margin-bottom: 10px;
  }

  .signed-image-thumb {
    width: 130px;
    min-width: 130px;
    height: 130px;
  }

  .signed-image-thumb-btn {
    width: 130px;
    min-width: 130px;
    height: 130px;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .settings-row.checkbox-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}
