:root {
  --navy: #14264a;
  --navy-2: #1f3868;
  --blue: #3b7dd8;
  --blue-soft: #dce9fb;
  --yellow: #ffcf3f;
  --yellow-soft: #fff3cd;
  --green: #2e9e5b;
  --green-soft: #e2f5e9;
  --red: #d63b3b;
  --red-soft: #fbe3e3;
  --ink: #22293a;
  --muted: #6b7385;
  --bg: #eef1f7;
  --card: #ffffff;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    ui-rounded,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

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

a.dark-bg {
  color: var(--blue-soft);
}

a.use-underline:hover,
a.use-underline:focus {
  text-decoration: underline;
}

.centered {
  text-align: center;
}

/* ---------- top bar ---------- */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 4px solid var(--yellow);
}

.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.5px;
}

.brand .roundel {
  display: inline-block;
  background: var(--yellow);
  color: var(--navy);
  border-radius: 50%;
  width: 1.6em;
  height: 1.6em;
  line-height: 1.6em;
  text-align: center;
  margin-right: 4px;
}

.topbar .tag {
  font-size: 0.75rem;
  opacity: 0.75;
}

/* ---------- cards & panels ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 1px 4px rgba(20, 38, 74, 0.08);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  margin: 10px 0;
}

.error:empty {
  display: none;
}

/* ---------- buttons & forms ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  color: #fff;
  background: var(--navy-2);
}

.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.45;
}

.btn.accent {
  background: var(--yellow);
  color: var(--navy);
}
.btn.subtle {
  background: #e3e7ef;
  color: var(--navy);
}
.btn.danger {
  background: #fff;
  color: var(--red);
  border: 2px solid var(--red);
}
.btn.big {
  display: block;
  width: 100%;
  font-size: 1.25rem;
  padding: 18px;
}

.btn.small {
  font-size: 0.95rem;
  padding: 11px;
}

.btn-link {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--blue);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  display: inline;
  -webkit-appearance: none;
  text-decoration: none;
}

.btn-link:hover,
.btn-link:focus {
  text-decoration: underline;
}

.btn-link.dark-bg {
  color: var(--blue-soft);
}

.ian-container {
  color: red;
}

.row {
  display: flex;
  gap: 10px;
}
.row > * {
  flex: 1;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px;
  border: 2px solid #cfd6e4;
  border-radius: 12px;
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
}

label.field {
  display: block;
  font-weight: 700;
  margin: 12px 0 4px;
}

fieldset {
  border: none;
}

.header-actions {
  display: flex;
  flex-direction: row;
  gap: 15px;
  align-items: center;
}

.header-action-item {
  padding-right: 15px;
  border-right: 1px solid #ddd;
}

/* ---------- home ---------- */

.hero {
  text-align: center;
  padding: 40px 0 10px;
}
.hero .big-roundel {
  font-size: 3.5rem;
  background: var(--navy);
  border-radius: 50%;
  width: 110px;
  height: 110px;
  line-height: 110px;
  margin: 0 auto 12px;
}
.hero h1 {
  margin: 0;
  font-size: 2rem;
  color: var(--navy);
}
.hero p {
  color: var(--muted);
  margin: 6px 0 24px;
}

.role-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 14px 0;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(20, 38, 74, 0.08);
  border: 2px solid transparent;
}
.role-btn:active {
  border-color: var(--blue);
}
.role-btn .emoji {
  font-size: 2.2rem;
}
.role-btn .sub {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

/* ---------- station / cab ---------- */

.now-panel {
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 22px 16px;
}

.now-panel .kicker {
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--yellow);
  font-weight: 700;
}

.now-panel .big {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 6px 0;
  overflow-wrap: anywhere;
}

.now-panel .next {
  color: #c6d2e8;
  font-size: 0.95rem;
}

.route-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 4px;
}

.stop {
  text-align: center;
  width: 64px;
  font-size: 0.65rem;
  color: #c6d2e8;
}
.stop .dot-line {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin: 0 auto 4px;
  background: #3a5185;
}
.stop.done .dot-line {
  background: var(--green);
}
.stop.now .dot-line {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 207, 63, 0.3);
}
.stop.now {
  color: var(--yellow);
  font-weight: 700;
}

/* new train-news alerts flash briefly so the driver notices */
@keyframes flash-new {
  from {
    background: var(--yellow-soft);
  }
  to {
    background: transparent;
  }
}
#alertsList div {
  padding: 4px 6px;
  border-radius: 8px;
}
#alertsList div.fresh {
  animation: flash-new 2.5s ease-out;
}

/* camera scan overlay (driver's cab) */
#scanOverlay[hidden] {
  display: none;
}

#scanOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
}
#scanOverlay video {
  width: 100%;
  max-width: 560px;
  max-height: 60vh;
  border-radius: 16px;
  background: #000;
}
#scanOverlay .scan-hint {
  color: var(--yellow);
  font-weight: 700;
}
#scanOverlay .btn {
  width: 100%;
  max-width: 560px;
}

/* the passenger's own stations on their ticket's route map */
.mine-word {
  margin-top: 2px;
  font-weight: 800;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
}

.mine-legend {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #c6d2e8;
}
.mine-legend .leg-now {
  color: var(--yellow);
}
.mine-legend .leg-done {
  color: var(--green);
}

/* ---------- ticket check result ---------- */

.check-result {
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin: 14px 0;
}
.check-result .reason {
  font-size: 1.6rem;
  font-weight: 800;
}
.check-result .detail {
  margin-top: 6px;
  font-size: 1.05rem;
}
.check-result.ok {
  background: var(--green-soft);
  color: var(--green);
}
.check-result.fail {
  background: var(--red-soft);
  color: var(--red);
}

input.code-input {
  text-transform: uppercase;
  letter-spacing: 6px;
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
}

/* ---------- seat map ---------- */

.seatmap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.seat {
  border-radius: 12px 12px 8px 8px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid transparent;
  position: relative;
}

/* aisle gap down the middle of the car */
.seat:nth-child(4n + 3) {
  margin-left: 16px;
}
.seat:nth-child(4n + 2) {
  margin-right: 16px;
}

.seat .who {
  font-size: 0.62rem;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.seat.available {
  background: #fff;
  border-color: var(--green);
  color: var(--green);
}
.seat.booked {
  background: var(--yellow-soft);
  border-color: var(--yellow);
  color: #9a7b12;
}
.seat.aboard {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.seat.pickable input {
  position: absolute;
  opacity: 0;
}
.seat.pickable {
  cursor: pointer;
}
.seat.pickable:has(input:checked),
.seat.pickable.selected {
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(46, 158, 91, 0.35);
}

.seat.tappable {
  cursor: pointer;
}
.seat.inspecting {
  box-shadow: 0 0 0 3px var(--navy);
}

.seat-detail {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue-soft);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 4px 0 10px;
}
.seat-detail .info {
  flex: 1;
}
.seat-detail .btn {
  padding: 10px 14px;
  font-size: 0.9rem;
}
.seat-detail {
  flex-wrap: wrap;
}

.seat-detail.sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 616px;
  margin: 0 auto;
  z-index: 50;
  border: 2px solid var(--navy);
  box-shadow: 0 8px 24px rgba(20, 38, 74, 0.35);
}

.sheet-close {
  border: 0;
  background: rgba(20, 38, 74, 0.1);
  color: var(--navy);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend .dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  margin-right: 4px;
  vertical-align: -1px;
}
.legend .dot.available {
  background: #fff;
  border: 2px solid var(--green);
}
.legend .dot.booked {
  background: var(--yellow);
}
.legend .dot.aboard {
  background: var(--blue);
}

/* ---------- pickers (stations) ---------- */

.pick {
  display: block;
  position: relative;
  margin: 8px 0;
}
.pick input {
  position: absolute;
  opacity: 0;
}
.pick span {
  display: block;
  background: #fff;
  border: 2px solid #cfd6e4;
  border-radius: 12px;
  padding: 14px;
  font-weight: 700;
}
.pick:has(input:checked) span,
.pick.selected span {
  border-color: var(--blue);
  background: var(--blue-soft);
}

/* ---------- ticket ---------- */

.ticket {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  margin: 16px 0;
  box-shadow: 0 2px 10px rgba(20, 38, 74, 0.15);
}

.ticket-head {
  background: var(--navy);
  color: var(--yellow);
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 0.8rem;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
}

.ticket-body {
  padding: 18px;
  text-align: center;
}
.ticket-body h2 {
  margin: 0 0 2px;
  font-size: 1.5rem;
  color: var(--navy);
}

.ticket-facts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin: 14px 0;
  border-top: 2px dashed #cfd6e4;
  border-bottom: 2px dashed #cfd6e4;
  padding: 12px 0;
}
.ticket-facts .fact .label {
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
}
.ticket-facts .fact .value {
  font-size: 1.15rem;
  font-weight: 800;
}

.ticket img.qr {
  width: 200px;
  height: 200px;
  margin: 8px auto;
  display: block;
}

.ticket .code {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--navy);
  margin: 4px 0 10px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 800;
  font-size: 1rem;
}
.badge.booked {
  background: var(--yellow-soft);
  color: #9a7b12;
}
.badge.aboard {
  background: var(--blue);
  color: #fff;
}
.badge.done {
  background: var(--green-soft);
  color: var(--green);
}

.train-now {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- lists ---------- */

.train-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.train-card .info {
  flex: 1;
  min-width: 0;
}
.train-card .info .name {
  font-weight: 800;
  font-size: 1.15rem;
}
.train-card .btn {
  flex-shrink: 0;
}

.mini-ticket {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid #cfd6e4;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.mini-ticket .info {
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.mini-ticket .code-sm {
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--navy);
}

/* Container to handle horizontal scrolling on small screens */
.table-container {
  overflow-x: auto;
  margin: 25px 0;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
}

/* Base table configuration */
.styled-table {
  width: 100%;
  border-collapse: collapse; /* Merges cell borders into a single clean line */
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 0.95rem;
  background-color: #ffffff;
  text-align: left;
}

/* Header row styling */
.styled-table thead tr {
  background-color: var(--navy);
  color: #ffffff;
  font-weight: 600;
}

/* Cell padding for breathing room */
.styled-table th,
.styled-table td {
  padding: 14px 18px;
}

/* Subtle border lines for columns/rows */
.styled-table tbody tr {
  border-bottom: 1px solid #f3f4f6;
}

/* Zebra striping for better row scanning */
.styled-table tbody tr:nth-of-type(even) {
  background-color: #f8fafc;
}

/* Highlight row on hover for tracking data entries */
.styled-table tbody tr:hover {
  background-color: #f1f5f9;
  cursor: pointer;
}

/* Clean up the bottom border */
.styled-table tbody tr:last-of-type {
  border-bottom: 2px solid #1e3a8a;
}

/* Utility rule for right-aligning financial/numeric columns */
.styled-table .num-col {
  text-align: right;
}
