:root {
  --bg: #f5efe4;
  --bg-soft: #fbf7f0;
  --panel: rgba(255, 252, 246, 0.96);
  --panel-strong: #ffffff;
  --line: #decbb0;
  --line-strong: #ccb28e;
  --ink: #304252;
  --muted: #728392;
  --accent: #4d8cb4;
  --accent-soft: #dcedf8;
  --success: #4c9a61;
  --success-soft: #e7f6ea;
  --warning: #d88a29;
  --warning-soft: #fff2dd;
  --danger: #c85c63;
  --danger-soft: #fde8eb;
  --shadow: 0 18px 38px rgba(92, 71, 42, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.82), transparent 35%),
    linear-gradient(180deg, #f8f1e5 0%, #efe4d1 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Avenir", "Trebuchet MS", sans-serif;
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 28px;
}

.login-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid rgba(222, 203, 176, 0.95);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 38px 34px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #396785;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-title,
.section-title {
  margin: 16px 0 8px;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.06;
}

.login-copy,
.section-copy,
.helper-text,
.field-help,
.empty-copy,
.muted {
  color: var(--muted);
  line-height: 1.45;
}

.login-copy {
  margin-bottom: 20px;
}

.login-card .actions-row {
  justify-content: center;
}

.login-card #google-login-btn {
  min-height: 56px;
  min-width: min(320px, 100%);
  padding: 0 24px;
  font-size: 17px;
  font-weight: 700;
  border-radius: 18px;
}

.demo-box,
.surface,
.metric-card,
.orders-table-wrap,
.detail-card,
.form-card,
.publish-card,
.timeline-card,
.aside-card,
.preview-card {
  background: var(--panel);
  border: 1px solid rgba(222, 203, 176, 0.95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.demo-box {
  margin-top: 22px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.7);
}

.notice-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid transparent;
  line-height: 1.45;
}

.notice-banner + .notice-banner {
  margin-top: 12px;
}

.notice-banner strong {
  white-space: nowrap;
}

.notice-banner.info {
  background: rgba(220, 237, 248, 0.78);
  border-color: #c6dfee;
  color: #396785;
}

.notice-banner.warning {
  background: rgba(255, 242, 221, 0.9);
  border-color: #f0d5a8;
  color: #8c5c12;
}

.demo-box strong {
  display: block;
  margin-bottom: 8px;
}

.demo-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  padding: 12px 14px;
}

.field textarea {
  min-height: 130px;
  resize: vertical;
}

.field-help {
  font-size: 12px;
}

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

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

.btn {
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdfa 0%, #f2e8d9 100%);
  color: var(--ink);
  padding: 11px 15px;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(92, 71, 42, 0.08);
}

.btn-primary {
  border-color: #6da1c1;
  background: linear-gradient(180deg, #6cb0d6 0%, #4f8cb4 100%);
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(180deg, #fff 0%, #f5f1e8 100%);
}

.btn-success {
  border-color: #7ab386;
  background: linear-gradient(180deg, #78c28a 0%, #569a66 100%);
  color: #fff;
}

.btn-warning {
  border-color: #e1b36c;
  background: linear-gradient(180deg, #ffd186 0%, #e0a74f 100%);
  color: #5d3d08;
}

.btn-danger {
  border-color: #d98a90;
  background: linear-gradient(180deg, #f5a4ab 0%, #d86b74 100%);
  color: #fff;
}

.btn-ghost {
  background: rgba(255,255,255,0.6);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid rgba(222, 203, 176, 0.95);
  background: rgba(255, 251, 244, 0.9);
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav a {
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--ink);
  border: 1px solid transparent;
  background: transparent;
}

.nav a.is-active {
  background: var(--accent-soft);
  border-color: #c3dcea;
  color: #396785;
  font-weight: 700;
}

.sidebar-user {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.76);
  border: 1px solid var(--line);
}

.sidebar-user strong {
  display: block;
  margin-bottom: 5px;
}

.sidebar-user .muted {
  font-size: 13px;
  margin-bottom: 12px;
}

.content-shell {
  min-width: 0;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.topbar-title {
  display: grid;
  gap: 10px;
}

.topbar-title h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.04;
}

.topbar-title p {
  margin: 0;
  color: var(--muted);
}

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

.status-pill,
.role-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge {
  background: var(--warning-soft);
  color: #8f6412;
  border-color: #f2d2a1;
}

.status-pill[data-status="draft"] { background: #f0eef7; color: #685793; border-color: #ddd4ef; }
.status-pill[data-status="paid"] { background: #eaf7ed; color: #488160; border-color: #cfe8d6; }
.status-pill[data-status="svg_ready"] { background: #eef6ff; color: #44729e; border-color: #d2e4f8; }
.status-pill[data-status="game_created"] { background: #eff8f8; color: #3c7e7a; border-color: #cee8e6; }
.status-pill[data-status="needs_calibration"] { background: #fff3e5; color: #96641d; border-color: #f0d4a3; }
.status-pill[data-status="ready_to_publish"] { background: #eef3ff; color: #4e5c98; border-color: #d5ddf7; }
.status-pill[data-status="published"] { background: #e8f8ef; color: #357d58; border-color: #c8ead8; }
.status-pill[data-status="delivered"] { background: #e7f6ff; color: #397696; border-color: #cbe4f4; }
.status-pill[data-status="error"] { background: #fdebed; color: #b65059; border-color: #f2c8cd; }
.role-pill[data-role="admin"] { background: #efeaff; color: #5c4e9d; border-color: #dbd3fb; }
.role-pill[data-role="operator"] { background: #eef7ff; color: #44729e; border-color: #d2e4f8; }
.role-pill[data-active="true"] { background: #e8f8ef; color: #357d58; border-color: #c8ead8; }
.role-pill[data-active="false"] { background: #fdebed; color: #b65059; border-color: #f2c8cd; }
.role-pill[data-mode="open"] { background: #fff3e5; color: #96641d; border-color: #f0d4a3; }
.role-pill[data-mode="restricted"] { background: #eaf7ed; color: #488160; border-color: #cfe8d6; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 18px;
}

.metric-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin-bottom: 8px;
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
}

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

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar-group input,
.toolbar-group select {
  min-width: 190px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  padding: 11px 12px;
}

.orders-table-wrap {
  overflow: auto;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

.orders-table th,
.orders-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(222, 203, 176, 0.65);
  vertical-align: top;
  text-align: left;
}

.orders-table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.orders-table tbody tr:hover {
  background: rgba(255,255,255,0.4);
}

.thumbnail {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.7);
  display: grid;
  place-items: center;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.tiny-btn {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.82);
  color: var(--ink);
  font-size: 12px;
  text-decoration: none;
}

.tiny-btn.primary {
  background: var(--accent-soft);
  border-color: #c5dcec;
  color: #396785;
}

.empty-state {
  padding: 44px 28px;
  text-align: center;
  display: grid;
  gap: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.detail-main,
.detail-side {
  display: grid;
  gap: 18px;
}

.detail-card,
.form-card,
.publish-card,
.timeline-card,
.aside-card,
.preview-card {
  padding: 20px;
}

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

.card-head h3,
.card-head h4 {
  margin: 0;
  font-size: 20px;
}

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

.info-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(222,203,176,0.85);
}

.info-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.order-photo {
  width: 100%;
  min-height: 280px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbff 0%, #edf3fb 100%);
  display: grid;
  place-items: center;
}

.order-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-preview {
  width: 100%;
  min-height: 320px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(77, 140, 180, 0.06) 25%, transparent 25%, transparent 75%, rgba(77, 140, 180, 0.06) 75%, rgba(77, 140, 180, 0.06)),
    linear-gradient(45deg, rgba(77, 140, 180, 0.06) 25%, transparent 25%, transparent 75%, rgba(77, 140, 180, 0.06) 75%, rgba(77, 140, 180, 0.06)),
    linear-gradient(180deg, #fdfefe 0%, #eff5fb 100%);
  background-size: 22px 22px, 22px 22px, auto;
  background-position: 0 0, 11px 11px, 0 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.asset-preview img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.asset-preview--empty {
  min-height: 220px;
}

.game-preview {
  width: 100%;
  min-height: 620px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.8);
}

.game-preview iframe {
  width: 100%;
  height: 620px;
  border: 0;
  display: block;
  background: #fff;
}

.game-preview--empty {
  display: grid;
  place-items: center;
  padding: 24px;
}

.asset-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.tiny-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: #396785;
  background: rgba(220, 237, 248, 0.78);
  border: 1px solid #c6dfee;
  font-size: 13px;
  font-weight: 600;
}

.placeholder-photo {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 12px;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  margin-top: 6px;
  border-radius: 999px;
  background: #7fb2cf;
  box-shadow: 0 0 0 4px rgba(127, 178, 207, 0.15);
}

.timeline-body {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(222,203,176,0.85);
}

.timeline-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.json-area {
  min-height: 180px;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 13px;
}

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

.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(222,203,176,0.85);
}

.publish-summary {
  display: grid;
  gap: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(222,203,176,0.85);
}

.summary-row span:first-child {
  color: var(--muted);
}

.settings-grid .detail-main,
.settings-grid .detail-side {
  align-content: start;
}

.settings-table {
  min-width: 860px;
}

.callout {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--accent-soft);
  border: 1px solid #c7ddeb;
  color: #396785;
}

.prompt-composer {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(222,203,176,0.85);
  display: grid;
  gap: 14px;
}

.prompt-textarea {
  min-height: 110px;
}

.job-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid transparent;
  line-height: 1.45;
  margin-bottom: 14px;
}

.job-banner strong {
  white-space: nowrap;
}

.job-banner--info {
  background: rgba(220, 237, 248, 0.78);
  border-color: #c6dfee;
  color: #396785;
}

.job-banner--success {
  background: rgba(231, 246, 234, 0.9);
  border-color: #cbe7d2;
  color: #417a55;
}

.job-banner--danger {
  background: rgba(253, 232, 235, 0.92);
  border-color: #efc0c6;
  color: #ab4751;
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 12px;
  z-index: 9999;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 14px 16px;
  border-radius: 18px;
  color: #fff;
  box-shadow: 0 18px 32px rgba(34, 30, 24, 0.18);
}

.toast.success { background: linear-gradient(180deg, #62b378 0%, #468a5b 100%); }
.toast.info { background: linear-gradient(180deg, #67a9cf 0%, #4c86a8 100%); }
.toast.error { background: linear-gradient(180deg, #e1838d 0%, #bd5a63 100%); }

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
  }

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

@media (max-width: 760px) {
  .content-shell {
    padding: 16px;
  }

  .game-preview,
  .game-preview iframe {
    min-height: 520px;
    height: 520px;
  }

  .form-row,
  .info-grid,
  .checks-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .orders-table {
    min-width: 860px;
  }
}
