/* House components. Depends on tokens.css. The app shell is the important
   part: it is what keeps a screen from collapsing back into a grid of cards. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--t-md) / var(--leading) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* shell: rail left, topbar across the content, content fills the rest.
   No page-level scroll. The content pane scrolls, the chrome stays put. */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
}

.rail {
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.rail-brand {
  padding: 0 var(--s-4);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: var(--t-lg);
  letter-spacing: var(--track-display);
}
.rail-group { padding: var(--s-4) var(--s-2) var(--s-1); }
.rail-group-label {
  padding: 0 var(--s-2) var(--s-2);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--fg-3);
}
.rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  padding: 6px var(--s-2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail-item:hover { background: var(--bg-3); color: var(--fg); }
.rail-item[aria-current='true'] {
  background: var(--bg);
  color: var(--fg);
  box-shadow: inset 2px 0 0 var(--accent);
}
.rail-foot {
  margin-top: auto;
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
  color: var(--fg-3);
  font-size: var(--t-xs);
}

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumb { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--fg-3); }
.crumb b { color: var(--fg); font-weight: 600; }
.topbar-spacer { margin-left: auto; }

.content { overflow: auto; padding: var(--s-5); min-height: 0; }
.content > * + * { margin-top: var(--s-6); }

/* section: a hairline and a label, not a bordered box */
.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-4);
}
.section-head h2 {
  margin: 0;
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
}
.section-head p { margin: 0; color: var(--fg-3); font-size: var(--t-sm); }

/* stat row: numbers on a rule, not in boxes */
.stats { display: flex; flex-wrap: wrap; gap: var(--s-7); }
.stat .v {
  font: 600 var(--t-2xl) / var(--leading-tight) var(--font-mono);
  letter-spacing: var(--track-display);
  font-variant-numeric: tabular-nums;
}
.stat .k {
  margin-top: var(--s-1);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--fg-3);
}

/* console table */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tbl th {
  position: sticky;
  top: 0;
  background: var(--bg);
  text-align: left;
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--fg-3);
  padding: var(--s-2);
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--fg); }
.tbl td { padding: 6px var(--s-2); border-bottom: 1px solid var(--border); }
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 60vh; }

/* status chip: a text label, never an emoji, never colour alone */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  font-weight: 500;
  white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.chip.ok   { color: var(--ok);   background: var(--ok-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.bad  { color: var(--bad);  background: var(--bad-soft); }
.chip.mute { color: var(--fg-3); background: var(--bg-3); }

/* run strip: one cell per run, the shape of a history at a glance */
.runs { display: flex; gap: 2px; align-items: flex-end; }
.runs i {
  display: block;
  width: 5px;
  height: 22px;
  border-radius: 1px;
  background: var(--bg-3);
  transition: transform var(--dur) var(--ease);
}
.runs i[data-state='success'] { background: var(--ok); }
.runs i[data-state='failed']  { background: var(--bad); }
.runs i[data-state='running'] { background: var(--accent); }
.runs i:hover { transform: scaleY(1.25); }

/* meter: a value inside a range */
.meter { position: relative; height: 18px; background: var(--bg-3); border-radius: var(--r-sm); }
.meter .span { position: absolute; top: 4px; height: 10px; border-radius: 1px; opacity: 0.5; }
.meter .tick { position: absolute; top: 0; width: 2px; height: 18px; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-md); overflow: hidden; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: var(--t-sm);
  padding: 5px var(--s-3);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button[aria-pressed='true'] { background: var(--bg-3); color: var(--fg); }

/* inputs */
.field, select.field {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 5px var(--s-2);
  font: inherit;
  font-size: var(--t-sm);
}
.field::placeholder { color: var(--fg-3); }

/* primary action: one per screen */
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: var(--r-md);
  padding: 6px var(--s-3);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
}

/* note: a caveat that belongs on screen, not hidden in a tooltip */
.note {
  border-left: 2px solid var(--warn);
  background: var(--bg-2);
  color: var(--fg-2);
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-sm);
}

/* empty state: say what is missing and why, never a shrug */
.empty { padding: var(--s-6); color: var(--fg-3); font-size: var(--t-sm); text-align: center; }

/* filter chips: what the current view is scoped to, each removable */
.filters { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.filters .f {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  background: var(--bg-2);
}
.filters .f button { border: 0; background: none; color: var(--fg-3); cursor: pointer; font: inherit; }
.filters .f button:hover { color: var(--fg); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

/* There is deliberately no fade-in-from-below load animation here. It is the
   default in every generated component set, which makes it a recognised slop
   tell: it signals "polished" while doing nothing for the user. Motion earns
   its place by explaining a state change, so it lives only on the components
   that change state. */
