:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #55606e;
  --line: #dfe4ea;
  --accent: #0e7490;
  --accent-soft: #d7ebf0;
  --bar-track: #eef1f4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 6px 20px rgba(20, 30, 45, 0.05);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.brand-suffix {
  font-weight: 600;
  color: var(--muted);
}

.sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.window-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.window-select select {
  font: inherit;
  color: var(--ink);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.whoami {
  font-size: 13px;
  color: var(--muted);
}

.logout {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.logout:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
}

.state {
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
}

.state.error {
  color: #9a3412;
}

.overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat-hint {
  font-size: 12px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.section {
  margin-top: 28px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 62ch;
}

.mini-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}

.mini-toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.dist-controls {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 6px 12px;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button.is-active {
  background: var(--accent);
  color: #fff;
}

.custom-dates input[type="date"] {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-width: 132px;
}

.date-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.date-sep {
  color: var(--muted);
  font-weight: 600;
}

.range-presets button {
  padding: 6px 10px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.pager-size select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pager-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.pager-status {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 0 8px;
  white-space: nowrap;
}

.pager-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.pager-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.pager-btn:disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: default;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.row {
  display: grid;
  grid-template-columns: 132px 1fr 52px;
  align-items: center;
  gap: 10px;
}

.row-label {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-bar {
  height: 7px;
  background: var(--bar-track);
  border-radius: 6px;
  overflow: hidden;
}

.row-zero {
  opacity: 0.45;
}

.hidden-note {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.row-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  min-width: 2px;
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.row-val {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.empty-note {
  font-size: 12.5px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .row-fill {
    transition: none;
  }
}

.runs {
  margin-top: 28px;
}

/* One calm surface: header, toolbar, filters, table, pager all live inside a
   single card separated by hairlines — no nested boxes. */
.runs-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.runs-header {
  padding: 20px 22px 0;
}

.runs-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.runs-title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.runs-count {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.runs-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 64ch;
}

.runs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px;
}

.toolbar-left {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-dates {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-dates[hidden] {
  display: none;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-toggle:hover {
  background: var(--bg);
}

.filter-toggle.is-open {
  background: var(--bg);
  border-color: var(--muted);
}

.filter-toggle.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.filter-count[hidden] {
  display: none;
}

.runs-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  animation: runs-filters-in 0.16s ease-out;
}

.runs-filters[hidden] {
  display: none;
}

@keyframes runs-filters-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

.filter {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.filter select {
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-width: 130px;
}

.filter-reset {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.filter-reset:hover {
  background: var(--accent-soft);
}

.runs-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.runs-scroll::-webkit-scrollbar {
  height: 8px;
}

.runs-scroll::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
}

.runs-scroll::-webkit-scrollbar-thumb:hover {
  background: #c9d0d8;
}

.runs-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.runs-table th,
.runs-table td {
  text-align: left;
  padding: 12px 22px;
  white-space: nowrap;
}

.runs-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}

.runs-table tbody tr + tr td {
  border-top: 1px solid var(--line);
}

.runs-table tbody tr:hover td {
  background: #f8fafb;
}

.runs-table td {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.runs-when {
  font-weight: 550;
}

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

.runs-row-err td {
  background: #fff7ed;
}

.runs-row-err:hover td {
  background: #ffedd5;
}

.runs-empty {
  text-align: center !important;
  color: var(--muted);
  padding: 28px 22px !important;
}

@media (prefers-reduced-motion: reduce) {
  .runs-filters {
    animation: none;
  }
}
