:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f7f8f5;
  --ink: #18201f;
  --muted: #61706d;
  --line: #d9dfdc;
  --accent: #0f766e;
  --accent-2: #d15b3f;
  --accent-3: #2f6f9f;
  --good: #16825d;
  --danger: #b42318;
  --shadow: 0 22px 70px rgba(35, 49, 46, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(209, 91, 63, 0.12), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.route-shell,
.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.route-panel {
  width: min(420px, 100%);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  text-align: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.route-panel h1,
.route-panel p {
  margin: 0;
}

.route-panel p {
  margin-top: 8px;
  color: var(--muted);
}

.workspace {
  width: min(1120px, 100%);
}

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

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.96;
}

h2 {
  font-size: 20px;
}

.ghost-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  text-decoration: none;
  font-weight: 700;
}

.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 92px;
  padding: 20px 22px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: #123b39;
  color: #fff;
  box-shadow: var(--shadow);
}

.service-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.service-tab {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.service-tab.is-active {
  border-color: var(--line);
  background: var(--ink);
  color: #fff;
}

.service-panel {
  display: none;
}

.service-panel.is-active {
  display: block;
}

.codex-band {
  background: #203a56;
}

.summary-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #69d8a9;
  box-shadow: 0 0 0 6px rgba(105, 216, 169, 0.2);
}

.summary-meter {
  display: grid;
  grid-template-columns: repeat(3, minmax(40px, 82px));
  gap: 8px;
}

.summary-meter span {
  display: block;
  height: 36px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
}

.summary-meter span:nth-child(2) {
  background: rgba(255, 255, 255, 0.3);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
  align-items: stretch;
}

.tool-panel,
.result-panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 44px rgba(35, 49, 46, 0.1);
  backdrop-filter: blur(16px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e0f2ee;
  color: #07594f;
  font-size: 12px;
  font-weight: 800;
}

.pill.muted {
  background: var(--surface-2);
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.warning-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(209, 91, 63, 0.32);
  border-radius: 8px;
  background: #fff5f0;
  color: #7a2d1a;
  font-size: 13px;
  font-weight: 800;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}

.compact-field {
  max-width: 180px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.textarea {
  min-height: 210px;
  padding: 13px;
  resize: vertical;
  line-height: 1.5;
}

.small-textarea {
  min-height: 130px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

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

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-button {
  width: 44px;
  padding: 0;
}

.result-panel {
  min-height: 410px;
}

.activation-grid {
  grid-template-columns: minmax(300px, 470px) 1fr;
}

.activation-result {
  min-height: 520px;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.result-actions strong {
  font-size: 18px;
}

.compact-actions {
  margin-top: 0;
}

.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  color: var(--muted);
  text-align: center;
}

.asset-card {
  width: min(310px, 72vw);
  aspect-ratio: 1.7;
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    #0f766e;
  box-shadow: 0 18px 50px rgba(15, 118, 110, 0.26);
}

.codex-asset {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)),
    #2f6f9f;
  box-shadow: 0 18px 50px rgba(47, 111, 159, 0.26);
}

.asset-card span {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.28);
}

.asset-card span:nth-child(1) {
  width: 46%;
}

.asset-card span:nth-child(2) {
  width: 84%;
}

.asset-card span:nth-child(3) {
  width: 62%;
}

.result-box {
  max-height: 540px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  background: #0f1716;
  color: #d6f7ee;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.is-error {
  color: #ffe0dc;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 18, 17, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modal-actions {
  justify-content: flex-end;
}

.admin-shell {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.admin-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

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

button.ghost-link {
  cursor: pointer;
  font: inherit;
}

.admin-login {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.admin-workspace {
  display: grid;
  gap: 18px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.tab-button,
.segment-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.tab-button.is-active,
.segment-button.is-active {
  border-color: var(--line);
  background: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
  gap: 18px;
}

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

.metric-card,
.table-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 44px rgba(35, 49, 46, 0.1);
}

.metric-card {
  display: grid;
  gap: 6px;
}

.metric-card span,
.metric-card small,
.muted-text {
  color: var(--muted);
}

.metric-card strong {
  font-size: 34px;
  line-height: 1;
}

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

.home-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.table-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 14px;
  color: var(--ink);
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.database-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.search-field {
  margin: 0;
}

.db-list {
  display: grid;
  gap: 8px;
}

.db-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.db-row strong,
.db-row span {
  overflow-wrap: anywhere;
}

.db-row span {
  color: var(--muted);
  font-size: 13px;
}

.code-output {
  max-height: 240px;
  margin-top: 14px;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.list-row div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.list-row strong,
.list-row span {
  overflow-wrap: anywhere;
}

.list-row span {
  color: var(--muted);
  font-size: 13px;
}

.admin-log {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #0f1716;
  color: #d6f7ee;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 16px;
    place-items: start center;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(38px, 14vw, 58px);
  }

  .summary-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-meter {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

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

  .metric-grid,
  .admin-grid,
  .table-grid,
  .home-grid,
  .database-toolbar {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .segment-button {
    flex: 1;
  }

  .admin-shell {
    padding: 16px;
  }

  .admin-topbar,
  .result-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-panel,
  .result-panel {
    padding: 18px;
  }

  .warning-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}
