/* Sestante theme: built on Open Props tokens, brand orange, dark + light modes. */

/* Palette: cool near-black dark mode (default), warm off-white light mode. */
:root {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1b232d;
  --surface-3: #232b36;
  --border: #232b36;
  --border-strong: #2f3a47;
  --text: #e6e8eb;
  --text-muted: #8b949e;
  --text-faint: #5f6873;
  --dot: rgba(139, 148, 158, 0.16);

  --brand: #ff6a1f;
  --brand-hover: #ff8a4c;
  --on-brand: #0d1117;
  --brand-soft: color-mix(in oklab, var(--brand) 16%, transparent);
  --accent: #39ffc4;
  --accent-soft: color-mix(in oklab, var(--accent) 16%, transparent);
  --accent-glow: 0 0 0 3px color-mix(in oklab, var(--accent) 28%, transparent);

  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --info: #58a6ff;

  --sev-critical: #f85149;
  --sev-high: #ff6a1f;
  --sev-medium: #d29922;
  --sev-low: #58a6ff;
  --sev-info: #8b949e;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --sidebar-w: 248px;
  --topbar-h: 56px;
  --radius: 5px;
  --radius-lg: 8px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --surface-3: #e8e8e4;
  --border: #e2e2df;
  --border-strong: #cfcfca;
  --text: #1a1d21;
  --text-muted: #5c6068;
  --text-faint: #8a8f97;
  --dot: rgba(26, 29, 33, 0.09);

  --brand: #e85d0d;
  --brand-hover: #c94f0a;
  --on-brand: #ffffff;
  --brand-soft: color-mix(in oklab, var(--brand) 12%, transparent);
  --accent: #0f9d78;
  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  --accent-glow: 0 0 0 3px color-mix(in oklab, var(--accent) 24%, transparent);

  --ok: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --info: #0969da;

  --sev-critical: #cf222e;
  --sev-high: #e85d0d;
  --sev-medium: #9a6700;
  --sev-low: #0969da;
  --sev-info: #6e7781;

  color-scheme: light;
}

/* --- Base ------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: var(--font-size-1);
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-hover);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--font-size-5);
}

h2 {
  font-size: var(--font-size-3);
}

h3 {
  font-size: var(--font-size-2);
}

p {
  margin: 0;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.muted {
  color: var(--text-muted);
}

.faint {
  color: var(--text-faint);
}

.small {
  font-size: var(--font-size-0);
}

.prompt::before {
  content: "> ";
  color: var(--brand);
  font-family: var(--font-mono);
  font-weight: 700;
}

.cursor::after {
  content: "_";
  color: var(--accent);
  animation: var(--animation-blink);
  font-family: var(--font-mono);
}

/* --- App layout ------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  padding: 0 var(--size-4);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  --logo-size: 30px;
}

.logo-icon {
  height: var(--logo-size);
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px color-mix(in oklab, var(--accent) 35%, transparent));
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: calc(var(--logo-size) * 0.62);
  letter-spacing: 0.08em;
  line-height: 1;
}

.wordmark::after {
  content: "_";
  color: var(--accent);
  animation: var(--animation-blink);
}

.logo--lg {
  --logo-size: 64px;
  flex-direction: column;
  gap: var(--size-3);
}

.logo--lg .wordmark {
  font-size: 26px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  display: inline-block;
  flex-shrink: 0;
}

.sidebar__tenant {
  padding: var(--size-3) var(--size-4);
  border-bottom: 1px solid var(--border);
}

.sidebar__tenant .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sidebar__tenant .name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-2);
  font-weight: 600;
}

.sidebar__nav {
  flex: 1;
  padding: var(--size-3) var(--size-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__section {
  padding: var(--size-3) var(--size-3) var(--size-1);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  padding: var(--size-2) var(--size-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.15s var(--ease-2), color 0.15s var(--ease-2);
}

.nav-link i {
  font-size: 18px;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-left-color: var(--brand);
}

.sidebar__footer {
  padding: var(--size-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  min-width: 0;
}

.user-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-round);
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.user-chip .meta {
  min-width: 0;
  line-height: 1.2;
}

.user-chip .meta strong {
  display: block;
  font-size: var(--font-size-0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip .meta span {
  font-size: 11px;
  color: var(--text-faint);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-3);
  padding: 0 var(--size-6);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  font-family: var(--font-mono);
  font-size: var(--font-size-1);
}

.topbar__title .crumb {
  color: var(--text-faint);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.content {
  padding: var(--size-6);
  display: flex;
  flex-direction: column;
  gap: var(--size-5);
  flex: 1;
}

.footer {
  padding: var(--size-3) var(--size-6);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--size-4);
  flex-wrap: wrap;
}

.page-head p {
  color: var(--text-muted);
  margin-top: var(--size-1);
}

/* --- Centered (auth) layout ------------------------------------------ */

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--size-5);
}

.auth-card {
  width: min(100%, 420px);
}

.auth-card .logo {
  display: block;
  height: 64px;
  margin: 0 auto var(--size-4);
}

.tenant-grid {
  width: min(100%, 880px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--size-4);
}

.tenant-card {
  display: flex;
  flex-direction: column;
  gap: var(--size-3);
  padding: var(--size-4);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s var(--ease-2), border-color 0.15s var(--ease-2);
}

.tenant-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px color-mix(in oklab, var(--accent) 20%, transparent);
}

.tenant-card .icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 22px;
}

/* --- Components ------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.accent-line {
  position: relative;
}

.accent-line::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-3);
  padding: var(--size-3) var(--size-4);
  border-bottom: 1px solid var(--border);
}

.card__head h3 {
  font-size: var(--font-size-1);
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.card__body {
  padding: var(--size-4);
}

.card__body--flush {
  padding: 0;
}

.grid {
  display: grid;
  gap: var(--size-4);
}

.grid--kpi {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.grid--2 {
  grid-template-columns: 1fr 1fr;
}

.grid--3-2 {
  grid-template-columns: 3fr 2fr;
}

@media (max-width: 1100px) {
  .grid--2,
  .grid--3-2 {
    grid-template-columns: 1fr;
  }
}

.kpi {
  padding: var(--size-4);
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
  position: relative;
  overflow: hidden;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: var(--kpi-accent, var(--brand));
  box-shadow: 0 0 10px var(--kpi-accent, var(--brand));
}

.kpi .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.kpi .value {
  font-family: var(--font-mono);
  font-size: var(--font-size-6);
  font-weight: 700;
  line-height: 1;
  color: var(--kpi-accent, var(--text));
}

.kpi .hint {
  font-size: var(--font-size-0);
  color: var(--text-faint);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--size-2);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: var(--font-size-0);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s var(--ease-2), border-color 0.15s var(--ease-2);
}

.btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  color: var(--on-brand);
  box-shadow: 0 0 14px color-mix(in oklab, var(--brand) 45%, transparent);
}

.btn:focus-visible,
.nav-link:focus-visible {
  outline: none;
  box-shadow: var(--accent-glow);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
}

.btn--danger {
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 40%, transparent);
}

.btn--danger:hover {
  background: color-mix(in oklab, var(--danger) 12%, transparent);
}

.btn--sm {
  padding: 0.3rem 0.6rem;
  font-size: 12px;
}

.btn--icon {
  padding: 0.4rem;
  width: 34px;
  height: 34px;
}

.btn--block {
  width: 100%;
}

.btn i {
  font-size: 16px;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-round);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  color: var(--badge-color, var(--text-muted));
  background: color-mix(in oklab, var(--badge-color, var(--text-muted)) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--badge-color, var(--text-muted)) 35%, transparent);
}

.badge--critical {
  --badge-color: var(--sev-critical);
}

.badge--high {
  --badge-color: var(--sev-high);
}

.badge--medium {
  --badge-color: var(--sev-medium);
}

.badge--low {
  --badge-color: var(--sev-low);
}

.badge--info {
  --badge-color: var(--sev-info);
}

.badge--ok {
  --badge-color: var(--ok);
}

.badge--neutral {
  --badge-color: var(--text-faint);
}

.badge--brand {
  --badge-color: var(--brand);
}

.badge--accent {
  --badge-color: var(--accent);
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--risk-color, var(--text));
}

.risk-pill .bar {
  width: 48px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.risk-pill .bar span {
  display: block;
  height: 100%;
  background: var(--risk-color, var(--brand));
}

.risk-critical {
  --risk-color: var(--accent);
}

.risk-high {
  --risk-color: var(--sev-high);
}

.risk-medium {
  --risk-color: var(--sev-medium);
}

.risk-low {
  --risk-color: var(--sev-low);
}

.flag {
  color: var(--text-faint);
  font-size: 16px;
}

.flag--on {
  color: var(--brand);
}

.flags {
  display: inline-flex;
  gap: 4px;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-0);
}

.table th {
  text-align: left;
  padding: var(--size-2) var(--size-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.table th a:hover,
.table th a.sorted {
  color: var(--brand);
}

.table td {
  padding: var(--size-2) var(--size-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tr.clickable {
  cursor: pointer;
}

.table .title {
  font-weight: 500;
}

.table .sub {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.table td.num,
.table th.num {
  text-align: right;
  font-family: var(--font-mono);
}

.table .empty {
  text-align: center;
  padding: var(--size-8);
  color: var(--text-faint);
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--size-1);
}

.field label {
  font-size: var(--font-size-0);
  font-weight: 500;
}

.field .help {
  font-size: 12px;
  color: var(--text-faint);
}

.field .error {
  font-size: 12px;
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--font-size-0);
  transition: border-color 0.15s var(--ease-2), box-shadow 0.15s var(--ease-2);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}

.select--sm {
  padding: 0.25rem 0.5rem;
  font-size: 12px;
  width: auto;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  font-size: var(--font-size-0);
}

.checkbox input {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--size-1);
}

.checklist li {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  font-size: var(--font-size-0);
}

.checklist input {
  accent-color: var(--brand);
}

.form-grid {
  display: grid;
  gap: var(--size-3);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--size-2);
  margin-top: var(--size-2);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--size-2);
}

.filters .input {
  width: 260px;
}

.filters .select {
  width: auto;
}

/* Flash messages */

.flashes {
  display: flex;
  flex-direction: column;
  gap: var(--size-2);
}

.alert {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  padding: var(--size-2) var(--size-3);
  border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--alert-color) 40%, transparent);
  background: color-mix(in oklab, var(--alert-color) 12%, transparent);
  color: var(--text);
  font-size: var(--font-size-0);
}

.alert i {
  color: var(--alert-color);
  font-size: 18px;
}

.alert--success {
  --alert-color: var(--ok);
}

.alert--danger {
  --alert-color: var(--danger);
}

.alert--warning {
  --alert-color: var(--warn);
}

.alert--info {
  --alert-color: var(--info);
}

/* Drawer + modal */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 560px);
  z-index: 40;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s var(--ease-3);
}

.drawer.open {
  transform: translateX(0);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(13, 17, 23, 0.6);
  backdrop-filter: blur(2px);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--size-4);
}

.modal .backdrop {
  position: absolute;
  z-index: 0;
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: 90vh;
  overflow-y: auto;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--size-3);
  padding: var(--size-4);
  border-bottom: 1px solid var(--border);
}

.detail-body {
  padding: var(--size-4);
  display: flex;
  flex-direction: column;
  gap: var(--size-4);
}

.dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--size-3);
  margin: 0;
}

.dl div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dl dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dl dd {
  margin: 0;
  font-size: var(--font-size-0);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-3);
  padding: var(--size-3) var(--size-4);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-0);
  color: var(--text-muted);
}

.pagination .pages {
  display: flex;
  gap: var(--size-1);
}

/* Prioritization bands */

.band {
  border-left: 3px solid var(--band-color);
}

.band--critical {
  --band-color: var(--accent);
}

.band--high {
  --band-color: var(--sev-high);
}

.band--medium {
  --band-color: var(--sev-medium);
}

.band--low {
  --band-color: var(--sev-low);
}

.band .count {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--band-color);
}

.formula {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: var(--size-3);
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.7;
}

.asset-bar {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  align-items: center;
  gap: var(--size-3);
  font-size: var(--font-size-0);
}

.asset-bar .track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.asset-bar .track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--sev-critical));
}

/* Import placeholder */

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--size-8);
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--size-2);
}

.dropzone i {
  font-size: 40px;
  color: var(--brand);
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--size-3);
}

.source-card {
  padding: var(--size-3) var(--size-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-2);
}

.source-card strong {
  text-transform: capitalize;
}

/* Charts */

.chart-box {
  position: relative;
  height: 260px;
}

/* Utilities */

.row {
  display: flex;
  align-items: center;
  gap: var(--size-2);
}

.row--between {
  justify-content: space-between;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--size-3);
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

.spin {
  animation: var(--animation-spin);
}

[x-cloak] {
  display: none !important;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar__nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar__section {
    display: none;
  }

  .content,
  .topbar {
    padding-inline: var(--size-4);
  }
}


/* --- Phase 2 additions: nav badges, dropdowns, timelines, empty states, factor bars --- */

.nav-link span:first-of-type {
  flex: 1;
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-round);
  background: var(--brand);
  color: var(--on-brand);
}

.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 280px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.dropdown__list {
  list-style: none;
  margin: 0;
  padding: var(--size-2) var(--size-3);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 4px;
  font-size: var(--font-size-0);
}

.empty-state {
  text-align: center;
  padding: var(--size-8);
  color: var(--text-faint);
}

.empty-state i {
  font-size: 40px;
  display: block;
  margin-bottom: var(--size-2);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--size-3);
}

.timeline li {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: var(--size-3);
  font-size: var(--font-size-0);
}

.timeline .dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.timeline .dot--system {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.timeline .when {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.factor {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: var(--size-2);
  font-size: var(--font-size-0);
}

.factor .track {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.factor .track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--brand));
}

.progress {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
  min-width: 80px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.tabs {
  display: flex;
  gap: var(--size-1);
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: var(--size-2) var(--size-3);
  color: var(--text-muted);
  font-size: var(--font-size-0);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--size-1) var(--size-4);
  font-size: var(--font-size-0);
}

.kv dt {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 3px;
}

.kv dd {
  margin: 0;
}

pre.raw {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--size-3);
  max-height: 360px;
  overflow: auto;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--size-2);
}

.select--inline {
  width: auto;
  display: inline-block;
}

.table .checkbox-cell {
  width: 32px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--size-2);
  flex-wrap: wrap;
  padding: var(--size-2) var(--size-4);
  border-bottom: 1px solid var(--border);
  background: var(--brand-soft);
}
