:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --border: #e2e8f0;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #f0f9ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 18px; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 300; }
.header-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.4px; flex-shrink: 0; }
.brand-icon { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #0284c7, #0369a1); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.brand .accent { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; transition: background .15s, color .15s; }
.nav-link:hover, .nav-link.active { background: var(--primary-light); color: var(--primary-dark); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.fav-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.fav-pill:hover { border-color: #f59e0b; background: #fffbeb; }
.fav-cnt { background: #f59e0b; color: #fff; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 999px; }
.lang-pills { display: inline-flex; align-items: center; gap: 2px; background: #f1f5f9; border-radius: 999px; padding: 3px; }
.lang-pill { padding: 4px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.lang-pill.active { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 3px rgba(15,23,42,.1); }

/* Hero Carburanti24-style */
.hero { background: #fff; border-bottom: 1px solid var(--border); padding: 40px 0 34px; text-align: center; }
.hero h1 { margin: 0 0 10px; font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.6px; color: var(--text); line-height: 1.15; }
.hero-sub { margin: 0 auto 24px; max-width: 640px; font-size: 15.5px; color: var(--muted); line-height: 1.5; }
.search-box { max-width: 620px; margin: 0 auto; position: relative; text-align: left; }
.search-label { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.search-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid #cbd5e1; border-radius: 14px; padding: 6px 8px 6px 14px; box-shadow: 0 4px 16px rgba(15,23,42,.05); transition: border-color .15s, box-shadow .15s; }
.search-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(2,132,199,.12); }
.search-input { flex: 1; border: none; outline: none; font-size: 15.5px; font-weight: 500; color: var(--text); background: transparent; min-height: 40px; width: 100%; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 11px; border: none; background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%); color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; transition: transform .12s, box-shadow .15s; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(2,132,199,.32); color: #fff; }
.btn-full { width: 100%; padding: 13px 20px; font-size: 15px; }
.ac-dropdown { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 34px rgba(15,23,42,.14); z-index: 250; overflow: hidden; }
.ac-dropdown.open { display: block; }
.ac-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; color: var(--text); font-size: 14px; font-weight: 600; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.ac-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: var(--subtle); }
.divider { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--subtle); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-gps { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 1.5px solid #bae6fd; background: #f0f9ff; color: var(--primary-dark); font-size: 14.5px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-gps:hover { background: #e0f2fe; }
.hero-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.chip-ok { border-color: #a7f3d0; background: var(--ok-bg); color: var(--ok); }
.chip-blue { border-color: #bae6fd; background: var(--primary-light); color: var(--primary-dark); }

/* Cards & Grids */
.section { padding: 28px 0; }
.section-title { margin: 0 0 6px; font-size: 20px; font-weight: 800; color: var(--text); }
.section-sub { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 2px 8px rgba(15,23,42,.03); }
.hubs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.hub-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: #fff; border: 1px solid var(--border); border-radius: 13px; color: var(--text); font-weight: 700; font-size: 14.5px; transition: border-color .15s, transform .12s, box-shadow .15s; }
.hub-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(2,132,199,.1); }
.hub-arr { color: var(--primary); font-weight: 800; }

/* Delay badges */
.badge-ok     { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--ok-bg); color: var(--ok); font-size: 12.5px; font-weight: 800; }
.badge-warn   { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; font-weight: 800; }
.badge-danger { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--danger-bg); color: var(--danger); font-size: 12.5px; font-weight: 800; }
.bin-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; padding: 4px 9px; border-radius: 8px; background: #f1f5f9; border: 1px solid #cbd5e1; color: var(--text); font-size: 13px; font-weight: 800; }
.cat-tag { display: inline-block; padding: 3px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; background: #e0f2fe; color: #0369a1; }
.cat-tag.cat-FR { background: #fee2e2; color: #b91c1c; }
.cat-tag.cat-IC { background: #ede9fe; color: #6d28d9; }

/* Station Board Table */
.board-tabs { display: inline-flex; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.board-tab { padding: 9px 18px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--muted); }
.board-tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 6px rgba(15,23,42,.08); }
.board-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
table.board { width: 100%; border-collapse: collapse; font-size: 14px; }
table.board th { text-align: left; padding: 12px 14px; background: #f8fafc; color: var(--subtle); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
table.board td { padding: 13px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.board tr:last-child td { border-bottom: none; }
table.board tr:hover td { background: #f8fafc; }

/* Train Timeline */
.tl-list { list-style: none; margin: 0; padding: 0; }
.tl-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px 13px 32px; border-bottom: 1px solid #f1f5f9; position: relative; }
.tl-item:last-child { border-bottom: none; }
.tl-item::before { content: ''; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; background: #cbd5e1; }
.tl-item.is-passed::before { background: var(--ok); }
.tl-dot { position: absolute; left: 7px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2.5px solid #94a3b8; }
.tl-item.is-passed .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-item.is-current .tl-dot { width: 16px; height: 16px; left: 5px; background: var(--primary); border-color: #fff; box-shadow: 0 0 0 4px rgba(2,132,199,.25); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; }
.stat-val { font-size: 24px; font-weight: 800; color: var(--text); }
.stat-lbl { font-size: 12px; color: var(--subtle); font-weight: 600; margin-top: 3px; }

/* Modal Preferiti */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.open { display: flex; }
.modal-box { width: 100%; max-width: 460px; background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 20px 50px rgba(15,23,42,.25); }

/* Footer */
.site-footer { background: #fff; border-top: 1px solid var(--border); margin-top: 40px; padding: 32px 0 24px; font-size: 13.5px; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 24px; margin-bottom: 22px; }
.footer-grid h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--text); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.footer-grid a { color: var(--muted); }
.footer-grid a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 16px; font-size: 12px; color: var(--subtle); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

@media (max-width: 820px) {
  .nav-links { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; align-items: stretch; padding: 10px; }
  .btn-primary { width: 100%; }
}
