:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #657080;
  --line: #d7dce3;
  --primary: #2f6db5;
  --primary-strong: #20558f;
  --danger: #a23c32;
  --done: #edf7ef;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, Helvetica, sans-serif;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.app-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.app-banner-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.app-banner-home {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
}
.app-banner-home:hover .app-banner-name { opacity: 0.9; }
.app-banner-home:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.app-banner-mark {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 3px 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  text-transform: uppercase;
}

.app-banner-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.app-banner-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.app-banner-user button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 4px 12px;
  min-height: 32px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.login-body { min-height: 100vh; }

.login-signup-link {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.login-signup-link a {
  color: var(--primary);
  font-weight: 600;
}

/* ---- Marketing landing page (/welcome.html) ------------------------- */
.landing-body { background: var(--bg); min-height: 100vh; }

.landing-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 48px 20px 24px;
}

.landing-hero {
  text-align: center;
  padding: 32px 0 40px;
}
.landing-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.5px;
}
.landing-lede {
  margin: 0 auto 24px;
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(15px, 2.2vw, 18px);
  line-height: 1.5;
}
.landing-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  font-size: 15px;
  min-width: 140px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-secondary:hover { background: rgba(47, 109, 181, 0.08); }

.landing-signup-note {
  margin: 14px auto 0;
  max-width: 480px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.landing-features {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 32px;
}
.landing-features .feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
.landing-features .feature h3 {
  margin: 0 0 8px;
  font-size: 17px;
}
.landing-features .feature p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.landing-about {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-top: 32px;
}
.landing-about-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 22px 24px;
}
.landing-about-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--primary-strong);
}
.landing-about-card p {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.landing-footer {
  border-top: 1px solid var(--line);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 640px) {
  .landing-shell { padding: 24px 14px 16px; }
  .landing-hero { padding: 20px 0 28px; }
  .btn-primary, .btn-secondary { width: 100%; }
  .landing-cta { flex-direction: column; align-items: stretch; max-width: 320px; margin: 0 auto; }
}

.login-shell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 18px;
}

.login-card[hidden] { display: none; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card #loginStatus {
  color: var(--danger);
  margin: 0;
  font-size: 14px;
  min-height: 1em;
}

@media (max-width: 560px) {
  .app-banner-inner { padding: 12px 14px; }
  .app-banner-name { font-size: 18px; }
}

button,
input,
select {
  font: inherit;
}

/* Base select styling — the picklist Machine dropdown and Notes machine
 * picker both use this. 16px keeps iOS from auto-zooming on focus.
 * Full-width + adequate padding makes the collapsed control readable
 * on phone screens. */
select {
  width: 100%;
  min-height: 44px;
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
}

button {
  min-height: 44px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  background: var(--primary-strong);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  /* Horizontal scroll on narrow screens instead of overflow-clipping the
   * rightmost tabs — the Machines tab was unreachable on phones. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
/* Keep tabs themselves from shrinking below their intrinsic width in
 * the scroll container. */
.tabs .tab {
  flex-shrink: 0;
  white-space: nowrap;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 8px 16px;
  font-weight: 700;
  min-height: 40px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
  position: relative;
  top: 1px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.qty-control {
  /* keep label header above row, then 3 columns inside */
}

.sub-tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0 12px;
  flex-wrap: wrap;
}

.sub-tab {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 36px;
  font-weight: 700;
}

.sub-tab.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sub-panel {
  display: none;
}

.sub-panel.is-active {
  display: block;
}

.sched-list {
  display: grid;
  gap: 8px;
}

.sched-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sched-row.is-filled {
  background: var(--done);
  border-color: #b6d7bb;
}

.sched-row .machine {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sched-row .machine strong {
  word-break: break-word;
}

.sched-row .machine span {
  color: var(--muted);
  font-size: 13px;
}

.sched-row .filled-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.sched-row .filled-toggle input[type="checkbox"] {
  width: 24px;
  height: 24px;
}

.sched-row .filled-time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.sched-empty {
  color: var(--muted);
  font-size: 14px;
}

.perf-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 22px;
}

.perf-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.picklist-warning-banner {
  background: #fff3d9;
  border: 1px solid #d1a13a;
  border-left-width: 4px;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0 0 12px;
  color: #6b4a08;
  font-size: 14px;
  line-height: 1.4;
}
.picklist-warning-banner strong {
  display: block;
  margin-bottom: 4px;
  color: #5a3d00;
  font-size: 14px;
}
.picklist-warning-banner ul {
  margin: 4px 0 0;
  padding-left: 20px;
}
.picklist-warning-banner li { margin: 2px 0; }

.perf-records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.perf-records-header h3 { margin: 0; }
button.ghost.perf-records-reset {
  padding: 4px 12px;
  min-height: 32px;
  font-size: 12px;
}
button.ghost.perf-records-reset[hidden] { display: none; }

.perf-records-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}
.perf-records-list li {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: baseline;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
.perf-records-list li.perf-records-empty {
  display: block;
  color: var(--muted);
  font-style: italic;
  padding: 10px 12px;
}
.perf-record-label { color: var(--text); font-weight: 600; font-size: 14px; }
.perf-record-value {
  color: var(--primary-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.perf-record-range {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.perf-record-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--primary-strong);
  color: #fff;
  vertical-align: 2px;
}
.perf-records-list li.perf-record-is-new {
  border-color: var(--primary-strong);
}
@media (max-width: 560px) {
  .perf-records-list li {
    grid-template-columns: 1fr auto;
  }
  .perf-record-range {
    grid-column: 1 / -1;
    text-align: left;
  }
}

.machine-perf-body { margin-top: 4px; }
.machine-perf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.machine-perf-table th,
.machine-perf-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.machine-perf-table th {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.machine-perf-table td.rank {
  width: 32px;
  color: var(--muted);
  font-weight: 700;
}
.machine-perf-table td.gross {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary-strong);
  white-space: nowrap;
}
.machine-perf-table td.provider {
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 560px) {
  .machine-perf-table td.provider { display: none; }
  .machine-perf-table th:nth-child(3) { display: none; }
}

.perf-total {
  font-size: 44px;
  font-weight: 800;
  color: var(--primary-strong);
  line-height: 1.1;
  margin: 0 0 14px;
}

@media (max-width: 560px) {
  .perf-total { font-size: 34px; }
}

.perf-breakdown {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.perf-breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
}

.perf-breakdown-row .src {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.perf-breakdown-row .val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.perf-breakdown-row.is-error .val {
  color: var(--danger);
  font-size: 13px;
  font-weight: 400;
}

#perfDailyChartCard,
#perfRollingChartCard {
  margin-top: 12px;
}

.perf-chart {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.perf-chart-rows {
  display: grid;
  gap: 6px;
}

.perf-chart-row {
  display: grid;
  grid-template-columns: 70px 1fr 70px;
  gap: 10px;
  align-items: center;
}

.perf-chart-row .date {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.perf-chart-row .track {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
}

.perf-chart-row .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px 0 0 5px;
  min-width: 2px;
}

.perf-chart-row .value {
  text-align: right;
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 560px) {
  .perf-chart-row {
    grid-template-columns: 64px 1fr 64px;
    gap: 8px;
  }
  .perf-chart-row .date { font-size: 12px; }
  .perf-chart-row .value { font-size: 13px; }
  .perf-chart-row .track { height: 20px; }
}

.perf-body[data-state="empty"],
.perf-body[data-state="error"] {
  color: var(--muted);
  font-size: 14px;
  padding: 12px 0;
}

.perf-recalc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.perf-recalc-row button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  min-height: 40px;
  cursor: pointer;
}

.perf-recalc-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.perf-body[data-state="error"] {
  color: var(--danger);
}

.perf-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  align-items: baseline;
}

.perf-stat {
  display: grid;
  gap: 2px;
}

.perf-stat .label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.perf-stat .value {
  font-size: 22px;
  font-weight: 800;
}

.perf-stat .value.big {
  font-size: 28px;
  color: var(--primary-strong);
}

.perf-stat .pct {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
  font-weight: 400;
}

.sched-set-list {
  display: grid;
  gap: 6px;
}

.sched-set-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sched-set-row .machine strong {
  word-break: break-word;
  font-size: 14px;
}

.sched-set-row .machine span {
  color: var(--muted);
  font-size: 12px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 38px);
  gap: 4px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.day-cell label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  display: block;
  text-align: center;
}

.day-cell input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
}

@media (max-width: 560px) {
  .sched-set-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .day-grid {
    grid-template-columns: repeat(7, 1fr);
  }
}

.qty-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 6px;
}

.qty-btn {
  min-height: 44px;
  padding: 0;
  font-size: 22px;
  font-weight: 800;
}

.qty-row input[type="number"] {
  text-align: center;
}

.qty-row input[type="number"]::-webkit-inner-spin-button,
.qty-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 300px) 180px 150px;
  gap: 14px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

.toolbar p,
.status-row {
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 16px; /* prevents iOS Safari zoom-on-focus */
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 4px 12px;
  flex-wrap: wrap;
}

#listStatus {
  flex: 1 1 auto;
  min-width: 0;
}

.status-row button,
dialog button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.status-actions,
.dialog-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.picklist {
  display: grid;
  gap: 10px;
}

.pick-item {
  display: grid;
  grid-template-columns: 84px 1fr 320px;
  grid-template-areas: "qty product actions";
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.pick-item.done {
  display: none;
}

.pick-item.out-reminder {
  background: #fff5f3;
  border-color: #d49892;
}

.pick-item.out-reminder .product strong {
  color: var(--danger);
}

.pick-item.note-row {
  background: #f1f6fc;
  border-color: #9bbfe3;
}

.pick-item.note-row .product strong {
  color: var(--primary-strong);
}

.notes-list-heading {
  margin: 18px 0 8px;
  font-size: 16px;
}

.notes-list {
  display: grid;
  gap: 12px;
}

.notes-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.notes-group-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid transparent;
  user-select: none;
}

.notes-group[open] .notes-group-summary {
  border-bottom-color: var(--line);
}

.notes-group-summary::-webkit-details-marker { display: none; }
.notes-group-summary::marker { content: ''; }

.notes-group-summary::before {
  content: '▶';
  display: inline-block;
  width: 12px;
  font-size: 11px;
  color: var(--muted);
  transition: transform 0.15s;
}

.notes-group[open] .notes-group-summary::before {
  transform: rotate(90deg);
}

.notes-group-title {
  flex: 1 1 auto;
  font-weight: 700;
  font-size: 15px;
}

.notes-group-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.notes-group-rows {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}

.notes-list-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: #f1f6fc;
  border: 1px solid #9bbfe3;
  border-radius: 8px;
}

.notes-list-row .qty {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-strong);
  text-align: center;
}

.notes-list-row .meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.notes-list-row .meta strong {
  word-break: break-word;
  color: var(--primary-strong);
}

.notes-list-row .meta span {
  color: var(--muted);
  font-size: 13px;
}

.notes-list-row button {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  min-height: 40px;
}

.notes-list-empty {
  color: var(--muted);
  font-size: 14px;
}

.pick-item .quantity.oos-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--danger);
  letter-spacing: 0.5px;
}

.clear-reminder {
  flex: 1 1 0;
  min-height: 48px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
}

.clear-reminder:active {
  background: #fbe9e7;
}

.clear-reminder:disabled {
  opacity: 0.5;
}

.pick-item .quantity { grid-area: qty; }
.pick-item .product { grid-area: product; min-width: 0; }
.pick-actions {
  grid-area: actions;
  display: flex;
  gap: 10px;
}
.pick-actions > .check-action {
  flex: 1 1 0;
  min-width: 0;
}

.quantity {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
}

.product strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
  word-break: break-word;
}

.product span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  word-break: break-word;
}

.product span.subtle {
  font-size: 11px;
  font-style: italic;
  margin-top: 2px;
  opacity: 0.85;
}

/* Flag for extras rows — the picklist tried the planogram but this
 * product wasn't in it. Red so the driver notices there's a slot-
 * assignment gap worth fixing. */
.product span.no-planogram-tag {
  font-size: 11px;
  font-style: italic;
  margin-top: 2px;
  color: var(--danger);
  font-weight: 600;
}

.check-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.check-action input {
  width: 22px;
  height: 22px;
}

.check-action.out {
  color: var(--danger);
}

dialog {
  width: min(720px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  max-height: 88vh;
}

.dialog-body {
  padding: 16px;
}

.dialog-body header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dialog-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.out-list {
  display: grid;
  gap: 8px;
  max-height: 65vh;
  overflow-y: auto;
}

.out-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.out-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  margin: 0;
}

.out-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.out-text strong {
  font-size: 16px;
  word-break: break-word;
}

.out-text span {
  color: var(--muted);
  font-size: 13px;
}

/* Busy overlay shown while we wait for a long-running scrape. */
.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 32, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.busy-overlay[hidden] {
  display: none;
}

.busy-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  width: min(340px, 100%);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.busy-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border: 4px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: busy-spin 0.9s linear infinite;
}

@keyframes busy-spin {
  to { transform: rotate(360deg); }
}

.busy-title {
  font-size: 18px;
  margin-bottom: 6px;
}

.busy-detail {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.busy-elapsed {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Tablet portrait / large phone landscape */
@media (max-width: 820px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "title title"
      "machine date"
      "build  build";
  }
  .toolbar > div:first-child { grid-area: title; }
  .toolbar > label:nth-of-type(1) { grid-area: machine; }
  .toolbar > label:nth-of-type(2) { grid-area: date; }
  #loadButton { grid-area: build; width: 100%; }

  .pick-item {
    grid-template-columns: 70px 1fr;
    grid-template-areas:
      "qty product"
      "actions actions";
    gap: 10px;
  }

  .pick-actions > .check-action { min-height: 50px; }
}

/* Phones */
@media (max-width: 560px) {
  .app-shell { padding: 12px; }

  h1 { font-size: 22px; }

  .toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "machine"
      "date"
      "build";
    gap: 10px;
    padding: 12px;
  }

  .pick-item {
    grid-template-columns: 60px 1fr;
    grid-template-areas:
      "qty product"
      "actions actions";
    gap: 8px;
    padding: 10px;
  }

  .quantity { font-size: 28px; }
  .product strong { font-size: 17px; }
  .pick-actions > .check-action { min-height: 52px; font-size: 14px; }

  .status-row {
    padding: 10px 0 8px;
  }

  dialog {
    width: calc(100% - 16px);
  }

  .dialog-body { padding: 12px; }
}

/* -----------------------------------------------------------------------
 * Settings page (/settings.html)
 * ----------------------------------------------------------------------- */
.app-banner-link {
  color: #fff;
  text-decoration: none;
  padding: 4px 12px;
  min-height: 32px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.app-banner-link:hover { background: rgba(255, 255, 255, 0.25); }
/* `display: inline-flex` above wins over the browser default for
 * `[hidden]` (which is `display: none`), so a hidden banner link
 * would still render. Re-assert the hide here. */
.app-banner-link[hidden] { display: none; }

.settings-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.settings-shell h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.settings-page-status {
  margin: 0 0 16px;
  min-height: 1em;
  font-size: 14px;
  color: var(--muted);
}
.settings-page-status.is-error { color: var(--danger); }

.settings-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 18px;
}

.settings-section h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.settings-section h3 {
  margin: 18px 0 8px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 700;
}

.settings-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.settings-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.settings-inline-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  min-width: 200px;
  flex: 1 1 200px;
}
.settings-inline-form input,
.settings-inline-form select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}

.settings-status {
  font-size: 13px;
  color: var(--muted);
  min-height: 1em;
}
.settings-status.is-error { color: var(--danger); }

/* Credentials cards */
.cred-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 10px;
}
.cred-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.cred-card-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}
.cred-meta {
  font-size: 12px;
  color: var(--muted);
}
.cred-form {
  display: grid;
  gap: 10px;
}
.cred-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.cred-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}
.cred-reveal {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}
.cred-reveal input {
  min-height: 0;
  width: 16px;
  height: 16px;
  padding: 0;
}
.cred-btns {
  display: flex;
  gap: 8px;
}

/* Users table */
.settings-table-wrap {
  overflow-x: auto;
}
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.settings-table th,
.settings-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.settings-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-table tbody tr.is-me { background: var(--done); }
.settings-actions-col { width: 220px; }
.settings-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.settings-actions button { padding: 0 10px; font-size: 13px; min-height: 36px; }
.settings-table select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text);
}

/* Ghost-style buttons (secondary + destructive) */
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 600;
}
button.ghost:hover { border-color: var(--primary); color: var(--primary); }
button.ghost.danger { color: var(--danger); }
button.ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
button.ghost:disabled {
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
  background: transparent;
}

.role-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--line);
  color: var(--text);
}
.role-badge.is-platform {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
}
.user-pending-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #fff4d6;
  color: #8a5a00;
  border: 1px solid #f0d99a;
}

.settings-note {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.machines-counts { margin-bottom: 12px; }
.machines-count-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.machines-count-list li {
  background: var(--done);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

/* Group list on Settings */
.group-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--panel);
}
.group-item summary {
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.group-item summary strong { font-size: 15px; }
.group-body { margin-top: 12px; display: grid; gap: 10px; }
.group-members { display: grid; gap: 4px; max-height: 340px; overflow-y: auto; padding-right: 4px; }

.checklist-heading {
  margin: 6px 0 4px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.checklist-subheading {
  margin: 4px 0 2px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.checklist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 0;
}
.checklist-row input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

/* Per-user access expander row */
.user-access-row td {
  padding: 0 8px 12px !important;
}
.access-body {
  display: grid;
  gap: 14px;
  padding: 10px 12px;
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
  max-height: 480px;
  overflow-y: auto;
}
.user-access-row summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  padding: 6px 8px;
  display: inline-block;
}
.user-access-row summary::marker,
.user-access-row summary::-webkit-details-marker { color: var(--primary); }

@media (max-width: 640px) {
  .user-access-row td { padding: 6px 4px !important; }
  .access-body { padding: 8px; }
}

/* Platform-admin banner — a stronger tone so the page's blast radius
 * is visually obvious. */
.smeac-admin-banner {
  background: linear-gradient(135deg, #7a1c1c 0%, var(--danger) 100%);
}

/* ---- Mobile: settings + platform-admin pages -------------------------
 * The tables cram badly at narrow widths (role dropdowns shrink to just
 * an arrow, dates wrap to 5 lines). Stack each row into a labeled card
 * instead. Requires each td to have a data-label attr; see settings.js
 * and smeac-admin.js.
 */
@media (max-width: 640px) {
  .settings-shell {
    padding: 16px 12px 40px;
  }

  .app-banner-user {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 6px;
    font-size: 12px;
  }

  .settings-inline-form label {
    min-width: 0;
    flex: 1 1 100%;
  }
  .settings-inline-form button[type="submit"] {
    width: 100%;
  }

  .cred-card-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .cred-btns { flex-wrap: wrap; }
  .cred-btns button { flex: 1 1 auto; }

  .settings-table {
    display: block;
  }
  .settings-table thead {
    display: none; /* labels live on each cell via data-label */
  }
  .settings-table tbody,
  .settings-table tr {
    display: block;
  }
  .settings-table tr {
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }
  .settings-table tr.is-me {
    background: var(--done);
  }
  .settings-table td {
    display: block;
    padding: 6px 0;
    border-bottom: none;
  }
  .settings-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
  }
  .settings-table select {
    width: 100%;
  }
  .settings-actions {
    gap: 8px;
  }
  .settings-actions button {
    flex: 1 1 auto;
    min-width: 130px;
  }
  .settings-actions-col { width: auto; }
}
