:root {
  --bg-1: #f4f7ff;
  --bg-2: #fff7f0;
  --card: rgba(255, 255, 255, 0.78);
  --border: rgba(6, 31, 54, 0.14);
  --text: #09223a;
  --muted: #4f6274;
  --accent: #0f8b8d;
  --accent-2: #fb8b24;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 18px 40px rgba(15, 33, 53, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Manrope, sans-serif;
  color: var(--text);
  background: linear-gradient(120deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 18px 44px;
  position: relative;
  z-index: 2;
}
.layout > section {
  margin: 0;
}
.layout > section + section {
  margin-top: 14px;
}

.bg-orb {
  position: fixed;
  border-radius: 9999px;
  filter: blur(70px);
  opacity: 0.45;
  z-index: 0;
  animation: drift 11s ease-in-out infinite alternate;
}
.bg-orb-a {
  width: 380px;
  height: 380px;
  left: -70px;
  top: -100px;
  background: #87e8de;
}
.bg-orb-b {
  width: 460px;
  height: 460px;
  right: -120px;
  bottom: -160px;
  background: #ffd2b0;
}

@keyframes drift {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(24px) scale(1.04); }
}

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

.top-nav {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.top-nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.top-nav form { margin: 0; }
.nav-link {
  text-decoration: none;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  background: rgba(255,255,255,0.7);
}
.nav-link.active {
  border-color: rgba(15, 139, 141, 0.45);
  background: rgba(15, 139, 141, 0.1);
}
.btn-secondary {
  background: linear-gradient(120deg, #4f6274, #2e3d4b);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.77rem;
}
h1 {
  margin: 4px 0 10px;
  font-family: Sora, sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}
.subtext { margin: 0; color: var(--muted); max-width: 760px; }

.hero-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.monitor-hero-actions {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.chip {
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.65);
}
.chip-ok { border-color: rgba(6, 118, 71, 0.35); background: rgba(228, 251, 240, 0.85); }
.chip-warn { border-color: rgba(251, 139, 36, 0.45); background: rgba(255, 243, 230, 0.85); }
.chip-error { border-color: rgba(180, 35, 24, 0.38); background: rgba(255, 235, 236, 0.9); }
.chip-off { opacity: 0.7; }

.toast {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid;
  backdrop-filter: blur(3px);
}
.toast-ok { color: var(--ok); border-color: rgba(6, 118, 71, 0.45); background: rgba(228, 251, 240, 0.85); }
.toast-error { color: var(--danger); border-color: rgba(180, 35, 24, 0.35); background: rgba(255, 235, 236, 0.9); }

.grid { display: grid; gap: 14px; align-items: stretch; }
.top-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tables-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manager-grid { grid-template-columns: 1fr; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
  padding: 16px;
}
.top-grid .card { min-height: 146px; }
.metric h3 { margin: 0 0 6px; font-size: 0.95rem; color: var(--muted); }
.metric-value { margin: 0; font-size: 2rem; font-family: Sora, sans-serif; }
.muted { color: var(--muted); font-size: 0.86rem; }

h2 { margin: 0 0 12px; font-family: Sora, sans-serif; font-size: 1.05rem; }

.stack { display: grid; gap: 9px; }
label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
input, select, textarea, button {
  border-radius: 11px;
  border: 1px solid var(--border);
  padding: 10px 11px;
  font: inherit;
}
textarea { min-height: 86px; resize: vertical; }
button {
  background: linear-gradient(120deg, #0f8b8d, #0ca678);
  color: #fff;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
button:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn-danger { background: linear-gradient(120deg, #fb8b24, #d9480f); }

.accent { background: linear-gradient(160deg, rgba(255,240,225,0.88), rgba(255,255,255,0.86)); }
.table-card { overflow: hidden; }
.table-header { margin-bottom: 12px; }

.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,0.7); }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid rgba(6,31,54,0.08); vertical-align: top; }
th { font-size: 0.84rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select, .inline-form input { min-width: 120px; }
.wide-form { margin-bottom: 12px; flex-wrap: wrap; }
.wide-form label { flex: 1 1 220px; }
.wide-form button { align-self: end; }
.compact-form { margin-top: 8px; flex-wrap: wrap; }
.tenant-switcher details { margin-top: 12px; }
.tenant-switcher summary { cursor: pointer; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.entity-list { margin-top: 10px; }
.entity-list summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}
.entity-list[open] summary { margin-bottom: 12px; }
.search {
  width: 100%;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.82);
}
.warning {
  border: 1px solid rgba(251, 139, 36, 0.45);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 244, 230, 0.85);
  color: #915200;
}
.bulk-onboard-form {
  margin-top: 8px;
}
.bulk-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
}
.bulk-pane {
  display: grid;
  gap: 10px;
  align-content: start;
}
.bulk-pane > span {
  color: var(--muted);
  font-size: 0.9rem;
}
.bulk-pane textarea {
  min-height: 130px;
}
.bulk-pane-controls {
  grid-template-rows: auto auto auto;
}
#bulk-new-group-wrap.is-hidden {
  display: none;
}

.prompt-manager-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}
.prompt-sidebar h2 {
  margin-bottom: 10px;
}
.prompt-list-wrap {
  max-height: 640px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.prompt-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  padding: 8px;
}
.prompt-link:hover {
  background: rgba(15, 139, 141, 0.08);
}
.prompt-link.active {
  background: rgba(15, 139, 141, 0.14);
}
.prompt-editor {
  min-width: 0;
}
.prompt-editor-textarea {
  min-height: 480px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.monitor-summary {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.monitor-small {
  font-size: 1.1rem;
  font-family: Manrope, sans-serif;
}
.monitor-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.monitor-run-btn {
  min-width: 190px;
  min-height: 96px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(15, 139, 141, 0.35);
  background: linear-gradient(120deg, #0f8b8d, #0ca678);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 14px 30px rgba(15, 139, 141, 0.3);
}
.monitor-run-btn:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
  filter: none;
  box-shadow: none;
}
.monitor-run-btn-secondary {
  background: linear-gradient(120deg, #4f6274, #2e3d4b);
}
.monitor-run-btn-heavy {
  background: linear-gradient(120deg, #fb8b24, #d9480f);
}
.monitor-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.monitor-green { color: #067647; }
.monitor-yellow { color: #8f6200; }
.monitor-red { color: #b42318; }
.monitor-table-wrap table td:first-child,
.monitor-table-wrap table th:first-child {
  position: sticky;
  left: 0;
  background: rgba(255,255,255,0.95);
}
.monitor-pill {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  margin-bottom: 3px;
}
.monitor-pill.monitor-green { background: rgba(6, 118, 71, 0.16); }
.monitor-pill.monitor-yellow { background: rgba(251, 139, 36, 0.2); }
.monitor-pill.monitor-red { background: rgba(180, 35, 24, 0.18); }
.monitor-pill.monitor-pending { background: rgba(79, 98, 116, 0.18); color: #4f6274; }
.monitor-pill-spinning {
  animation: monitor-spin 0.8s linear infinite;
}

@keyframes monitor-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.simple-list {
  margin: 8px 0 12px 18px;
  padding: 0;
}
code {
  background: rgba(8, 28, 48, 0.08);
  border-radius: 7px;
  padding: 3px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

@media (max-width: 1080px) {
  .top-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tables-grid { grid-template-columns: 1fr; }
  .bulk-grid { grid-template-columns: 1fr; }
  .prompt-manager-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .hero { flex-direction: column; }
  .top-grid, .cards-grid { grid-template-columns: 1fr; }
  .layout { padding: 16px 12px 32px; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
