:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #182230;
  --muted: #667085;
  --border: #d7dee8;
  --border-strong: #b9c4d0;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --amber: #b54708;
  --red: #b42318;
  --shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(245, 247, 251, 0) 320px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

button,
.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 8px 13px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

.button.secondary {
  background: var(--surface);
  color: var(--accent-strong);
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  color: var(--text);
  font-weight: 650;
  padding: 10px 12px;
}

.nav-link:hover {
  background: var(--surface-soft);
  text-decoration: none;
}

.nav-link.is-active {
  background: #e6f4f1;
  color: var(--accent-strong);
}

.sidebar-actions {
  margin-top: auto;
  padding-top: 24px;
}

.logout-button {
  width: 100%;
}

.admin-main {
  min-width: 0;
  padding: 34px clamp(18px, 4vw, 52px) 52px;
}

.page-header {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
  line-height: 1.08;
}

h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.page-description {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

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

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

.panel,
.stat-card,
.section-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 18px 20px;
}

.panel-body {
  padding: 18px 20px;
}

.stat-card,
.section-card {
  padding: 18px;
}

.stat-label,
.setting-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-value {
  margin: 0;
  font-size: 28px;
  font-weight: 850;
  line-height: 1.1;
}

.status-list,
.clean-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-line,
.setting-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.status-value,
.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
}

.badge.ok,
.status-value.ok {
  border-color: rgba(15, 118, 110, 0.28);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.badge.warn,
.status-value.warn {
  border-color: rgba(181, 71, 8, 0.28);
  background: #fff3e0;
  color: var(--amber);
}

.badge.danger,
.status-value.danger {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff1f0;
  color: var(--red);
}

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

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: #263343;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

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

.empty-state {
  margin: 0;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 16px;
}

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

.disabled-item {
  opacity: 0.72;
}

.content-cell {
  min-width: 320px;
  max-width: 720px;
}

.compact-table {
  min-width: 460px;
}

.footer-note {
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  padding: 10px 12px;
}

.notice.ok {
  border-color: rgba(15, 118, 110, 0.24);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.prompt-list {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.prompt-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

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

.prompt-editor h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.prompt-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 12px;
}

.prompt-textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font:
    13px/1.55 ui-monospace,
    SFMono-Regular,
    Consolas,
    "Liberation Mono",
    monospace;
  padding: 12px;
}

.prompt-textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.model-list {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 16px;
}

.model-copy h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.model-form {
  display: grid;
  gap: 10px;
}

.model-select-label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.model-form select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
}

.model-form select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.model-meta,
.model-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.model-id {
  color: var(--muted);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 12px;
}

.log-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.log-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  font-weight: 800;
  text-decoration: none;
}

.log-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.log-tab.is-active {
  border-color: var(--accent);
  background: #e6f4f1;
  color: var(--accent-strong);
}

.tab-count {
  min-width: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 2px 7px;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.log-tab.is-active .tab-count {
  background: var(--accent);
  color: #fff;
}

.log-summary {
  margin: 0;
}

.log-days {
  display: grid;
  gap: 18px;
}

.log-day-header {
  align-items: center;
}

.trace-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 16px 20px;
}

.trace-item + .trace-item {
  border-top: 1px solid var(--border);
}

.trace-item::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 36px;
  width: 1px;
  background: var(--border);
  content: "";
}

.trace-marker {
  position: relative;
  z-index: 1;
  width: 13px;
  height: 13px;
  margin: 6px auto 0;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
}

.trace-tool .trace-marker {
  border-color: var(--blue);
}

.trace-audit .trace-marker {
  border-color: var(--amber);
}

.trace-memory .trace-marker {
  border-color: var(--accent);
  background: #e6f4f1;
}

.trace-card {
  min-width: 0;
}

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

.trace-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.28;
}

.trace-time {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trace-summary {
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.trace-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin: 12px 0 0;
}

.trace-details div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px 10px;
}

.trace-details dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.trace-details dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.trace-json-wrap {
  margin-top: 12px;
}

.trace-json-wrap summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.trace-json {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  font:
    12px/1.55 ui-monospace,
    SFMono-Regular,
    Consolas,
    "Liberation Mono",
    monospace;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
  }

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

  .sidebar-actions {
    margin-top: 14px;
    padding-top: 0;
  }

  .admin-main {
    padding-top: 24px;
  }

  .panel-header {
    display: grid;
  }

  .prompt-editor-header {
    display: grid;
  }

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

  .public-hero {
    grid-template-columns: 1fr;
  }

  .public-hero-copy {
    min-height: 0;
  }

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

  .trace-item {
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 14px 16px;
  }

  .trace-item::before {
    left: 27px;
  }
}

@media (max-width: 560px) {
  .nav-list,
  .stat-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .status-line,
  .setting-line {
    align-items: flex-start;
    flex-direction: column;
  }

  button,
  .button {
    width: 100%;
  }

  .log-filter,
  .trace-head {
    display: grid;
  }
}

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

.login-panel {
  width: min(100%, 440px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.form-field {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.form-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
}

.form-field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.login-error {
  margin: 0 0 16px;
  border: 1px solid rgba(180, 35, 24, 0.28);
  border-radius: 8px;
  background: #fff1f0;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
}

.public-home {
  display: grid;
  gap: 36px;
  min-height: 100vh;
  padding: 32px clamp(16px, 5vw, 64px) 48px;
}

.public-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 24px;
  align-items: stretch;
  width: min(100%, 1120px);
  margin: 0 auto;
}

.public-hero-copy,
.public-status-panel,
.public-policy-panel,
.public-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.public-hero-copy {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 430px;
  padding: clamp(24px, 5vw, 52px);
}

.public-lead {
  max-width: 760px;
  margin: 0;
  color: #344054;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.5;
}

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

.public-status-panel {
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 280px;
  padding: 24px;
}

.public-status-panel p {
  margin: 0;
}

.public-section {
  display: grid;
  gap: 16px;
  width: min(100%, 1120px);
  margin: 0 auto;
}

.public-section-heading {
  display: grid;
  gap: 6px;
}

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

.public-card {
  padding: 18px;
}

.public-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.public-card p,
.public-policy-panel p {
  margin: 0;
  color: #344054;
}

.public-policy-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.legal-shell {
  min-height: 100vh;
  padding: 32px clamp(16px, 4vw, 48px);
}

.legal-document {
  width: min(100%, 900px);
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 42px);
}

.legal-header {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.legal-section {
  display: grid;
  gap: 10px;
  padding: 22px 0;
}

.legal-section + .legal-section {
  border-top: 1px solid var(--border);
}

.legal-section p,
.legal-section ul {
  margin: 0;
}

.legal-section ul {
  display: grid;
  gap: 8px;
  padding-left: 22px;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 22px;
  font-weight: 800;
}

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

  .login-panel {
    padding: 20px;
  }

  .public-home {
    gap: 24px;
    padding: 16px;
  }

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

  .public-actions .button {
    width: 100%;
  }

  .legal-shell {
    padding: 16px;
  }
}
