/* How each page lays its cards out: two columns on a desk, one on a phone, with nothing ever wider than the screen. */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
  margin-bottom: 20px;
}

.page-heading {
  min-width: 0;
}

.page-title {
  font-size: 24px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--ink-3);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.header-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

/* six tiles in one row once each can be about 170px wide beside the sidebar */
@media (min-width: 1320px) {
  .tiles {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.tiles-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .tiles-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--line),
    var(--shadow);
}

.tile-label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-3);
}

.tile-value {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.tile-sub {
  display: -webkit-box;
  margin-top: 2px;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  color: var(--ink-3);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.tile-delta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 550;
}

.tile-trend {
  margin-top: auto;
  padding-top: 12px;
}

/* The live strip */
.live-holder {
  margin-bottom: var(--gap);
}

.live-holder:empty {
  display: none;
}

.live-body {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr);
  align-items: center;
  gap: 20px 32px;
}

.live-figures {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.live-figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.live-value {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.live-figure.tone-warning .live-value {
  color: var(--warning-ink);
}

.live-figure.tone-bad .live-value {
  color: var(--critical-ink);
}

.live-label {
  font-size: 12px;
  color: var(--ink-3);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

.live-meter .minor-title {
  margin-top: 0;
}

/* Grids of cards */
.chart-grid,
.person-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

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

.list-holder {
  min-height: 120px;
}

/* Errors page */
.recent-item {
  border-bottom: 1px solid var(--line);
}

.recent-item:last-child {
  border-bottom: 0;
}

.recent-item summary {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}

.recent-chevron {
  grid-row: 1 / span 2;
  margin-top: 3px;
  color: var(--ink-3);
  transition: transform 0.15s;
}

details[open] > summary .recent-chevron {
  transform: rotate(90deg);
}

.recent-item .stack {
  margin-left: 24px;
}

.recent-item summary::-webkit-details-marker {
  display: none;
}

.recent-message {
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.recent-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.stack {
  max-height: 260px;
  margin: 0 0 12px;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  background: var(--surface-sunk);
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}

/* Money before the first sale */
.no-sales {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.6fr);
  align-items: center;
  gap: 24px 40px;
}

.no-sales-words {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.no-sales-words .state-text {
  max-width: 340px;
}

.no-sales-figure {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.no-sales-figure b {
  color: var(--ink);
  font-size: 15px;
}

.quiet-empty {
  padding: 4px 20px 20px;
  font-size: 13.5px;
  color: var(--ink-3);
}

/* Pictures page */
.picture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.picture-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.picture-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
}

.picture-reason {
  font-weight: 600;
}

.picture-note {
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.picture-meta {
  font-size: 13px;
}

.picture-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 12px;
}

/* Forms: codes and settings */
.code-form,
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.code-form {
  padding: 4px 20px 20px;
  border-bottom: 1px solid var(--line);
}

.codes-card .state {
  padding: 28px 20px 32px;
}

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

.form-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.switch-words {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
}

.switch-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-knob {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s;
  pointer-events: none;
}

.switch-knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.switch-input:checked + .switch-knob {
  background: var(--accent);
}

.switch-input:checked + .switch-knob::after {
  transform: translateX(16px);
}

.switch-input:focus-visible + .switch-knob {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.device {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  font-size: 13px;
}

.device-name {
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .live-body {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .chart-grid,
  .person-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-title {
    font-size: 22px;
  }

  .range {
    align-items: flex-start;
  }

  .range-custom {
    right: auto;
    left: 0;
  }

  .tiles,
  .tiles-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .no-sales {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* on a phone the code and its note take a whole line each, the two numbers share one */
  .code-form .form-grid > .field:first-child,
  .code-form .form-grid > .field:last-child {
    grid-column: 1 / -1;
  }

  .quiet-empty {
    padding: 4px 16px 16px;
  }

  .tile {
    padding: 14px;
  }

  .tile-value {
    font-size: 22px;
  }

  .live-figures {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 14px;
  }

  .card-head {
    padding: 16px 16px 0;
  }

  .card-body {
    padding: 14px 16px 16px;
  }

  .chart-card {
    padding: 16px;
  }

  .table th:first-child,
  .table td:first-child {
    padding-left: 16px;
  }

  .table th:last-child,
  .table td:last-child {
    padding-right: 16px;
  }

  .code-form {
    padding: 4px 16px 16px;
  }

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

  .picture-body {
    padding: 12px;
  }

  .picture-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
