/* ===========================================================================
   Trackdar — page stylesheet
   ---------------------------------------------------------------------------
   The pages were shipping with only the header/bottom-bar <style> block, so
   every form, card and tab below the header rendered as raw unstyled HTML.
   This file is the missing page stylesheet: a small dark design system that
   covers every class the pages actually use.

   Linked from each page with:
     <link rel="stylesheet" href="/styles.css" />
   =========================================================================== */

/* ---------- 1. base ------------------------------------------------------ */
:root {
  --bg: #0d1117;
  --bg-2: #11161d;
  --surface: #161b22;
  --surface-2: #1b222c;
  --line: #2a323d;
  --line-soft: rgba(255, 255, 255, 0.06);
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-mute: #6e7b8a;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --amber: #fbbf24;
  --green: #3fb950;
  --red: #f85149;
  --pink: #ff5db1;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 10px;
  line-height: 1.25;
  font-weight: 700;
}

h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.28rem;
}
h3 {
  font-size: 1.08rem;
}

p {
  margin: 0 0 10px;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

/* ---------- 2. layout ---------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 18px 40px;
}

/* Pages that carry the fixed mobile bottom bar reserve room for it. */
@media (max-width: 860px) {
  .wrap {
    padding: 16px 12px 96px;
  }
}

/* ---------- 3. cards ----------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 16px;
}

.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}

section.card + section.card {
  margin-top: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 18px;
  margin: 10px 0 0;
}

.info-grid > div,
.info-grid > p {
  margin: 0;
}

/* ---------- 4. buttons --------------------------------------------------- */
.btn,
.btn-primary,
.sc-btn,
.sc-primary,
.sc-secondary,
.action-btn,
.tc-btn,
.lc-filter-btn,
.auth-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease,
    transform 0.08s ease;
}

.btn:hover,
.sc-btn:hover,
.action-btn:hover,
.tc-btn:hover,
.lc-filter-btn:hover,
.auth-toggle-btn:hover {
  background: #222b36;
  border-color: #39434f;
  text-decoration: none;
}

.btn:active,
.sc-btn:active,
.action-btn:active,
.tc-btn:active {
  transform: translateY(1px);
}

.btn-primary,
.sc-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 700;
}

.btn-primary:hover,
.sc-primary:hover {
  background: #79b8ff;
  border-color: #79b8ff;
}

.sc-secondary {
  background: transparent;
  color: var(--text-dim);
}

.btn:disabled,
.sc-btn:disabled,
.form-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons that sit inline with an input keep their height. */
.search-row .btn,
.form-row .btn,
.watch-form-grid .btn {
  min-height: 40px;
}

/* ---------- 5. form controls --------------------------------------------- */
input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-mute);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* A plain text field in a page (everything except checkbox/radio). */
.form-input,
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="url"],
select,
textarea {
  display: block;
  width: 100%;
  padding: 9px 11px;
  min-height: 40px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  min-height: 0;
  margin: 0 7px 0 0;
  padding: 0;
  vertical-align: -3px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Checkboxes that carry a label beside them should not stretch. */
label > input[type="checkbox"],
label > input[type="radio"] {
  width: 17px;
}

label {
  font-size: 0.92rem;
  color: var(--text-dim);
}

.form-group {
  margin: 0 0 14px;
}

.form-group > label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.form-row > .form-group {
  flex: 1 1 200px;
  margin: 0;
}

/* Search box + button on one line. */
.search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}

.search-row > input,
.search-row > .form-input {
  flex: 1 1 220px;
  width: auto;
  max-width: 420px;
}

.watch-form-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.watch-form-grid > input {
  flex: 1 1 180px;
  width: auto;
  max-width: 260px;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Small helper text under a control. */
small,
.pane-desc,
.tc-sub,
.sc-sub {
  color: var(--text-dim);
  font-size: 0.86rem;
}

/* ---------- 6. section tabs --------------------------------------------- */
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.section-tab:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.section-tab.active,
.section-tab[aria-selected="true"] {
  color: #06121f;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.section-pane {
  display: none;
}

.section-pane.active {
  display: block;
}

/* ---------- 7. chips and badges ----------------------------------------- */
.chip,
.tag-badge,
.crs-tag,
.tiploc-tag,
.hc,
.chipOnly-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}

.hc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  letter-spacing: 0.03em;
}

.chip-ok {
  color: #7ee787;
  border-color: rgba(63, 185, 80, 0.4);
  background: rgba(63, 185, 80, 0.12);
}

.chip-bad {
  color: #ff9d96;
  border-color: rgba(248, 81, 73, 0.4);
  background: rgba(248, 81, 73, 0.12);
}

.crs-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
}

.tiploc-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  vertical-align: 1px;
}

/* ---------- 8. empty state ---------------------------------------------- */
.empty,
.empty-state {
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
  color: var(--text-dim);
  text-align: center;
  font-size: 0.92rem;
}

/* ---------- 9. tables ---------------------------------------------------- */
.sec-table,
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.sec-table th,
.sec-table td,
table th,
table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.sec-table th,
table th {
  color: var(--text-mute);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom-color: var(--line);
}

.sec-table tbody tr:hover,
table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Stat cards used on the boards/service pages. */
.sec-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.sec-stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.sec-stat-title {
  color: var(--text-mute);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 4px;
}

.sec-stat-value {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
}

/* ---------- 10. train cards --------------------------------------------- */
.tc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 12px;
}

.tc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.tc-hc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text);
}

.tc-arrow {
  color: var(--text-mute);
  margin: 0 2px;
}

.tc-route {
  font-weight: 600;
}

.tc-toc,
.tc-stock,
.tc-platform,
.tc-dep,
.tc-where,
.tc-looking {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.tc-state {
  font-weight: 700;
  font-size: 0.82rem;
}

.tc-amb {
  color: var(--amber);
}
.tc-coaches,
.tc-coupled {
  color: var(--text-mute);
  font-size: 0.82rem;
}

.tc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tc-btn {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 0.86rem;
}

.tc-link {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 600;
}

.tc-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- 11. station page -------------------------------------------- */
.station-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.station-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 16px;
}

.station-name-group h1 {
  margin: 0;
}

.station-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.station-map-preview {
  width: 100%;
  height: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg-2);
  margin: 0 0 16px;
}

/* ---------- 12. level crossings ----------------------------------------- */
.lc-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 12px;
}

.lc-name {
  font-weight: 700;
  font-size: 1rem;
}

.lc-meta,
.lc-type,
.lc-risk,
.lc-shut,
.lc-services {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.lc-risk {
  color: var(--amber);
}

.lc-svc-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
}

.lc-svc-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-dim);
}

.lc-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.lc-pop {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.lc-pop-head {
  font-weight: 700;
  margin: 0 0 6px;
}

.lc-pop-foot {
  color: var(--text-mute);
  font-size: 0.8rem;
  margin-top: 8px;
}

/* ---------- 13. settings / tree panes ----------------------------------- */
.settings-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}

.settings-sidebar {
  flex: 1 1 240px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.settings-content-pane {
  flex: 3 1 420px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.settings-wide {
  flex: 1 1 100%;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.pane-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.pane-section + .pane-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.tree-nav,
.tree-sub-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-sub-items {
  padding-left: 14px;
}

.tree-category {
  margin: 0 0 8px;
}

.tree-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tree-toggle-icon {
  width: 14px;
  display: inline-block;
  text-align: center;
  color: var(--text-mute);
}

.tree-item-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin: 2px 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}

.tree-item-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree-item-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 14. modals --------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card,
.sc-card {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.modal-header,
.sc-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.sc-title {
  font-size: 1.02rem;
}

.modal-body,
.sc-sub {
  padding: 16px;
}

.modal-close,
.sc-close {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.modal-close:hover,
.sc-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

/* ---------- 15. auth toggle --------------------------------------------- */
.auth-toggle-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.auth-toggle-btn {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 0.86rem;
}

.auth-toggle-btn.active,
.auth-toggle-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.45);
  color: var(--accent);
}

/* ---------- 16. map chrome ---------------------------------------------- */
.mapbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.hud-overlay {
  background: rgba(13, 17, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.cnt {
  font-weight: 700;
  color: var(--amber);
}

/* ---------- 17. misc ----------------------------------------------------- */
.hidden,
[hidden] {
  display: none !important;
}

.none {
  display: none;
}

.crs-tag > span,
.station-badges > span {
  white-space: nowrap;
}

/* Put a small caption under a section heading. */
.pane-desc {
  margin: -6px 0 14px;
  display: block;
}

/* Spinners / lookups. */
.tc-looking {
  font-style: italic;
}

/* ---------- 18. mobile --------------------------------------------------- */
@media (max-width: 700px) {
  body {
    font-size: 15px;
  }

  .wrap {
    padding: 14px 12px 100px;
  }

  .card,
  .station-card,
  .settings-content-pane,
  .lc-card {
    padding: 14px;
    border-radius: 12px;
  }

  h1 {
    font-size: 1.32rem;
  }
  h2 {
    font-size: 1.14rem;
  }

  .section-tabs {
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .section-tab {
    flex: 0 0 auto;
  }

  .search-row > input,
  .search-row > .form-input,
  .watch-form-grid > input {
    max-width: none;
    flex: 1 1 100%;
  }

  .search-row,
  .watch-form-grid,
  .form-row {
    gap: 8px;
  }

  .search-row .btn,
  .watch-form-grid .btn,
  .form-row .btn {
    flex: 1 1 auto;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .settings-layout {
    gap: 12px;
  }

  .settings-sidebar,
  .settings-content-pane,
  .settings-wide {
    flex: 1 1 100%;
  }

  .station-map-preview {
    height: 180px;
  }

  table {
    font-size: 0.86rem;
  }

  .sec-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}
