/* SqueekVision: dark, dependency-free dashboard styles. */

:root {
  /* Primitives: ramps named by hue */
  --ink-950: #0b0e12;
  --ink-900: #12161c;
  --ink-800: #1b2129;
  --ink-700: #2a323d;
  --ink-400: #8d99a8;
  --ink-100: #e6ebf1;
  --amber-400: #f4b740;
  --amber-950: #1c1404;
  --sky-300: #8ec5ff;
  --green-400: #4ade80;
  --red-400: #f87171;

  /* Semantic roles */
  --color-page: var(--ink-950);
  --color-surface: var(--ink-900);
  --color-raised: var(--ink-800);
  --color-border: var(--ink-700);
  --color-text: var(--ink-100);
  --color-text-muted: var(--ink-400);
  --color-action: var(--amber-400);
  --color-on-action: var(--amber-950);
  --color-link: var(--sky-300);
  --color-positive: var(--green-400);
  --color-negative: var(--red-400);
  --color-focus: var(--sky-300);

  /* Type scale: five sizes */
  --text-sm: 0.8125rem;  /* 13px meta, labels, table */
  --text-md: 0.9375rem;  /* 15px body, controls */
  --text-lg: 1.125rem;   /* 18px section titles, metric values */
  --text-xl: 1.5rem;     /* 24px page title */
  --text-2xl: 2rem;      /* 32px headline figure */

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Spacing: 4px base */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --page-max: 72rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, dl, dd, figure, ol, ul { margin: 0; }
h1, h2, h3 { line-height: 1.25; font-weight: 600; text-wrap: balance; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }

a { color: var(--color-link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  inset-block-start: var(--space-2);
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--color-raised);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* Header */
.top {
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark { width: 2.25rem; height: 2.25rem; flex: none; color: var(--color-action); }
.lede { color: var(--color-text-muted); }

.refresh-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

.meta {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.refresh-bar .meta { flex-basis: 100%; }

.btn {
  min-height: 2.75rem;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
}
.btn-primary {
  background: var(--color-action);
  color: var(--color-on-action);
  border: 0;
}
.btn-primary:hover { background: #f7c561; }
.btn-primary:active { transform: scale(0.97); }
.btn[aria-busy="true"] { cursor: progress; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  cursor: pointer;
}
.toggle input {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--color-action);
  cursor: pointer;
}

/* Layout grid */
.grid {
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-2) var(--space-4) var(--space-6);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}
.grid:focus { outline: none; }

@media (min-width: 46rem) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid > .card:first-child { grid-column: 1 / -1; }
  .refresh-bar .meta { flex-basis: auto; }
}

@media (min-width: 68rem) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid > .card:first-child { grid-column: auto; }
  .top { padding-block-start: var(--space-5); }
}

.span-all { grid-column: 1 / -1; }

/* Cards: border for structure, no shadow */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card-head-wrap { flex-wrap: wrap; }

.note { color: var(--color-text-muted); font-size: var(--text-sm); max-width: 65ch; }
.note:empty { display: none; }
.note[data-tone="negative"] { color: var(--color-negative); }

/* Status badge: dot + word, never colour alone */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--color-raised);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.badge .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--color-text-muted);
}
.badge[data-tone="positive"] .dot { background: var(--color-positive); }
.badge[data-tone="warning"] .dot { background: var(--color-action); }
.badge[data-tone="negative"] .dot { background: var(--color-negative); }

/* Wheel */
.wheel-body { display: flex; align-items: center; gap: var(--space-4); }
.wheel-icon {
  width: 4rem;
  height: 4rem;
  flex: none;
  color: var(--color-text-muted);
}
.wheel-icon[data-running="true"] {
  color: var(--color-action);
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metrics {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: var(--space-3);
}
.metrics dt, .facts dt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.metrics dd {
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Facts */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: var(--space-3);
}
.facts dd {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.facts-lg dd { font-size: var(--text-lg); }
.facts-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 46rem) {
  .facts-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Block progress */
.figure {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.progress {
  position: relative;
  height: 0.875rem;
  border-radius: 999px;
  background: var(--color-raised);
  overflow: hidden;
}
.progress-thin { height: 0.5rem; }
.progress-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background-color: var(--color-action);
  background-image: repeating-linear-gradient(
    -45deg,
    rgb(255 255 255 / 0.22) 0 0.5rem,
    transparent 0.5rem 1rem
  );
  background-size: 1.414rem 1.414rem;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 900ms var(--ease-out);
  animation: stripes 1s linear infinite;
}
.progress-still { background-image: none; animation: none; }
.progress[data-idle="true"] .progress-fill { animation: none; }
@keyframes stripes { to { background-position: 1.414rem 0; } }

/* Tabs */
.tabs {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-page);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.tab {
  min-width: 3.25rem;
  min-height: 2.5rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] {
  background: var(--color-raised);
  color: var(--color-text);
}

#settlements-panel { display: flex; flex-direction: column; gap: var(--space-4); }

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: var(--color-page);
}
table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: var(--space-3);
  text-align: start;
  white-space: nowrap;
}
th { color: var(--color-text-muted); font-weight: 600; }
tbody tr + tr td { border-block-start: 1px solid var(--color-surface); }
.num { text-align: end; }
.mono { font-family: var(--font-mono); }
.table-wrap[data-empty="true"] { display: none; }

/* Activity chart */
.chart { display: flex; flex-direction: column; gap: var(--space-2); }
.bars {
  list-style: none;
  padding: 0;
  height: 9rem;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-block-end: 1px solid var(--color-border);
}
.bar {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.bar-fill {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--color-action);
  transform-origin: bottom;
  transition: height 600ms var(--ease-out);
}
.bar[data-zero="true"] .bar-fill { background: var(--color-border); }
.axis {
  display: flex;
  justify-content: space-between;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* Contracts */
.contract-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
}
@media (min-width: 46rem) {
  .contract-groups { grid-template-columns: 3fr 2fr; }
}
.contract-groups h3 { margin-block-end: var(--space-2); color: var(--color-text-muted); }
.contracts {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 68rem) {
  .contracts#contracts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-5); }
}
.contracts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.75rem;
  border-block-end: 1px solid var(--color-raised);
}
.contracts .name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-2);
  min-width: 0;
}
.contracts a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.state {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.state[data-tone="positive"] { color: var(--color-positive); }

/* Footer */
.foot {
  max-width: var(--page-max);
  margin-inline: auto;
  padding: 0 var(--space-4) var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* A card whose last refresh failed keeps its data and gets a dashed edge;
   the header says why. Opacity is avoided so text contrast is unchanged. */
.card[data-stale="true"] { border-style: dashed; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
