:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --line: #dce3e8;
  --text: #17212b;
  --muted: #637181;
  --teal: #167c80;
  --amber: #b7791f;
  --red: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; overflow-x: hidden; font: 14px/1.45 "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #edf7f7 0%, #f5f7f9 55%, #eef2f5 100%); }
.login-panel { width: 100%; max-width: 390px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: 0 18px 48px rgba(20, 42, 50, .12); }
.login-brand { color: var(--text); margin-bottom: 22px; }
.login-brand small { color: var(--muted); }
.login-form { display: grid; gap: 13px; }
.form-message, .inline-message { min-height: 20px; margin: 0; color: #247a4d; font-size: 12px; font-weight: 700; }
.form-message.error, .inline-message.error { color: var(--red); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { background: #17212b; color: #fff; padding: 22px 18px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--teal); font-weight: 700; }
.brand small { display: block; color: #9fb2c3; }
nav { display: grid; gap: 4px; }
nav a { color: #c9d5df; text-decoration: none; padding: 10px 12px; border-radius: 6px; }
nav a.active, nav a:hover { background: #243342; color: #fff; }
.workspace { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; color: var(--teal); font-weight: 700; text-transform: uppercase; font-size: 11px; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
.user-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 12px; }
.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metrics-grid article, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.metrics-grid article { padding: 14px; }
.metrics-grid span { display: block; color: var(--muted); font-size: 12px; }
.metrics-grid strong { display: block; margin-top: 6px; font-size: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.panel { padding: 16px; overflow: hidden; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.panel-title.tight { align-items: flex-start; }
.panel-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; min-width: 0; }
.panel-actions input { width: 220px; }
.panel-actions select { width: 140px; }
button { border: 0; border-radius: 6px; background: var(--teal); color: #fff; padding: 9px 12px; font-weight: 700; cursor: pointer; }
button:disabled { opacity: .58; cursor: not-allowed; }
button.secondary { background: #e8f2f3; color: var(--teal); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.small { padding: 6px 8px; font-size: 12px; }
button.danger { background: var(--red); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; }
.actions-cell { display: flex; gap: 6px; }
.selected-row { background: #eef8f8; }
.empty-row { color: var(--muted); text-align: center; }
.badge { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.pending { color: #7a4b00; background: #fff3d6; }
.ok { color: #14532d; background: #dcfce7; }
.danger-badge { color: #7f1d1d; background: #fee2e2; }
.compact { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; color: var(--text); background: #fff; font: inherit; }
textarea { min-height: 76px; resize: vertical; }
.code { font-family: Consolas, monospace; }
.detail-panel { margin-top: 18px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.detail-grid .wide { grid-column: 1 / -1; }
.detail-grid input, .detail-grid textarea { font-family: Consolas, "Segoe UI", Arial, sans-serif; overflow: hidden; text-overflow: ellipsis; }
.detail-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.monitor-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 18px; align-items: start; }
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll table { min-width: 720px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .auth-shell { padding: 16px; }
  .login-panel { width: calc(100vw - 64px); max-width: 360px; justify-self: center; padding: 20px; }
  .workspace { padding: 16px; }
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  nav { grid-template-columns: 1fr 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }
  .panel-title { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; justify-content: stretch; }
  .panel-actions input, .panel-actions select { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-actions { justify-content: stretch; flex-direction: column; }
}
