/* ------------------------------------------------------------------ */
/* Page titles / headings                                             */
/* ------------------------------------------------------------------ */
.layout h1.page-title,
.content h1.page-title {
  margin: 0 0 4px;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-1);
}

.section-title {
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text-1);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin: 20px 0 12px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-title .section-count,
.type-heading .type-count {
  color: var(--text-3);
}

@media (max-width: 900px) {
  .layout h1.page-title,
  .content h1.page-title {
    min-height: 40px;
    padding-left: 52px;
    margin: 0 0 12px;
    text-align: right;
    display: block;
    font-size: 26px;
  }
}

@media (max-width: 480px) {
  .layout h1.page-title,
  .content h1.page-title {
    font-size: 22px;
  }
}

/* ------------------------------------------------------------------ */
/* Buttons                                                            */
/* ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 5px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  min-height: 40px;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled,
.btn[disabled] { opacity: 0.6; cursor: default; filter: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: 5px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  min-height: 40px;
}

.btn-secondary:hover { background: #22c55e; border-color: #22c55e; color: #052e16; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid #ef4444;
  color: #ef4444;
  border-radius: 5px;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  min-height: 40px;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.12); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  min-height: 40px;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn-ghost:hover { background: var(--surface-2); }

.btn-small {
  padding: 8px 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-1);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-small:hover { border-color: var(--text-3); }
.btn-small.danger { color: var(--danger, #e5484d); border-color: var(--danger, #e5484d); background: transparent; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 9px 18px;
  color: var(--text-1);
  background: transparent;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  font-family: inherit;
  min-height: 40px;
}

.pill-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.pill-btn:hover:not([disabled]) { background: var(--bg); }
.pill-btn[disabled] { opacity: 0.6; cursor: default; }
.pill-btn-sm { padding: 6px 14px; font-size: 13px; background: var(--surface); min-height: 0; }
.pill-btn.pill-btn-sm[type="submit"] { margin-left: auto; }
.pill-btn-primary { background: var(--surface); color: var(--text-1); border: 1px solid var(--border); }
.pill-btn-primary:hover { background: #16a34a; border-color: #16a34a; color: #fff; }
.pill-btn-danger { color: #f87171; }

/* Icon-only buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-1);
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--bg, rgba(255, 255, 255, 0.06)); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn svg { width: 16px; height: 16px; display: block; }

.icon-btn-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
}

.icon-btn-danger:hover { background: rgba(239, 68, 68, 0.12); }

/* ------------------------------------------------------------------ */
/* Inputs / form controls                                             */
/* ------------------------------------------------------------------ */
.field-label {
  display: block;
  font-size: 17px;
  margin: 18px 0 6px;
  color: var(--text-1);
}

.field-label-sm {
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--text-2);
  font-weight: 700;
  margin: 0 0 6px;
}

.text-input,
input.text-input,
select.text-input,
textarea.text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-1);
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.text-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.text-input::placeholder { color: var(--text-3); }

textarea.text-input {
  min-height: 220px;
  resize: vertical;
}

select.text-input { appearance: auto; }

.hint {
  color: var(--text-1);
  opacity: 0.85;
  font-size: 14px;
  margin: 6px 0 0;
}

.form-error {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 5px;
  padding: 8px 12px;
  font-size: 13px;
}

/* Checkbox / radio row */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  color: var(--text-1);
}

.check input[type="checkbox"],
.check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Notices                                                            */
/* ------------------------------------------------------------------ */
.note-ok { color: var(--accent); font-weight: 600; font-size: 14px; margin: 8px 0 0; }
.note-err { color: var(--danger); font-weight: 600; font-size: 14px; margin: 8px 0 0; }
.note-pending { color: var(--warn); font-weight: 600; font-size: 14px; margin: 8px 0 0; }

/* ------------------------------------------------------------------ */
/* Swatches / livery indicators                                       */
/* ------------------------------------------------------------------ */
.swatches {
  display: flex;
  gap: 5px;
  align-items: center;
}

.swatch {
  width: 44px;
  height: 28px;
  border: 1px solid var(--border);
  display: inline-block;
  background: var(--surface-2);
  flex-shrink: 0;
}

.swatch-xs {
  width: 30px;
  height: 20px;
}

.swatch-sm {
  width: 36px;
  height: 24px;
}

.swatch-lg {
  width: 80px;
  height: 52px;
  border-radius: 3px;
}

.swatch-flip {
  transform: scaleX(-1);
}

.swatch-empty {
  background: var(--surface-2);
}

/* Livery swatch: the canonical livery colour block used in lists/cards */
.livery-swatch {
  width: 52px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: inline-block;
  vertical-align: middle;
}

.livery-swatch-sm {
  width: 34px;
  height: 22px;
}

.livery-swatch-md {
  width: 44px;
  height: 28px;
}

.livery-swatch-lg {
  width: 104px;
  height: 68px;
}

.train-livery-swatch {
  display: inline-block;
  width: 34px;
  height: 22px;
  border: 1px solid var(--border);
  background: #333;
  flex: none;
  vertical-align: middle;
}

.livery-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-right: 1px solid var(--border);
  padding: 6px 14px 6px 8px;
  font-size: 14px;
}

.livery-chip:last-child { border-right: 0; }
.livery-chip .livery-swatch { width: 34px; height: 22px; }
.livery-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.livery-chip .code-pill { margin: 0; }

@media (max-width: 480px) {
  .swatch { width: 36px; height: 24px; }
}

/* ------------------------------------------------------------------ */
/* Status / identity pills                                            */
/* ------------------------------------------------------------------ */
.code-pill {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--text-3);
}

.code-pill--defunct {
  border-color: rgba(248, 113, 113, 0.45);
  color: #f87171;
}

.ridden-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #22c55e;
  color: #22c55e;
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}

.unridden-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  color: var(--text-3);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 13px;
}

.spotted-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #38bdf8;
  color: #38bdf8;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.photo-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #c084fc;
  color: #c084fc;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.spotted-pill svg, .photo-pill svg { width: 12px; height: 12px; }
html[data-theme="light"] .spotted-pill { color: #0284c7; border-color: #0284c7; }
html[data-theme="light"] .photo-pill { color: #9333ea; border-color: #9333ea; }

.dashed-circle {
  width: 12px;
  height: 12px;
  border: 1.5px dashed var(--text-3);
  border-radius: 50%;
}

.trip-count { color: var(--text-3); font-size: 13px; }

/* ------------------------------------------------------------------ */
/* Common layout helpers                                              */
/* ------------------------------------------------------------------ */
.crumbs { margin: 0 0 8px; font-size: 13px; color: var(--text-3); }
.crumbs a { color: var(--text-3); text-decoration: none; }
.crumbs a:hover { color: var(--text-1); }
.crumbs span { margin: 0 6px; }

.progress {
  display: block;
  height: 8px;
  border-radius: 5px;
  background: var(--surface-2);
}

.progress > span { display: block; height: 100%; background: #22c55e; border-radius: 5px; }

.empty-state { color: var(--text-3); padding: 24px 0; }

.stat-cards { display: grid; gap: 16px; margin: 16px 0; }
.stat-cards-3 { grid-template-columns: repeat(3, 1fr); }
.stat-cards-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label { font-size: 13px; color: var(--text-3); }
.stat-value { font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 22px; }

@media (max-width: 900px) {
  .stat-cards-3, .stat-cards-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px 18px; border-radius: 5px; }
  .stat-value { font-size: 28px; }
}

@media (max-width: 640px) {
  .stat-cards-3, .stat-cards-4 { grid-template-columns: 1fr; }
}
