/* uphill.fit - controls, cards and tables.
   The utility classes at the bottom are the contract the page templates build on. */

/* -------------------------------------------------------------- controls */

.segmented,
.chips {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.segmented {
  display: flex;
  gap: 3px;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 4px;
}

.segment,
.chip {
  cursor: pointer;
  user-select: none;
}

.segment input,
.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segment span {
  display: block;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: var(--round);
  color: var(--subtle);
  transition: background var(--speed) ease, color var(--speed) ease;
}

/* Active state follows the checked radio, so a click moves the pill before the
   server round trip and the out-of-band swap of the bar confirms it. */
.segment:has(input:checked) span {
  background: var(--accent);
  color: var(--on-brand);
  font-weight: 600;
}

.segment:hover span {
  color: var(--strong);
}

.segment:has(input:checked):hover span {
  color: var(--on-brand);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  border: 1px solid var(--hairline);
  background: var(--base);
  color: var(--text);
  border-radius: var(--round);
  padding: 6px 14px;
  transition: border-color var(--speed) ease;
}

.chip:hover span {
  border-color: var(--subtle);
}

.chip:has(input:checked) span {
  background: var(--text);
  border-color: var(--text);
  color: var(--canvas);
  font-weight: 600;
}

.chip-count {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.6;
}

.filters-button,
.button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--control);
  border: 1px solid var(--hairline);
  border-radius: var(--round);
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  transition: border-color var(--speed) ease;
}

.filters-button:hover,
.button:hover {
  border-color: var(--subtle);
}

.badge {
  background: var(--accent);
  color: var(--on-brand);
  border-radius: var(--round);
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  line-height: 16px;
}

/* --------------------------------------------------------------- popover */

.popover {
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--base);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-popover);
  box-shadow: var(--popover-shadow);
  padding: 16px;
  margin: 0;
  inset: auto;
  position: fixed;
  top: 108px;
  right: max(var(--gutter), calc((100vw - var(--page)) / 2 + var(--gutter)));
  display: none;
  flex-direction: column;
  gap: 12px;
}

.popover:popover-open {
  display: flex;
}

@supports (anchor-name: --anchor) {
  .filters-button {
    anchor-name: --filters;
  }

  .popover {
    position-anchor: --filters;
    position-area: bottom span-left;
    margin-top: 8px;
    top: auto;
    right: auto;
  }
}

.popover-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.popover-rule {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--hairline);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

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

.check--stacked {
  align-items: flex-start;
}

.check--stacked input {
  margin-top: 3px;
}

.check-sub {
  display: block;
  font-size: 11px;
  color: var(--subtle);
}

.popover-button {
  justify-content: center;
  background: var(--tint);
  font-weight: 600;
}

/* ----------------------------------------------------------------- cards */

.card,
.panel {
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 22px;
}

.card--mini {
  border-radius: var(--radius-mini);
  padding: 16px;
}

.card--hero {
  background: var(--hero);
  border-color: color-mix(in oklch, var(--brand), white 25%);
  color: #fff;
  padding: 10px;
}

.card--planned {
  background: none;
  border: 1.5px dashed var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.planned-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.planned-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--strong);
}

.planned-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--subtle);
  border: 1px solid var(--line);
  border-radius: var(--round);
  padding: 1px 8px;
}

.card-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-head h2,
.card-head h3,
.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--strong);
}

.panel-aside,
.caption {
  margin: 0;
  font-size: 11.5px;
  color: var(--subtle);
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--strong);
  line-height: 1.15;
}

.link-arrow {
  border: 0;
  background: var(--tint);
  color: var(--subtle);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: grid;
  place-items: center;
  flex: none;
  transition: color var(--speed) ease;
}

.link-arrow:hover {
  color: var(--strong);
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-bar {
  height: 16px;
  border-radius: var(--round);
  background: var(--tint);
  overflow: hidden;
  flex: 1;
  min-width: 60px;
}

.pill-bar > span {
  display: block;
  height: 100%;
  border-radius: var(--round);
  background: var(--line);
  transition: width 0.35s ease;
}

.pill-bar--accent > span {
  background: var(--accent);
}

.delta--up,
.delta-up {
  color: var(--success);
}

.delta--down,
.delta-down {
  color: var(--danger);
}

.delta-flat {
  color: var(--subtle);
}

/* --------------------------------------------------------------- tables */

.table-scroll,
.chart-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  font-size: 13px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  white-space: nowrap;
}

.table thead th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--subtle);
  padding-block: 7px;
}

.table tbody th {
  font-weight: 600;
  color: var(--strong);
}

.table .numeric {
  text-align: right;
}

.table tfoot th,
.table tfoot td {
  border-bottom: 0;
  font-weight: 600;
  color: var(--strong);
  padding-block: 10px;
}

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

.table .unit {
  font-weight: 400;
  opacity: 0.7;
}

.table a {
  color: var(--text);
}

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

.cell-delta {
  margin-left: 6px;
  font-size: 11.5px;
}

.tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--subtle);
  border: 1px solid var(--line);
  border-radius: var(--round);
  padding: 1px 7px;
}

.empty {
  color: var(--subtle);
}

/* ------------------------------------------- overview fragment (interim) */

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

.stat {
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-mini);
  padding: 16px;
}

.stat p {
  margin: 0;
}

.stat-label {
  font-size: 11.5px;
  color: var(--subtle);
}

.stat .stat-value {
  margin-block: 2px;
}

.stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--subtle);
  margin-left: 5px;
}

.stat-delta {
  font-size: 11.5px;
}

.stat-pct {
  color: var(--subtle);
}

.panel-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.chart {
  width: 100%;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--base);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-mini);
  padding: 12px 18px;
}

.banner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--brand), white 22%);
  flex: none;
}

.banner-text {
  margin: 0;
  font-size: 13px;
}

.banner-status {
  margin-left: auto;
  font-size: 11px;
  color: var(--subtle);
}

.notice {
  margin: 0;
  font-size: 12.5px;
  color: var(--subtle);
}

.notice-warn {
  color: var(--danger);
}

.log-nav {
  display: flex;
  gap: 6px;
}

.log-date {
  color: var(--subtle);
}

@media (max-width: 720px) {
  .grid-2,
  .panel-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .card,
  .panel {
    padding: 18px;
  }

  .filterbar-end {
    margin-left: 0;
  }
}
