/* Admin console. Extends styles.css rather than replacing it: the tokens, the
 * theme handling and the button and form styles are all shared, so the two
 * pages cannot drift into looking like different products.
 *
 * The visual difference is density. Sales sees one estimate at a time and the
 * page can breathe; an admin is comparing a list of rules against each other,
 * so rows are tighter, numbers are tabular, and structure is carried by rules
 * and alignment rather than by whitespace.
 */

.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}

.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-link {
  font-size: 0.85rem; font-weight: 550; text-decoration: none;
  color: var(--text-muted);
  padding: 0.35rem 0.7rem; border-radius: 4px;
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--surface-sunk); }
.nav-active {
  color: var(--accent); background: var(--accent-weak); border-color: var(--accent);
}

.picker { display: flex; align-items: center; gap: 0.5rem; }
.picker-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint);
}
.picker select { width: auto; min-width: 16rem; font-size: 0.85rem; padding: 0.35rem 2rem 0.35rem 0.5rem; }

.admin-main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.5rem 5rem;
  display: flex; flex-direction: column; gap: 1.25rem; }

.loading { color: var(--text-faint); font-size: 0.9rem; }

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

.grid { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.grid th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600;
  padding: 0.4rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.grid td {
  padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.grid tr:last-child td { border-bottom: 0; }
.grid td.num, .grid th.num {
  text-align: right; font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0;
}
.grid td.empty { color: var(--text-faint); font-style: italic; padding: 1rem 0; }
.grid .row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; }

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

.f { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.f-hint { font-size: 0.78rem; color: var(--text-faint); margin: 0; max-width: 62ch; }
.f-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0 1rem; }
.cb { display: flex; align-items: center; gap: 0.45rem; font-size: 0.875rem; font-weight: 400; }
.cb input { accent-color: var(--accent); }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.1rem 0.42rem; border-radius: 3px;
  background: var(--surface-sunk); color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.ok      { background: var(--ok-weak);   color: var(--ok);   border-color: var(--ok); }
.pill.warn    { background: var(--warn-weak); color: var(--warn); border-color: var(--warn); }
.pill.stop    { background: var(--stop-weak); color: var(--stop); border-color: var(--stop); }
.pill.accent  { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------ rule editor */

/* A condition group is a box inside a box. The left rule and the indent are
 * doing real work: they are the only thing showing where an AND stops and the
 * nested OR begins, which is precisely what an admin gets wrong. */
.group {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 0.7rem 0.8rem; margin-top: 0.5rem;
  background: var(--surface-sunk);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.group .group { margin-left: 0.75rem; border-left-color: var(--border-strong); }
.group-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.group-logic { width: auto; min-width: 5rem; font-size: 0.8rem; padding: 0.25rem 1.8rem 0.25rem 0.45rem; }
.cond {
  display: grid; grid-template-columns: minmax(9rem,1.4fr) minmax(7rem,0.9fr) minmax(7rem,1fr) auto;
  gap: 0.4rem; align-items: center;
}
.cond select, .cond input { font-size: 0.83rem; padding: 0.3rem 0.45rem; }
.cond select { padding-right: 1.8rem; }
@media (max-width: 760px) { .cond { grid-template-columns: 1fr; } }

.action-row {
  display: grid; grid-template-columns: minmax(9rem,1fr) minmax(6rem,0.7fr) minmax(8rem,1fr) auto;
  gap: 0.4rem; align-items: center; margin-top: 0.4rem;
}
@media (max-width: 760px) { .action-row { grid-template-columns: 1fr; } }

.rule-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1rem; background: var(--surface);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.rule-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.rule-name { font-weight: 620; }
.rule-summary { font-size: 0.83rem; color: var(--text-muted); font-family: var(--mono); }

/* ------------------------------------------------------------- findings */

.finding {
  display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 0.75rem;
  padding: 0.55rem 0.7rem; border-radius: 4px; font-size: 0.85rem;
  border: 1px solid; margin-bottom: 0.4rem;
}
.finding-error   { background: var(--stop-weak); border-color: var(--stop); }
.finding-warning { background: var(--warn-weak); border-color: var(--warn); }
.finding-message { color: var(--text); }
.finding-remedy  { font-size: 0.8rem; color: var(--text-muted); grid-column: 2; }

/* --------------------------------------------------------- golden diff */

.diff-changed td { background: var(--warn-weak); }
.diff-failing td { background: var(--stop-weak); }
.delta-up   { color: var(--stop); }
.delta-down { color: var(--ok); }
.delta-same { color: var(--text-faint); }

/* ----------------------------------------------------------------- misc */

.alert-field { font-family: var(--mono); font-size: 0.8rem; margin-top: 0.25rem; }
.toast-ok   { background: var(--text); color: var(--bg); }
.toast-error{ background: var(--stop); color: #fff; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.muted { color: var(--text-muted); font-size: 0.85rem; }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
