:root {
  --bg: #f3f6f8;
  --paper: #ffffff;
  --ink: #17202a;
  --muted: #5d6b78;
  --line: #e4eaee;
  --teal: #128f82;
  --teal-2: #0c6e64;
  --teal-soft: #e7f6f3;
  --sand: #c4a574;
  --danger: #c44536;
  --danger-soft: #fdecea;
  --ok: #2f9e6b;
  --ok-soft: #e7f7ee;
  --warn: #c4891a;
  --warn-soft: #fff4de;
  --sidebar: #ffffff;
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.06);
  --sans: "Segoe UI", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }
.app { min-height: 100vh; }
.boot { padding: 48px; color: var(--muted); }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(320px, 0.95fr);
  background: linear-gradient(180deg, #f7fbfb 0%, var(--bg) 100%);
}
.auth-brand, .auth-panel { padding: 48px 44px; }
.auth-brand {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mark { width: 48px; height: 48px; }
.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--teal);
  font-weight: 700;
  margin: 24px 0 10px;
}
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 36px; line-height: 1.15; letter-spacing: -0.03em; }
.lede { color: var(--muted); max-width: 42ch; line-height: 1.55; margin-top: 14px; }
.legal { color: var(--muted); font-size: 13px; line-height: 1.5; }
.ghl-note {
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  max-width: 46ch;
  line-height: 1.5;
  border-radius: 12px;
}

.auth-panel { display: grid; place-items: center; }
.card {
  width: min(420px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
  border-radius: 16px;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  background: #fff;
  color: var(--ink);
  border: 1px solid #cfd8de;
  padding: 11px 12px;
  outline: none;
  border-radius: 10px;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(18, 143, 130, 0.12); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  padding: 10px 14px;
  background: var(--teal);
  color: white;
  font-weight: 650;
  border-radius: 10px;
}
.btn:hover { background: var(--teal-2); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 0; }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.stack { display: flex; gap: 8px; flex-wrap: wrap; }
.flash { margin-top: 14px; color: var(--danger); min-height: 1.2em; }
.flash.ok, .ok { color: var(--ok); }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.rail {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 10px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 8px;
  font-weight: 800;
  letter-spacing: -0.03em;
  flex: none;
}
.brand .wordmark { white-space: nowrap; }
.brand .wordmark span { color: var(--teal); }
.rail-scroll { flex: 1; overflow: auto; min-height: 0; }
.rail .group { color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding: 10px 12px 4px; }
.rail nav { display: grid; gap: 1px; overflow: visible; }
.rail button {
  text-align: left;
  background: transparent;
  color: #3d4b57;
  border: 0;
  padding: 7px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.rail button svg { width: 16px; height: 16px; flex: none; }
.rail button.active, .rail button:hover { background: var(--teal-soft); color: var(--teal-2); }
.rail .who {
  margin-top: 8px;
  padding: 12px 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  flex: none;
}
.main { padding: 28px 32px 72px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.topbar h1 { font-size: 28px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 280px;
}
.search input { border: 0; padding: 0; box-shadow: none; }
.tabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
}
.tabs button.active { background: var(--teal-soft); color: var(--teal-2); font-weight: 700; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.stat, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 28px; font-weight: 800; margin-top: 8px; letter-spacing: -0.03em; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 6px; }
.split { display: grid; grid-template-columns: 1.4fr 0.9fr; gap: 14px; }
.banner {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  color: #3d4b57;
  line-height: 1.5;
}
.banner.ok { background: var(--ok-soft); border-color: #cfe9da; }
.banner.warn { background: var(--warn-soft); }
.banner.hipaa { background: #f4f8fb; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.hash { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: #eef2f5;
  color: #3d4b57;
}
.pill.active, .pill.verified, .pill.clear, .pill.signed, .pill.validated { background: var(--ok-soft); color: var(--ok); }
.pill.pending, .pill.not_connected, .pill.not_run, .pill.not_sent, .pill.unvalidated, .pill.mx_ok { background: var(--warn-soft); color: var(--warn); }
.pill.deactivated, .pill.rejected, .pill.hit, .pill.disabled { background: var(--danger-soft); color: var(--danger); }
form.inline { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; margin: 12px 0 8px; }
form.inline .full { grid-column: 1 / -1; }
.hidden { display: none !important; }
.waiting { max-width: 560px; margin: 12vh auto; padding: 28px; }
.bars { display: grid; gap: 12px; margin-top: 18px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: #eef2f5; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--teal); width: 0; }
.chart { width: 100%; height: 180px; }
.muted { color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.detail-grid div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-grid .k { font-size: 12px; color: var(--muted); }
.detail-grid .v { margin-top: 4px; font-weight: 650; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 42, 0.35);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}
.modal {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 1100px) {
  .kpis, .split, .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .auth-shell, .shell { grid-template-columns: 1fr; }
  .rail { height: auto; position: static; overflow: visible; }
  .rail-scroll { overflow: visible; flex: none; }
  .kpis, .split, .detail-grid { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; }
  .main, .auth-brand, .auth-panel { padding: 20px; }
  h1 { font-size: 28px; }
}
