/* SPDX-FileCopyrightText: 2026 David Dalzell */
/* SPDX-License-Identifier: MIT */

/* Rail Car Movement Simulator */

.dialog-toast-container {
  position: sticky;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 10;
}

.chip-group {
  display: inline-flex;
  margin: 0.15rem 0.2rem 0 0;
  vertical-align: middle;
}

.cmap-add-chip,
.cmap-dismiss-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  margin: 0;
}

.chip-group .cmap-add-chip {
  border-radius: 4px 0 0 4px;
  border-right: none;
}

.chip-group .cmap-dismiss-chip {
  border-radius: 0 4px 4px 0;
  padding: 0.1rem 0.4rem;
}

.layout-item.layout-item-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
}

.layout-item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.ind-unmapped-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.25rem 0.1rem;
  border-top: 1px solid rgba(255,165,0,0.25);
  background: rgba(255,165,0,0.06);
}

.ind-unmapped-label {
  font-size: 0.75rem;
  color: var(--badge-orange, #e67e22);
  font-weight: 600;
  white-space: nowrap;
}

body {
  font-family: "Red Rose", system-ui, sans-serif;
  padding-top: 4.5rem;
}

.brand {
  font-family: "Montserrat Alternates", system-ui, sans-serif;
}

#car-detail-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#close-detail-dialog {
  margin-left: auto;
  width: auto;
}


:root {
  --rail-accent:    #c0392b;
  --rail-accent-bg: #fdf3f2;
  --rail-dark:      #2c3e50;
  --rail-darker:    #212f3c;
  --rail-light:     #ecf0f1;
  --rail-red:       #e74c3c;
  --card-radius:    8px;

  --bg-muted:         #f4f4f4;
  --border-light:     #ddd;
  --border-muted:     #aaa;
  --border-subtle:    #eee;
  --text-muted:       #888;
  --text-secondary:   #555;
  --text-light:       #777;
  --text-placeholder: #666;
  --text-strong:      #333;

  /* Adaptive: light-mode defaults */
  --consist-card-bg:     #f0f2f4;
  --consist-card-border: #d0d5db;
  --info-offer-bg:       #f0f2f4;
  --car-img-bg:          #FAF0E6;

  --rail-blue:      #2980b9;
  --badge-blue:     #2980b9;
  --badge-muted-bg: #bdc3c7;
  --badge-muted-fg: #555;
  --badge-green:    #27ae60;
  --badge-purple:   #8e44ad;
  --badge-orange:   #d68910;

  --rail-green: #5c7a3e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --consist-card-bg:     var(--rail-darker);
    --consist-card-border: var(--rail-dark);
    --info-offer-bg:       var(--rail-dark);
    --car-img-bg:          #2a2a2a;
    --bg-muted:            #2a2a2a;
  }
}

[data-theme="dark"] {
  --consist-card-bg:     var(--rail-darker);
  --consist-card-border: var(--rail-dark);
  --info-offer-bg:       var(--rail-dark);
  --car-img-bg:          #2a2a2a;
  --bg-muted:            #2a2a2a;
}

main.container {
  max-width: 1024px;
}

/* ── Header & navigation ─────────────────────────────────────────────────── */
header.container-fluid {
  background: var(--rail-dark);
  padding: 0.4rem 1rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.nav-hamburger { display: none; }
.nav-current-tab { display: none; }

header nav .brand {
  color: var(--rail-light);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

header nav .brand-rail {
  color: var(--rail-red);
}

header nav a {
  color: var(--rail-light);
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  transition: background 0.15s;
  text-decoration: none;
}

header nav a:hover:not(.active) {
  background: rgba(255,255,255,0.1);
}

header nav a.active {
  background: var(--rail-red);
  color: white;
  font-weight: 600;
}

/* ── Toast notifications ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--rail-dark);
  color: var(--rail-light);
  padding: 0.65rem 1rem;
  border-radius: var(--card-radius);
  font-size: 0.875rem;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: var(--badge-green); }
.toast.error   { background: var(--rail-accent); }
.toast.warn    { background: var(--badge-orange); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--text-strong);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.35rem;
}

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2,
.section-header h3 {
  margin: 0;
}

.section-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Car grid ────────────────────────────────────────────────────────────── */
.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.car-card {
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.car-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.car-thumb {
  height: 130px;
  background: var(--car-img-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.car-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.2s;
}

.car-card:hover .car-thumb img {
  transform: scale(1.05);
}

.no-photo {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.5rem;
}

.no-photo.small {
  font-size: 0.7rem;
  padding: 0.25rem;
}

.default-car-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--car-img-bg);
}

.car-type-thumb {
  width: 48px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  background: #eee;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.car-info {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.car-type     { color: var(--text-secondary); }
.car-color    { color: var(--text-light); font-style: italic; }
.car-location { font-weight: 600; }

.waybill-badge {
  margin-top: 4px;
  font-size: 0.75rem;
  background: var(--badge-blue);
  color: white;
  border-radius: 4px;
  padding: 2px 6px;
  display: inline-block;
}

.waybill-badge.muted {
  background: var(--badge-muted-bg);
  color: var(--badge-muted-fg);
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-muted);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1rem;
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-zone label {
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-placeholder);
}

#upload-preview {
  text-align: center;
  margin-bottom: 1rem;
}

#upload-preview img {
  max-height: 200px;
  max-width: 100%;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-light);
}

.error-msg {
  color: var(--rail-accent);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ── Car detail dialog ───────────────────────────────────────────────────── */
#car-detail-dialog article {
  max-width: 680px;
  max-height: 80vh;
  overflow-y: auto;
}

.dialog-footer-primary {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  justify-content: center;
}

.dialog-footer-secondary {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.dialog-footer-primary button,
.dialog-footer-secondary button {
  flex: 1;
  max-width: 160px;
}

#btn-advance-waybill,
#btn-edit-waybills {
  max-width: 240px;
}

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-photo {
  width: 270px;
  height: 195px;
  object-fit: contain;
  background: var(--car-img-bg);
  border-radius: var(--card-radius);
  border: 1px solid var(--border-light);
}

/* ── Waybill cards ───────────────────────────────────────────────────────── */
.waybill-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.waybill-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--pico-card-background-color, #f9f9f9);
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.waybill-row.active-slot {
  border-color: var(--rail-accent);
  background: var(--rail-accent-bg);
}

.slot-num {
  font-weight: bold;
  min-width: 1.5rem;
  color: var(--text-muted);
}

.industry-tag {
  margin-left: auto;
  font-size: 0.75rem;
  background: var(--badge-green);
  color: white;
  border-radius: 4px;
  padding: 2px 6px;
  min-width: 110px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Waybill editor dialog ───────────────────────────────────────────────── */
#waybill-dialog article {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

.waybill-slot {
  border: 1px solid var(--border-light);
  border-radius: var(--card-radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.waybill-slot.active-slot {
  border-color: var(--rail-accent);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ── Operations view ─────────────────────────────────────────────────────── */
.ops-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: var(--pico-card-background-color, #f9f9f9);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

/* ── Layout setup ────────────────────────────────────────────────────────── */
.layout-grid {
  gap: 2rem;
}

.inline-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--card-radius);
  margin-bottom: 0.75rem;
  background: var(--pico-card-background-color, #fafafa);
}

.inline-form input,
.inline-form select {
  margin-bottom: 0;
}

.inline-form .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.suggest-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.suggest-row input {
  flex: 1;
  margin-bottom: 0;
}

.ai-suggest-btn {
  white-space: nowrap;
  flex-shrink: 0;
  margin-bottom: 0;
}

.layout-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  gap: 0.5rem;
}

.layout-item span:last-child {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

/* ── Waybill pool ────────────────────────────────────────────────────────── */
.pool-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}

.pool-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pool-item-meta { white-space: nowrap; }

.pool-item-actions {
  display: flex;
  gap: 0.25rem;
}

/* ── Slot assignment rows ────────────────────────────────────────────────── */
.slot-assign-row {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.4rem;
  background: var(--pico-card-background-color, #f9f9f9);
  border: 1px solid transparent;
}

.slot-assign-row.active-slot {
  border-color: var(--rail-accent);
  background: var(--rail-accent-bg);
}

.slot-picker { margin-bottom: 0; }

/* ── Empty states ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin: 0;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.muted   { color: var(--text-muted); font-size: 0.85rem; }
.empty-msg { color: var(--text-muted); font-style: italic; margin-top: 1rem; }
.ml-sm   { margin-left: 0.5rem; }
.mb-md   { margin-bottom: 1rem; }

button.small {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

.btn-confirming {
  background-color: var(--rail-accent) !important;
  border-color: var(--rail-accent) !important;
  color: white !important;
}

.edit-photo-label {
  cursor: pointer;
  align-self: center;
}

.we-empty-label {
  align-self: flex-end;
  padding-bottom: 0.5rem;
}

/* ── Commodity autocomplete ──────────────────────────────────────────────── */
.commodity-wrap { position: relative; margin-bottom: 0; }

.suggestion-dropdown {
  position: absolute;
  z-index: 200;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: var(--card-radius);
  max-height: 180px;
  overflow-y: auto;
  padding: 0;
  margin: 2px 0 0;
  list-style: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.suggestion-item {
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.suggestion-item:hover {
  background: var(--pico-secondary-background, #f4f4f4);
}

.suggestion-car-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Edit car photo ──────────────────────────────────────────────────────── */
.edit-photo-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.edit-thumb {
  width: 100px;
  height: auto;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-light);
  display: none;
}

.edit-photo-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.edit-photo-buttons .edit-photo-label,
.edit-photo-buttons button {
  width: 100%;
  margin: 0;
}

.edit-photo-buttons .edit-photo-label span {
  display: block;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

/* ── Stylize section ─────────────────────────────────────────────────────── */
#stylize-section {
  position: relative;
  margin: 0.75rem 0;
  padding: 0.75rem;
  padding-top: 1.6rem;
  border: 1px solid var(--pico-form-element-border-color);
  border-radius: var(--card-radius);
  background: var(--pico-form-element-background-color);
}

.ai-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: gold;
  background: transparent;
  border: none;
  padding: 1px 6px;
  line-height: 1.4;
}

#btn-stylize {
  background: var(--badge-blue) !important;
  color: gold !important;
  border-color: gold !important;
}

#stylize-idle,
#stylize-processing {
  text-align: center;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

.stylize-compare {
  text-align: center;
  margin-bottom: 0.75rem;
}

#stylize-preview {
  max-height: 220px;
  max-width: 100%;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-light);
}

/* ── Photo library ───────────────────────────────────────────────────────── */
#photo-library-dialog article {
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
}

.photo-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.lib-thumb {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  aspect-ratio: 4/3;
  background: var(--bg-muted);
}

.lib-thumb:hover { border-color: var(--rail-accent); }

.lib-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.lib-thumb.lib-assigned { opacity: 0.6; }

.lib-thumb.lib-selected {
  border-color: var(--rail-accent);
  outline: 2px solid var(--rail-accent);
}

.lib-thumb.lib-selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--rail-accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lib-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: var(--badge-blue);
  color: white;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
}

.lib-badge-default {
  background: var(--rail-green);
}

.upload-zone-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-zone-sep {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Needs-move highlight ────────────────────────────────────────────────── */
.car-needs-move {
  border: 2px solid var(--badge-orange);
}

.car-needs-move .waybill-badge {
  background: var(--badge-orange);
}

.ops-row.car-needs-move {
  border-left: 4px solid var(--badge-orange);
}

/* ── End-session dialog ──────────────────────────────────────────────────── */
#end-session-dialog article {
  max-width: 560px;
}

.session-warnings {
  background: #fef9e7;
  border: 1px solid var(--badge-orange);
  border-radius: var(--card-radius);
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: #7d6608;
}

.session-progress {
  text-align: right;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.session-progress-label {
  font-size: 0.85rem;
  align-self: center;
}

#ops-clock-bar {
  position: sticky;
  top: 4.5rem;
  z-index: 500;
  background: var(--rail-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.4rem 1rem;
  margin-bottom: 0.75rem;
}

.fast-clock {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--rail-dark);
  border-radius: 6px;
  padding: 0.2rem 0.6rem 0.2rem 0.7rem;
}

#clock-time {
  font-family: "Courier New", Courier, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #e8f5e9;
  min-width: 4.5ch;
}

.help-section {
  border: 1px solid var(--border-light);
  border-radius: var(--card-radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.help-section-header {
  width: 100%;
  text-align: left;
  background: var(--pico-card-background-color, #fafafa);
  border: none;
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--badge-blue);
  margin-bottom: 0;
}

.help-section-header:hover {
  background: var(--bg-muted);
}

.help-section-body {
  padding: 0.75rem 1rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  border-top: 1px solid var(--border-light);
}

.help-section-body p {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.help-section-body ul {
  margin: 0 0 0.5rem 1.2rem;
  padding: 0;
}

.help-section-body li {
  margin-bottom: 0.25rem;
}

.clock-btn {
  width: 3rem !important;
  min-width: 3rem !important;
  max-width: 3rem !important;
  padding: 0.15rem 0 !important;
  text-align: center;
  font-size: 0.8rem;
  margin-bottom: 0;
  border-color: rgba(255,255,255,0.3) !important;
  color: rgba(255,255,255,0.8) !important;
  background: transparent !important;
}

.session-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0.75rem 0 0.4rem;
}

.session-car-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: var(--pico-card-background-color, #f9f9f9);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  transition: opacity 0.2s;
}

.session-car-row.done {
  opacity: 0.45;
  text-decoration: line-through;
}

.session-car-row.done button { display: none; }

.session-car-row.cp {
  border: 4px solid var(--badge-orange);
  background: var(--rail-dark);
}

.session-car-row .session-btn-row {
  display: flex;
  gap: 0.4rem;
}

.session-car-info  { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.session-car-marks { font-weight: 600; }
.session-car-move  { color: var(--text-muted); font-size: 0.8rem; }

.session-car-thumb {
  width: 60px;
  height: 48px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--car-img-bg);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.session-car-thumb.clickable-thumb {
  cursor: pointer;
}
.session-car-thumb.clickable-thumb:hover {
  outline: 2px solid var(--rail-accent);
  outline-offset: 1px;
}

.session-car-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

.no-photo-thumb {
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2px;
}

.cp-car-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}
.cp-car-row:last-child { border-bottom: none; }
.cp-car-label { flex: 1; font-weight: 600; }

/* ── Mobile (≤ 600px) ────────────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* Navigation — hamburger dropdown */
  .nav-current-tab {
    display: inline;
    color: var(--rail-light);
    font-size: 0.9rem;
    opacity: 0.75;
    margin-left: auto;
    align-self: center;
    padding-right: 0.25rem;
  }

  .nav-hamburger {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--rail-light);
    font-size: 1.5rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    min-height: 36px;
  }

  #nav-tab-list {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--rail-dark);
    padding: 0.5rem;
    gap: 0.4rem;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin: 0;
  }

  #nav-tab-list.nav-open {
    display: flex;
  }

  #nav-tab-list {
    padding: 0.25rem 0;
    margin: 0;
    padding-inline-start: 0;
  }

  #nav-tab-list li {
    padding: 0;
    margin: 0;
    padding-inline-start: 0;
  }

  #nav-tab-list a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 0.95rem;
  }

  /* Main container — tighter side padding */
  main.container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Car grid — 2 columns, smaller cards */
  .car-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.65rem;
  }

  /* All dialogs — full-width bottom sheet */
  dialog article {
    max-width: 100% !important;
    max-height: 90vh;
    margin: 0;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  /* Car detail — stack photo above info */
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-photo {
    width: 100%;
    height: 180px;
  }

  /* Dialog footers — stack buttons vertically */
  .dialog-footer-primary,
  .dialog-footer-secondary {
    flex-direction: column;
  }

  .dialog-footer-primary button,
  .dialog-footer-secondary button {
    width: 100%;
  }

  /* Two-column form grids → single column */
  .grid {
    grid-template-columns: 1fr !important;
  }

  /* Layout setup: locations + industries stack */
  .layout-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Operations row — thumbnail + info on top, actions span full width below */
  .ops-row {
    grid-template-columns: 72px 1fr;
    grid-template-rows: auto auto;
  }

  .ops-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 0.25rem;
  }

  /* Waybill pool — info on top row, meta below, actions span both rows */
  .pool-item {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .pool-item-meta {
    grid-column: 1;
    grid-row: 2;
  }

  .pool-item-actions {
    grid-row: 1 / 3;
    align-self: center;
  }

  /* Touch targets — 44px minimum height */
  button,
  [role="button"],
  a.outline {
    min-height: 44px;
  }

  /* Pico close button — keep square, not squished by min-height */
  button[rel="prev"] {
    min-width: 44px;
  }

  button.small {
    min-height: 36px;
    font-size: 0.85rem;
  }

  /* Toast — full width */
  #toast-container {
    left: 0.75rem;
    right: 0.75rem;
  }

  .toast {
    max-width: 100%;
  }

  /* Section headers — allow wrap */
  .section-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .section-header .button-row {
    margin-top: 0;
  }

  /* Upload zone — tighter */
  .upload-zone {
    padding: 1rem;
  }

  /* Session ops header — wrap controls, keep Cancel/End on own row */
  #ops-header-buttons {
    flex-wrap: wrap;
    width: 100%;
  }
  #btn-cancel-session,
  #btn-end-session {
    flex: 1;
  }

  /* Session car rows — prevent text overflow and button spillage */
  .session-car-info {
    min-width: 0;
  }
  .session-car-marks,
  .session-car-move {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .session-btn-row {
    flex-shrink: 0;
  }
  .session-car-row .industry-tag {
    flex-shrink: 0;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Car Roster header — title on its own line, buttons wrap below */
  #tab-roster > .section-header > h2 {
    flex: 0 0 100%;
  }

  /* Car detail dialog — full-width buttons, no desktop max-width */
  .dialog-footer-primary,
  .dialog-footer-secondary {
    justify-content: stretch;
    align-items: stretch;
  }
  .dialog-footer-primary button,
  .dialog-footer-secondary button,
  #btn-advance-waybill,
  #btn-edit-waybills {
    width: 100%;
    max-width: none;
  }
}

/* ── Power strip (session header / dispatcher consist) ───────────────────── */
.session-power-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--pico-card-background-color, #f5f0e8);
  border: 1px solid var(--pico-muted-border-color, #d9cfc4);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.power-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.4rem;
  background: var(--pico-secondary-background, #e8e0d5);
  border-radius: 4px;
}

.power-chip img,
.power-chip > span:first-child {
  width: 60px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--car-img-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.power-chip-marks {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.power-strip-sep {
  color: var(--pico-muted-color);
  font-size: 0.8rem;
}

.power-strip-empty {
  display: inline-flex;
  align-items: center;
  height: 52px;
  color: var(--text-muted, #888);
  font-size: 0.75rem;
  font-style: italic;
}

.power-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  margin-left: 0.1rem;
}
.power-chip-remove:hover {
  color: var(--rail-accent, #c0392b);
}

/* Consist card status badges */
.status-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}
.status-draft    { background: #d4d4d4; color: #555; }
.status-active   { background: #2a9d8f; color: #fff; }
.status-complete { background: #457b9d; color: #fff; }

/* Consist cards */
.consist-card {
  background: var(--consist-card-bg);
  border: 1px solid var(--consist-card-border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.consist-body {
  padding-top: 0.5rem;
}

/* ── Spotting Conflicts ───────────────────────────────────────────────────── */
.conflict-panel {
  background: color-mix(in srgb, var(--badge-orange) 12%, var(--card-background-color));
  border: 1px solid var(--badge-orange);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.conflict-panel-title {
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--badge-orange);
}

.conflict-group {
  margin-bottom: 0.75rem;
}

.conflict-group:last-child {
  margin-bottom: 0;
}

.conflict-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.conflict-car-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.conflict-will-spot {
  background: color-mix(in srgb, var(--color-valid, #27ae60) 10%, transparent);
}

.conflict-will-cp {
  background: color-mix(in srgb, var(--badge-orange) 10%, transparent);
  opacity: 0.8;
}

.conflict-car-marks {
  flex: 1;
  font-weight: 500;
}

.aging-badge {
  font-size: 0.75rem;
  background: var(--badge-orange);
  color: #fff;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
}

.priority-badge {
  font-size: 0.75rem;
  color: var(--muted-color, #888);
  white-space: nowrap;
}

.conflict-disposition {
  min-width: 3.5rem;
  text-align: right;
}

.info-offer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--info-offer-bg);
  border-radius: 6px;
  margin-top: 0.5rem;
}

.warning-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.tab-badge {
  display: inline-block;
  margin-left: 0.35rem;
  background: #dc3545;
  color: #fff;
  font-size: 0.7rem;
  font-weight: bold;
  border-radius: 10px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  line-height: 1.3;
}

.car-type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0;
}

.ct-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  margin: 0;
}

.ct-pill input[type="checkbox"] {
  display: none;
}

.ct-pill:has(input:checked) {
  background: var(--pico-primary-background, #1a6fb5);
  border-color: var(--pico-primary-background, #1a6fb5);
  color: #fff;
}
