:root {
  --ink: #12151a;
  --panel: #1a1e25;
  --panel-2: #20242c;
  --panel-3: #262b34;
  --line: #272c35;
  --line-soft: #1f232b;
  --paper: #e9ebef;
  --mute: #8b93a3;
  --mute-2: #5c6472;
  --signal: #ce7b3e;
  --signal-bright: #e2954f;
  --signal-bg: rgba(206, 123, 62, 0.14);
  --ok: #4ea97b;
  --ok-bg: rgba(78, 169, 123, 0.14);
  --warn: #e0b23c;
  --warn-bg: rgba(224, 178, 60, 0.14);
  --crit: #e1615a;
  --crit-bg: rgba(225, 97, 90, 0.14);
  --info: #5b93d6;
  --font-body: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--signal-bg); color: var(--paper); }
a { color: var(--signal-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font-family: inherit; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--signal-bright);
  outline-offset: 1px;
}
table { border-collapse: collapse; width: 100%; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
h1 { font-size: 21px; font-weight: 700; margin: 0 0 6px; text-wrap: balance; }
p.lede { color: var(--mute); font-size: 13px; margin: 0 0 18px; max-width: 65ch; }

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 212px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "rail topbar"
    "rail main";
  min-height: 100vh;
}

/* ---------- rail ---------- */
.rail {
  grid-area: rail;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 10px;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.rail-mark {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--signal);
  color: #1a1006;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
  margin: 0 0 18px 4px;
  letter-spacing: -0.02em;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px 4px;
}
.rail-brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--paper);
}
.rail-mark-logo {
  width: 34px; height: 34px;
  object-fit: contain;
  background: transparent;
  border: 0;
  margin: 0;
}
.rail-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute-2);
  padding: 12px 10px 5px;
}
.rail-group-label:first-of-type { padding-top: 0; }
.rail-item {
  height: 34px;
  border-radius: 6px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  color: var(--mute);
  background: transparent;
  border: none;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.rail-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.rail-item:hover { background: var(--panel-2); color: var(--paper); }
.rail-item.active { background: var(--signal-bg); color: var(--signal-bright); }
.rail-item.active::before {
  content: "";
  position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px;
  background: var(--signal); border-radius: 0 2px 2px 0;
}
.rail-spacer { flex: 1; }

/* ---------- topbar ---------- */
.topbar {
  grid-area: topbar;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: 0.01em; color: var(--paper); }
.brand-sub { font-size: 11.5px; color: var(--mute-2); }
.crumb { color: var(--mute); font-size: 12.5px; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.crumb b { color: var(--paper); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.env-chip {
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  color: var(--mute); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 9px;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.env-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--panel-3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: var(--paper);
  flex-shrink: 0;
}

/* ---------- main ---------- */
.main {
  grid-area: main;
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* health strip */
.health-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.health-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 13px;
}
.health-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.health-name { font-size: 13px; font-weight: 600; }
.health-detail { font-size: 11.5px; color: var(--mute); margin-bottom: 10px; min-height: 2.6em; }
.health-links { display: flex; gap: 8px; }

/* pills */
.pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 4px; padding: 2.5px 6px;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.ok::before { background: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.warn::before { background: var(--warn); }
.pill.crit { background: var(--crit-bg); color: var(--crit); }
.pill.crit::before { background: var(--crit); }

/* neutral label chip — no semantic dot, for values like a lead's freeform status */
.chip {
  font-size: 10.5px; font-weight: 600;
  border-radius: 4px; padding: 2.5px 7px;
  color: var(--mute); background: var(--panel-2);
  border: 1px solid var(--line);
  display: inline-block;
  white-space: nowrap;
}

/* panel / card container for page content */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}
.panel-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.panel-body { padding: 0; }
.panel-body.padded { padding: 16px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 10.5px; color: var(--mute-2); letter-spacing: 0.04em; text-transform: uppercase; }
.field select, .field input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--paper);
  font-size: 12.5px;
  padding: 6px 9px;
  height: 30px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.field.date input { width: 150px; }
.field.num input { width: 68px; }
.spacer-grow { flex: 1; }

/* buttons */
.btn {
  height: 30px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--paper);
  font-size: 12.5px; font-weight: 600; padding: 0 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn:hover { background: var(--panel-3); text-decoration: none; }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #1a1006; }
.btn.primary:hover { background: var(--signal-bright); }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #1a0807; }
.btn.danger:hover { background: #ea7a73; }

/* search box */
.search-input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--paper);
  font-size: 12.5px;
  height: 30px;
  padding: 0 9px;
  min-width: 240px;
}
.search-input::placeholder { color: var(--mute-2); }
.search-input:focus { outline: none; border-color: var(--signal); }

/* tables */
.grid-wrap { overflow-x: auto; }
.data-table th {
  text-align: left;
  font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--mute-2); font-weight: 600;
  padding: 9px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 16px; border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px; white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--panel-2); }
.data-table td.num { text-align: right; }

/* Wide tables that must fit the viewport without horizontal scroll: let text columns
   wrap instead of forcing the table past the container width. */
.fit-table { width: 100%; table-layout: auto; }
.fit-table th, .fit-table td { white-space: normal; }
.fit-table td.mono, .fit-table td .mono { word-break: break-word; }
.fit-table td.num, .fit-table td.tnum { white-space: nowrap; }
.fit-table .row-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.cell-primary { font-weight: 600; }
.cell-sub { color: var(--mute); font-size: 11px; }
.corr-id { color: var(--mute-2); }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; color: var(--mute); font-size: 11.5px;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar .mono { color: var(--mute-2); }

/* feedback */
.callout {
  border-radius: 7px;
  padding: 12px 14px;
  font-size: 13px;
  border: 1px solid var(--line);
}
.callout h5 { margin: 0 0 6px; font-size: 13.5px; }
.callout p { margin: 0 0 6px; }
.callout ol { margin: 8px 0 0; padding-left: 20px; }
.callout.crit { background: var(--crit-bg); border-color: rgba(225,97,90,0.35); color: var(--paper); }
.callout.crit h5 { color: var(--crit); }
.callout.info { background: rgba(91,147,214,0.1); border-color: rgba(91,147,214,0.3); }
.callout.ok { background: var(--ok-bg); border-color: rgba(78,169,123,0.35); }
.callout.ok h5 { color: var(--ok); }
.callout code { font-family: var(--font-mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 3px; }

.empty-state { padding: 32px 16px; text-align: center; color: var(--mute); font-size: 13px; }

/* stats row */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
}
.stat-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--mute-2);
  margin-bottom: 6px;
}
.stat-value { font-size: 22px; font-weight: 700; color: var(--paper); }
.stat-value.tnum { font-variant-numeric: tabular-nums; }
