/* Re-auth banner - the server rejected this device's token. The app
   stays fully usable behind it; only sync is paused. Sits below both
   overlays (9600 / 9999) so a real login screen always wins. */
#reauthBanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: #2e2205;
  border-bottom: 1px solid var(--warning);
  color: var(--warning);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
}
/* Push the page down by the banner's height so it never covers the
   header. Higher specificity than the base body rule, so it wins. */
body.reauth-pending {
  padding-top: calc(74px + var(--safe-top));
}
@media print {
  #reauthBanner {
    display: none !important;
  }
}

/* Existing UI Elements */
#gatekeeperOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0f172a;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.gatekeeper-card {
  background: var(--card-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  /* Never taller than the overlay's padded area: both overlays that use
     this card (the sign-in gatekeeper and the project picker) centre it
     in a fixed full-screen flex overlay, so an over-tall card used to
     overflow the screen equally at the top and the bottom with nothing
     able to scroll - the picker was unusable on a laptop-height window
     with a long project list (owner report, 2026-11-10). Capping the
     height and scrolling inside the card leaves the layout untouched
     when the content fits, and rescues it when it does not. */
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.gatekeeper-input {
  margin-top: 16px;
  text-align: center;
  font-size: var(--fs-lg);
  letter-spacing: 1px;
}
/* In-app modal — replaces native alert/confirm/prompt so dialogs
           match the app's own look instead of the browser chrome. Driven
           entirely by appAlert()/appConfirm()/appPrompt() in the script
           below; this is just the shared shell. */
.app-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
}
/* The shared alert/confirm/prompt box must always sit above every
           other modal (including the photo lightbox at 20000) - it can be
           triggered from inside any of them, e.g. the duplicate-asset
           warning fired while the Add Asset modal is still open. */
#appModalOverlay {
  z-index: 21000;
}
.app-modal-box {
  background: var(--card-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}
.app-modal-message {
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text-main);
  white-space: pre-line;
  margin-bottom: 16px;
}
.app-modal-input-wrap input {
  margin-bottom: 16px;
}
.app-modal-actions {
  display: flex;
  gap: 10px;
}
.app-modal-actions .btn,
.app-modal-actions .btn-secondary {
  margin-bottom: 0;
  flex: 1;
  width: auto;
}
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--primary);
  line-height: 1.15;
  text-wrap: balance;
  min-width: 0;
  flex: 1;
}
.status-badge {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.status-badge.synced {
  background: rgba(74, 222, 128, 0.1);
  color: var(--success);
}
.status-badge.offline {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}
/* Waiting to send / no signal with work on the phone (Nov 2026). */
.status-badge.waiting,
.status-line #syncStatus.waiting,
.status-line #syncStatus.offline.waiting {
  color: var(--warning);
}
/* The "2 waiting · 5 stored · 3 h ago" line is a button: tap for the list. */
.status-counts-btn {
  background: none;
  border: 0;
  /* A full 44px tap target that still sits in the line like plain text. */
  min-height: 44px;
  padding: 0;
  margin: -12px 0;
  display: block;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
/* "Last synced 3 h ago" gets its own line under the counts: as a suffix
   on the counts line it was the first thing truncated on narrow phones,
   and unlabelled it read as if nothing had happened since. */
.status-last {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-top: 2px;
}
/* While work is waiting, Sync fills in — it should look pressable
   exactly when pressing it matters. */
.status-sync.has-waiting {
  background: var(--primary);
  border-color: transparent;
  color: #ffffff;
}
/* While a sync runs, the button pulses for the whole run — a press
   must be visibly answered from tap to finish, including the long
   download phase when nothing is being sent. */
.status-sync.is-syncing {
  animation: syncing-pulse 1.2s ease-in-out infinite;
}
@keyframes syncing-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}
.storage-banner {
  margin: -6px 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--warning);
  background: rgba(245, 158, 11, 0.08);
  color: var(--text-main);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-dark);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  text-align: center;
}
/* Cards previously relied on a 1px border alone for definition
           against the near-identical dark page background - this soft
           shadow gives them a touch of lift without changing layout or
           risking any measurements. Applies to the main content card
           types; doesn't touch overlays/modals, which already have their
           own stronger shadow for a different reason (floating above
           everything, not just resting on the page). */
.stat-card,
.equipment-card,
.part-card,
.tower-card,
.log-item,
.form-panel {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.stat-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-lbl {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
}
.btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: var(--fs-lg);
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  transition:
    transform 0.1s ease,
    filter 0.1s ease;
}
.btn:active,
.btn-secondary:active,
.btn-action:active,
.btn-folder-toggle:active,
.btn-subfolder-toggle:active,
.btn-proc-tab:active,
.checklist-toggle:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}
.btn,
.btn-secondary,
.btn-action,
.btn-folder-toggle,
.btn-subfolder-toggle,
.btn-proc-tab,
.checklist-toggle {
  transition:
    transform 0.1s ease,
    filter 0.1s ease;
}
.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
}
.btn-success {
  background-color: transparent;
  border: 2px solid var(--success);
  color: var(--success);
}
.btn-secondary {
  /* Same full-size footprint as .btn - CLOSE/CANCEL buttons used to
     render at tiny native-button size, easy to miss on a phone. Rows
     that genuinely need a small pill (STAMP, OPEN) override with
     inline padding/margin, which wins over this. */
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: var(--fs-lg);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  background-color: var(--card-dark);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.action-tray {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.btn-action {
  width: 100%;
  /* Same surface-glass pattern as .btn-secondary (7.6): the old dark
     fill + dashed border read as "not a button" next to the rest. */
  background: var(--surface-glass);
  border: 1px solid var(--surface-glass-border);
  color: var(--text-main);
  padding: 12px;
  font-size: var(--fs-sm);
  font-weight: bold;
  border-radius: var(--radius-xs);
  cursor: pointer;
  text-align: center;
}
.btn-action.active-panel {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--primary);
}
.btn-action.fault-active {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}
.search-box {
  position: relative;
  margin-bottom: 14px;
}
.search-box input {
  padding-left: 40px;
  background: var(--card-dark);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--fs-lg);
}
.chat-stream {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: bold;
}
.chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-input-row input {
  padding: 10px;
  font-size: var(--fs-sm);
}
.form-panel {
  display: none;
  background: var(--card-dark);
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  margin-bottom: 30px;
}

/* Self-serve shaping (Nov 2026): project-picker group headings for the
   unit owner tag, the trial banner's Keep-it-live button, and the setup
   wizard / checklist. */
.picker-group-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 8px;
}
.picker-group-label:first-child {
  margin-top: 0;
}
.plan-banner-action {
  margin-top: 10px;
  width: auto;
  padding: 9px 16px;
  min-height: 44px;
}
.setup-progress {
  display: flex;
  gap: 6px;
  margin: 12px 0 18px;
}
.setup-progress span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}
.setup-progress span.on {
  background: var(--primary, #38bdf8);
}
.setup-step-note {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: 12px;
}
.setup-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin-bottom: 10px;
}
.btn.setup-check-row {
  text-align: left;
  justify-content: flex-start;
}
.btn.setup-check-row .btn-label-group {
  align-items: flex-start;
  text-align: left;
}
.setup-check-tick {
  font-size: 1.1rem;
  flex: none;
}
