/* The radar's admin views (admin.js): only an account in ADMIN_EMAILS ever sees them. Built from
   the site's own tokens and components in styles.css. */

.admin-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* On the Stores tab the health table sits above the store cards. */
#stores-admin {
  margin-bottom: var(--space-lg);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.admin-toolbar h2,
.admin-card h2 {
  margin: 0;
  font-size: var(--text-subheading);
  font-weight: 600;
}

.admin-summary,
.admin-muted,
.admin-sub,
.admin-legend {
  color: var(--text3);
  font-size: var(--text-body-sm);
}

.admin-muted {
  margin: 0;
}

.admin-sub {
  display: block;
  font: 400 var(--text-caption) var(--font-mono);
}

.admin-note {
  margin: 0;
  color: var(--accent);
  font: 400 var(--text-caption) var(--font-mono);
}

.is-bad {
  color: var(--error);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: var(--space-md);
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  min-width: 0;
}

.admin-card > .btn {
  align-self: flex-start;
}

.admin-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Wide tables scroll inside their card, never the page. */
.admin-scroll {
  overflow-x: auto;
  min-width: 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}

.admin-table th,
.admin-table td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-table thead th {
  color: var(--text3);
  font: 400 var(--text-label) / 1.2 var(--font-pixel);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-table tbody tr:last-child > * {
  border-bottom: none;
}

.admin-table .is-num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.admin-table tr.is-failing > td:first-child {
  box-shadow: inset 3px 0 0 var(--error);
}

.admin-table .admin-error {
  min-width: 180px;
  max-width: 300px;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--error);
  font: 400 var(--text-caption) var(--font-mono);
}

.admin-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: var(--text-body-sm);
}

.admin-facts dt {
  color: var(--text3);
}

.admin-facts dd {
  margin: 0;
}

/* The Farmers matrix: products down, regions across, the product column pinned while it scrolls. */
.admin-matrix .admin-product {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 220px;
  max-width: 300px;
  white-space: normal;
  background: var(--surface1);
  font-weight: 500;
}

.admin-matrix .admin-product a:hover {
  color: var(--accent);
}

.admin-matrix .admin-product .badge {
  margin-top: 4px;
}

.admin-cell {
  text-align: center;
  font: 400 var(--text-caption) / 1.2 var(--font-mono);
  border-radius: var(--radius-element);
}

td.admin-cell {
  min-width: 52px;
  border-left: 2px solid var(--surface1);
}

.admin-cell small {
  display: block;
  color: var(--text3);
  font-size: 10px;
}

.admin-cell.is-fresh {
  background: var(--success-bg);
  color: var(--success);
}

.admin-cell.is-due {
  background: var(--warning-bg);
  color: var(--warning);
}

.admin-cell.is-stale {
  background: var(--error-bg);
  color: var(--error);
}

.admin-cell.is-never {
  color: var(--text4);
  box-shadow: inset 0 0 0 1px var(--border-visible);
}

.admin-cell.has-stock small {
  color: var(--text1);
  font-weight: 700;
}

.admin-legend {
  margin: 0;
  line-height: 2;
}

.admin-legend .admin-cell {
  display: inline-block;
  padding: 0 6px;
}

/* Farmers: the check intervals, and each product's place on the hot list. */
.admin-settings {
  gap: 8px;
}

.admin-settings .admin-toolbar {
  align-items: flex-end;
}

.admin-minutes {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
}

.admin-minutes .admin-input {
  width: 96px;
}

.admin-hot-select {
  display: block;
  width: auto;
  height: 30px;
  margin-top: 6px;
  padding: 0 8px;
  font-size: var(--text-caption);
}

.admin-hot-select.is-hot {
  border-color: var(--restock);
}

.admin-matrix tr.is-hot .admin-product {
  box-shadow: inset 3px 0 0 var(--restock);
}

/* Log */
.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text3);
  font-size: var(--text-caption);
}

.admin-field-grow {
  flex: 1 1 240px;
}

.admin-select,
.admin-input {
  height: 38px;
  padding: 0 12px;
}

.admin-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-end;
  height: 38px;
  color: var(--text2);
}

.log {
  margin: 0;
  padding: 6px 0;
  list-style: none;
  font: 400 var(--text-caption) / 1.5 var(--font-mono);
}

.log-line {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.log-line:last-child {
  border-bottom: none;
}

.log-line time {
  color: var(--text4);
}

.log-level {
  min-width: 40px;
  text-transform: uppercase;
  color: var(--text3);
}

.log-line.is-warn .log-level {
  color: var(--warning);
}

.log-line.is-error .log-level,
.log-line.is-fatal .log-level {
  color: var(--error);
}

.log-line.is-error {
  background: var(--error-bg);
}

.log-source {
  color: var(--accent);
}

.log-msg {
  color: var(--text1);
}

.log-details {
  flex-basis: 100%;
  color: var(--text3);
}

.log-kv i {
  font-style: normal;
  color: var(--text4);
}

.log-details details summary {
  cursor: pointer;
  color: var(--text2);
}

.log-details pre {
  margin: 6px 0 0;
  padding: 8px;
  max-height: 320px;
  overflow: auto;
  border-radius: var(--radius-control);
  background: var(--surface2);
  white-space: pre-wrap;
}

/* SKUs the Farmers probe found, waiting for a name. */
.found-skus-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.found-sku {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  min-width: 0;
}

.found-sku-image {
  width: 64px;
  height: 84px;
  object-fit: contain;
  flex: none;
  border-radius: var(--radius-control);
  background: var(--surface2);
}

.found-sku-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.found-sku-meta {
  font: 400 var(--text-caption) var(--font-mono);
  color: var(--text3);
  overflow-wrap: anywhere;
}

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

.found-sku-input {
  flex: 1 1 220px;
  height: 36px;
  padding: 0 12px;
}

/* Eight tabs do not fit a phone's bar, so an admin's scrolls sideways (the page never does). */
@media (max-width: 860px) {
  .tabbar.has-admin {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabbar.has-admin button {
    flex: 0 0 76px;
  }
}

@media (max-width: 600px) {
  .admin-matrix .admin-product {
    min-width: 140px;
    max-width: 160px;
    font-size: var(--text-caption);
  }
}

/* Check times */
.admin-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text2);
}

.admin-table tr.is-off > td {
  color: var(--text3);
}

.admin-hot-list {
  max-height: 420px;
  overflow-y: auto;
}

.admin-hot-list tr.is-hot > td:first-child {
  box-shadow: inset 3px 0 0 var(--restock);
}

/* Stock alerts paused: the card says so at a glance. */
.admin-card.is-paused {
  border-color: var(--error);
  box-shadow: inset 4px 0 0 var(--error);
}

.admin-card h2 .ph-bold {
  vertical-align: -2px;
}
