/* SAGenAI-B server version. Colours come only from /theme.css (the Phase 8 palettes, light and dark). */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Liberation Sans", Arial, sans-serif; line-height: 1.45;
}
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1 { font-size: 1.55rem; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 4px; }
p { margin: 4px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
::selection { background: var(--selection-bg); color: var(--selection-text); }

/* Top bar with the tabs (the Windows tab order) */
.topbar {
  display: flex; align-items: stretch; gap: 24px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; padding: 12px 0; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tab {
  display: flex; align-items: center; padding: 0 14px; color: var(--muted); text-decoration: none;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--hover); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.page { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 20px; }
.page-header { margin-bottom: 14px; }

/* Status bar: the collector's dot, who is signed in, theme and sign-out */
.statusbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 6px 20px;
  background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .92rem;
}
.statusbar .spacer { flex: 1; }
.dot { font-size: 1rem; line-height: 1; }
.dot-green { color: var(--success); }
.dot-yellow { color: var(--warning); }
.dot-red { color: var(--danger); }
form.inline { display: inline; margin: 0; }

/* Buttons and links that look like buttons */
.button, button {
  font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; min-height: 32px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--button); color: var(--text);
  text-decoration: none; cursor: pointer;
}
.button:hover, button:hover { background: var(--button-hover); color: var(--text); }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-hover); color: #fff; }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--primary); text-decoration: underline; }
button.link:hover { color: var(--primary-hover); background: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Messages */
.notice { padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; border: 1px solid var(--notice-border);
  background: var(--notice-bg); color: var(--notice-text); }
.notice-warning, .notice-error { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn-text); }
.notice-error { border-left: 4px solid var(--danger); }

/* Cards, tiles, charts */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 0 0 16px; }
.card.narrow, .signin { max-width: 640px; }
.signin { margin: 40px auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 0 0 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.card .tile { background: var(--surface-2); }
.tile-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.tile-value.tile-text { font-size: 1.2rem; padding: 4px 0; }
.tone-good { color: var(--success); }
.tone-warn { color: var(--warning); }
.tone-bad { color: var(--danger); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 12px; margin: 0 0 16px;
  align-items: start; }
.chart-card { margin: 0; padding: 8px; }
.chart-card.wide { grid-column: 1 / -1; overflow-x: auto; }
.chart-card.wide svg.chart { min-width: 760px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { font-family: inherit; fill: var(--text); font-size: 12px; }
svg.chart .chart-title { font-size: 14px; font-weight: 600; }
svg.chart .chart-label, svg.chart .chart-value { fill: var(--text); }
svg.chart .chart-muted { fill: var(--muted); }
svg.chart .chart-grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .chart-gap { stroke: var(--surface); }

/* Filters and toolbars */
.filters, .toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; margin: 0 0 12px; }
.filters label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: .9rem; }
.custom-range { display: inline-flex; gap: 10px; align-items: end; }
select, input, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; min-height: 32px;
}
textarea { width: 100%; resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 8px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; overflow-x: auto; }

/* Tables */
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: var(--surface-3); font-weight: 600; white-space: nowrap; }
table.sortable th:not(.nosort) { cursor: pointer; user-select: none; }
table.sortable th[aria-sort="ascending"]::after { content: " \25B2"; font-size: .7em; }
table.sortable th[aria-sort="descending"]::after { content: " \25BC"; font-size: .7em; }
table.grid tbody tr:nth-child(even) { background: var(--alt-row); }
table.grid tbody tr:hover { background: var(--hover); }
tr.void td { color: var(--disabled-text); text-decoration: line-through; }
tr.void td.actions, tr.void td:nth-child(9) { text-decoration: none; }
td.actions a { margin-right: 10px; }
a.danger { color: var(--danger); }
td.details { max-width: 520px; overflow-wrap: anywhere; }
.sev { font-weight: 600; }
.sev-critical { color: var(--sev-critical); }
.sev-high { color: var(--sev-high); }
.sev-medium { color: var(--sev-medium); }
.sev-low { color: var(--sev-low); }

@media (max-width: 700px) {
  .topbar { flex-direction: column; gap: 0; padding: 0 12px; }
  .page { padding: 12px; }
  .charts { grid-template-columns: 1fr; }
}
