:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6fb;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: #4f46e5; }
button, input, select, textarea { font: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px max(24px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid #dbe2ef;
  background: #fff;
}

.brand {
  color: #4338ca;
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.public-shell, .auth-card {
  width: min(680px, calc(100% - 32px));
  margin: 12vh auto;
  padding: 32px;
  border: 1px solid #dbe2ef;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(30, 41, 59, .08);
}

.public-shell h1 { font-size: clamp(32px, 6vw, 56px); }
.public-shell p { color: #526078; font-size: 18px; line-height: 1.7; }
.public-links { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 28px; }

.dashboard-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 32px auto 80px;
}

.dashboard-heading, .panel-heading, .record-actions, .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-card form, .inline-form { display: grid; gap: 12px; }
.auth-card label, .inline-form label { display: grid; gap: 6px; font-weight: 650; }

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #b9c4d6;
  border-radius: 8px;
  background: #fff;
  color: #172033;
}

.button {
  width: fit-content;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.button.primary { background: #4f46e5; color: #fff; }
.button.secondary { border-color: #cbd5e1; background: #fff; color: #26334a; }
.button.danger { border-color: #fecaca; color: #991b1b; }
.button:disabled { cursor: wait; opacity: .6; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 24px 0;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid #dbe2ef;
  border-radius: 10px;
  background: #fff;
}
.tabs button {
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button.active { background: #eef2ff; color: #3730a3; font-weight: 750; }

.panel {
  padding: 24px;
  border: 1px solid #dbe2ef;
  border-radius: 12px;
  background: #fff;
}
.pending-approvals {
  margin: 18px 0 26px;
  padding: 18px;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  background: #fffbeb;
}
.pending-approvals h3 { margin-top: 0; }
.count-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  vertical-align: middle;
}
.inline-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 18px 0 24px;
  padding: 18px;
  border-radius: 10px;
  background: #f8fafc;
}
.inline-form .button { align-self: end; }
.rule-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
  padding: 18px;
  border-radius: 10px;
  background: #f8fafc;
}
.rule-form label { display: grid; gap: 6px; font-weight: 650; }
.rule-form .wide-field { grid-column: 1 / -1; }
.check-label { grid-template-columns: auto 1fr !important; align-items: center; align-self: end; min-height: 42px; }
.check-label input { width: auto; min-height: 0; }
.publish-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 18px 0; }
.impact-box { margin: 12px 0 22px; padding: 16px; border: 1px solid #f59e0b; border-radius: 9px; background: #fffbeb; }
.rule-builder-section { border: 1px solid #d7dee8; border-radius: 9px; padding: 14px; }
.rule-builder-section legend { padding: 0 6px; font-weight: 750; }
.builder-list { display: grid; gap: 10px; margin: 10px 0; }
.builder-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; align-items: end; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; }
.builder-row label { font-size: .92rem; }
.builder-row .builder-wide { grid-column: 1 / -1; }
.builder-remove { justify-self: start; }
.scenario-lines { display: grid; gap: 8px; grid-column: 1 / -1; }
.code-meta { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.record-list { display: grid; gap: 10px; margin-top: 18px; }
.record {
  padding: 16px;
  border: 1px solid #dbe2ef;
  border-radius: 9px;
}
.record h3 { margin: 0 0 5px; overflow-wrap: anywhere; }
.meta, .empty { margin: 4px 0; color: #64748b; overflow-wrap: anywhere; }
.record-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 12px; }
.record-actions select { width: auto; }

.secret-box {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  background: #fffbeb;
}
.message { min-height: 24px; padding: 8px 0; }
.message.error { color: #991b1b; font-weight: 650; }
.message.success { color: #166534; font-weight: 650; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .dashboard-heading, .panel-heading { align-items: flex-start; }
  .dashboard-heading { flex-direction: column; }
  .panel { padding: 16px; }
  .public-shell, .auth-card { margin-top: 32px; padding: 22px; }
}
