*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme Variables ───────────────────────── */
:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #162032;
  --border:    #2d3f55;
  --text:      #e2e8f0;
  --muted:     #7a90a8;
  --heading:   #60a5fa;
  --link:      #60a5fa;
  --link-hover:#93c5fd;
  --shadow:    0 4px 16px rgba(0,0,0,0.35);
  --radius:    10px;
  --header-h:  56px;
}

body.light {
  --bg:        #f0f4f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #dde4ef;
  --text:      #1e293b;
  --muted:     #64748b;
  --heading:   #1d4ed8;
  --link:      #2563eb;
  --link-hover:#1e40af;
  --shadow:    0 4px 16px rgba(0,0,0,0.08);
}

/* ── Base ──────────────────────────────────── */
body {
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.25s, color 0.25s;
}

/* ── Header ────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  transition: background 0.25s;
}

.site-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--heading);
  font-family: "Roboto Mono", monospace;
}

.site-sub {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.clock {
  font-family: "Roboto Mono", monospace;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
  min-width: 72px;
  text-align: right;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}
#theme-toggle:hover { background: var(--border); }

/* ── Layout ────────────────────────────────── */
.content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "asr jal"
    "tto jal";
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}

.box-asr { grid-area: asr; }
.box-tto { grid-area: tto; }
.box-jal { grid-area: jal; }

/* ── Box / Card ────────────────────────────── */
.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.25s;
}

/* ── Box Header ────────────────────────────── */
.box-header {
  padding: 12px 16px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.box-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.01em;
}

.dir-arrow {
  font-size: 1.1rem;
  font-weight: 700;
  opacity: 0.7;
}
.dir-left  { color: #f87171; }
.dir-right { color: #4ade80; }

.box-sub {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── Table ─────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.72rem, 1.4vw, 0.88rem);
}

thead tr {
  background: var(--surface2);
}

th {
  padding: 8px 10px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--surface2); }

/* ── Train number badge ─────────────────────── */
.train-no-cell {
  white-space: nowrap;
}

.train-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: "Roboto Mono", monospace;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  color: #fff;
  background: var(--muted);
  transition: opacity 0.15s;
}
.train-badge:hover { opacity: 0.85; }

.SUPERFAST { background: #15803d; }
.SHATABDI  { background: #9d174d; }
.DMU, .MEMU{ background: #6d28d9; }
.JAN       { background: #b45309; }
.MAIL      { background: #374151; }

/* ── Columns ───────────────────────────────── */
.col-name   { }
.col-from   { font-size: 0.72rem; color: var(--muted); font-family: "Roboto Mono", monospace; white-space: nowrap; }
.col-dep    { font-family: "Roboto Mono", monospace; font-weight: 600; white-space: nowrap; }
.col-status { font-size: 0.75rem; color: #f87171; }

th:nth-child(1) { width: 68px; }
th:nth-child(3) { width: 52px; }
th:nth-child(4) { width: 60px; }
th:nth-child(5) { width: 80px; }

/* ── States ────────────────────────────────── */
.loading {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
}

.error {
  text-align: center;
  padding: 16px;
  color: #f87171;
  font-size: 0.85rem;
}

a { color: inherit; text-decoration: none; }

/* ── Refresh bar ───────────────────────────── */
.refresh-bar {
  text-align: center;
  padding: 8px;
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── Mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "jal"
      "asr"
      "tto";
    padding: 10px;
    gap: 10px;
  }

  th:nth-child(3) { display: none; }  /* hide From on mobile */
  td:nth-child(3) { display: none; }

  td, th { padding: 8px 8px; }
}
