:root {
  color-scheme: light dark;

  --bg: #f4f6f8;
  --card: #ffffff;
  --card-2: #f8fafb;
  --ink: #12151a;
  --muted: #667085;
  --line: #e1e6ea;
  --line-soft: #eef1f4;

  --green: #12855c;
  --yellow: #9a6b00;
  --red: #c33b2c;
  --unknown: #8b8f97;

  --green-soft: #12855c22;
  --yellow-soft: #9a6b0022;
  --red-soft: #c33b2c22;

  --radius: 12px;
  --gap: clamp(0.75rem, 1.2vw, 1.25rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1116;
    --card: #171a21;
    --card-2: #1c2029;
    --ink: #e7eaef;
    --muted: #98a1b0;
    --line: #262b36;
    --line-soft: #1f242e;

    --green: #3ecf8e;
    --yellow: #e3ad42;
    --red: #f0705f;
    --unknown: #7d838f;

    --green-soft: #3ecf8e26;
    --yellow-soft: #e3ad4226;
    --red-soft: #f0705f26;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: clamp(1rem, 1.8vw, 2rem) clamp(1rem, 2vw, 2.25rem) 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Full window width by design: this is watched full screen on a wide monitor
   and in a half-screen column, so nothing is capped and everything reflows. */
#app {
  width: 100%;
  margin: 0;
}

/* ------------------------------------------------------------- header --- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: var(--gap);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h1 {
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: -0.01em;
}

/* -------------------------------------------------------------- tiles --- */

.tiles {
  display: grid;
  gap: var(--gap);
  /* One column when narrow, as many as fit when wide. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr));
  align-items: start;
}

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

.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
}

.tile h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 1rem;
}

.tile-icon {
  width: 1rem;
  height: 1rem;
}

.tile h2 .dot {
  margin-left: auto;
}

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

.warn {
  color: var(--yellow);
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--unknown);
  flex: 0 0 auto;
}

.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }

/* --------------------------------------------------------------- bars --- */

.bar-row + .bar-row {
  margin-top: 0.9rem;
}

.bar-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.bar-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.bar-detail {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-percent {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.9rem;
}

.bar-percent.green { color: var(--green); }
.bar-percent.yellow { color: var(--yellow); }
.bar-percent.red { color: var(--red); }

.bar-track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--unknown);
  transition: width 0.4s ease;
}

.bar-fill.green { background: var(--green); }
.bar-fill.yellow { background: var(--yellow); }
.bar-fill.red { background: var(--red); }

/* -------------------------------------------------------------- facts --- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
  gap: 0.6rem 1rem;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.fact-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fact-value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------- backup --- */

.verdict {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.verdict.green { color: var(--green); }
.verdict.yellow { color: var(--yellow); }
.verdict.red { color: var(--red); }

.archive {
  margin: 0.9rem 0 0;
  font-size: 0.78rem;
  word-break: break-all;
}

.history {
  margin-top: 0.9rem;
}

.history ul {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-size: 0.85rem;
}

.history li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.history li:last-child {
  border-bottom: 0;
}

.history-time {
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- containers --- */

.container-grid {
  display: grid;
  gap: 0.75rem;
  /* Cards keep a comfortable minimum so names never wrap; below that the grid
     drops to a single column instead of squeezing. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19.5rem), 1fr));
}

.container-card {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--unknown);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  min-width: 0;
}

.container-card.green { border-left-color: var(--green); }
.container-card.yellow { border-left-color: var(--yellow); }
.container-card.red { border-left-color: var(--red); }

.container-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.container-icon {
  width: 1.05rem;
  height: 1.05rem;
  color: var(--muted);
  flex: 0 0 auto;
}

.container-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.pill {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--line-soft);
  color: var(--muted);
}

.pill.green { background: var(--green-soft); color: var(--green); }
.pill.yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill.red { background: var(--red-soft); color: var(--red); }

.container-image {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.container-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
}

.container-meta .fact-value {
  font-size: 0.85rem;
}

.container-meta .fact:last-child {
  text-align: right;
}

/* -------------------------------------------------------------- forms --- */

button {
  font: inherit;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

button:hover {
  opacity: 0.9;
}

input {
  font: inherit;
  width: 100%;
  max-width: 32rem;
  padding: 0.55rem 0.7rem;
  margin: 0.5rem 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

details {
  margin-top: 1.5rem;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.status {
  min-height: 1.5rem;
  margin-top: 1rem;
}

/* The login view is the one place a narrow column is right. */
[data-state='login'] {
  max-width: 30rem;
  margin: 4rem auto 0;
}
