/* ============================================================
   Making Tracks Booking System - Design System
   Self-contained CSS — no Tailwind dependency
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --bg: #ffffff;
    --fg: #1a1a1a;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --accent-dark: #1d4ed8;
    --border: #e5e7eb;
    --section-bg: #f9fafb;
    --success: #059669;
    --success-light: #d1fae5;
    --success-border: #a7f3d0;
    --warning: #d97706;
    --danger: #dc2626;
    --muted: #6b7280;
    --fade-speed: 1.2s;
    --toast-duration: 4s;
}

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

/* ---- Checkboxes: round throughout (toggle-cb class opts out) ---- */
input[type="checkbox"]:not(.toggle-cb) {
    border-radius: 50%;
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
input[type="checkbox"]:not(.toggle-cb):checked {
    background: var(--accent);
    border-color: var(--accent);
}
input[type="checkbox"]:not(.toggle-cb):checked::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -1px;
}
input[type="checkbox"]:not(.toggle-cb):disabled {
    opacity: 0.4;
    cursor: default;
}

/* ---- Body ---- */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--fg);
    background: var(--bg);
    line-height: 1.6;
    font-size: 15px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ---- Navigation ---- */
.nav {
    background: var(--bg);
    border-bottom: 2px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.mini-map, .detail-map {
    z-index: 0;
    isolation: isolate;
}

/* Landing page nav */
.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
}
.landing-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}
.landing-logo img {
    height: 72px;
}

.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
}

.nav-bar {
    display: flex;
    align-items: center;
    min-height: 48px;
    gap: 8px;
}

.nav-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
    flex-shrink: 0;
}
.nav-brand-icon { font-size: 18px; }
.nav-brand-text { white-space: nowrap; }

.nav-links {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.nav-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
}
.nav-link svg, .nav-link .icon { display: none; }
.nav-link-label { }

.nav-link:hover {
    color: var(--fg);
    background: var(--section-bg);
}

.nav-link.active {
    color: #fff;
    background: var(--accent);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-user {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

/* Hamburger toggle button (hidden on desktop) */
.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* Mobile nav menu */
.nav-mobile-menu {
    display: none;
    padding: 8px 0;
    border-top: 1px solid var(--border);
}
.nav-mobile-menu .nav-link {
    padding: 10px 16px;
    display: flex;
    width: 100%;
    color: var(--muted);
}

/* ---- Utilities ---- */
.hidden { display: none !important; }
.antialiased { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ---- Page Layout ---- */
.page {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px 40px;
    overflow-x: hidden;
}

.page-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 24px;
}

/* Hub grid (Admin/System dashboards) */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.hub-grid .compact-card {
    text-decoration: none;
    color: var(--fg);
}

.compact-card-icon {
    font-size: 20px;
    margin-bottom: 6px;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--fg);
    margin-bottom: 2px;
}

.page-sub {
    font-size: 15px;
    color: var(--muted);
    margin-bottom: 24px;
}

/* ---- Step Containers ---- */
.step-container {
    transition: opacity var(--fade-speed) ease, filter var(--fade-speed) ease;
    opacity: 1;
    filter: none;
    scroll-margin-top: 70px;
}

.step-container.greyed {
    opacity: 0.3;
    filter: grayscale(0.6);
    pointer-events: none;
}

.step-container.pending {
    opacity: 0.15;
    filter: grayscale(1);
    pointer-events: none;
}

.step-container.revealing {
    animation: revealFade 1.8s ease forwards;
}

/* ---- Step Labels ---- */
.step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
    margin-bottom: 10px;
}

.step-num {
    background: var(--accent);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    transition: background var(--fade-speed) ease;
}

.step-num.done {
    background: var(--success);
}

.step-num.waiting {
    background: #d1d5db;
}

.step-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg);
}

.step-spacer {
    flex: 1;
}

/* ---- Choice Bars ---- */
.choice-bar {
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 38px;
    transition: background var(--fade-speed) ease,
                border-color var(--fade-speed) ease,
                color var(--fade-speed) ease,
                opacity var(--fade-speed) ease;
}

.choice-bar.empty {
    background: var(--section-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    font-weight: 400;
    font-style: italic;
    opacity: 0.5;
}

.choice-bar.confirmed {
    background: var(--success-light);
    border: 1px solid var(--success-border);
    color: #065f46;
    font-weight: 600;
    font-style: normal;
    opacity: 1;
}

.choice-bar .check {
    font-size: 15px;
    transition: opacity var(--fade-speed) ease;
}

.choice-bar.empty .check {
    opacity: 0;
}

.choice-bar.confirmed .check {
    opacity: 1;
    color: var(--success);
}

/* ---- Event Grid ---- */
.event-grid {
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.event-card {
    background: #fff;
    padding: 12px 16px;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.event-card:hover {
    background: var(--accent-light);
}

.event-card.selected {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.event-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.event-card.disabled:hover {
    background: #fff;
}

.ev-title {
    font-size: 15px;
    font-weight: 600;
}

.ev-meta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 1px;
}

.ev-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.ev-badge.open {
    background: var(--success-light);
    color: #065f46;
}

.ev-badge.closed {
    background: #fee2e2;
    color: #991b1b;
}

/* ---- Event Detail ---- */
.event-detail {
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    background: var(--section-bg);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height var(--fade-speed) ease, opacity var(--fade-speed) ease, padding var(--fade-speed) ease;
    padding: 0 16px;
}

.event-detail.open {
    max-height: 600px;
    opacity: 1;
    padding: 16px;
}

.detail-desc {
    font-size: 13px;
    color: #374151;
    line-height: 1.7;
    margin-bottom: 12px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 3px 12px;
    font-size: 13px;
}

.detail-grid dt {
    color: var(--muted);
    font-weight: 500;
}

.detail-grid dd {
    color: var(--fg);
    font-weight: 500;
}

.btn-select-event {
    margin-top: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-select-event:hover {
    background: var(--accent-dark);
}

/* ---- Mini Calendar Strip ---- */
.mini-cal-strip {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    justify-content: center;
}

.mini-cal {
    flex: 0 0 auto;
}

.mini-cal-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-align: center;
    margin-bottom: 4px;
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    font-size: 9px;
    line-height: 1;
}

.mini-cal-hdr {
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    padding: 2px 0;
    font-size: 8px;
    text-transform: uppercase;
}

.mini-cal-day {
    text-align: center;
    padding: 3px 2px;
    border-radius: 2px;
    color: #d1d5db;
    font-size: 10px;
}

.mini-cal-day.in-month {
    color: #9ca3af;
}

.mini-cal-day.event-day {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    border-radius: 3px;
}

.mini-cal-day.selected-day {
    background: var(--success);
    color: #fff;
    font-weight: 700;
    border-radius: 3px;
}

/* ---- Date List ---- */
.date-list-wrap {
    position: relative;
}
.date-list-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--muted);
}
.date-list-controls select {
    font-size: 12px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    color: var(--fg);
}
.date-list {
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.date-list.scrollable {
    overflow-y: auto;
    scrollbar-width: thin;
}
.date-list.scrollable::-webkit-scrollbar {
    width: 6px;
}
.date-list.scrollable::-webkit-scrollbar-track {
    background: var(--section-bg);
}
.date-list.scrollable::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.date-row {
    background: #fff;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.date-row:hover {
    background: var(--accent-light);
}

.date-row.selected {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.date-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.date-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
}

.date-total {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}

.date-total.has-slots {
    background: var(--success-light);
    color: #065f46;
}

.date-total.few-slots {
    background: #fef3c7;
    color: #92400e;
}

.date-total.no-slots {
    background: #fee2e2;
    color: #991b1b;
}

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

.date-session-chip {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    background: var(--section-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-session-chip .chip-slots {
    font-weight: 700;
}

.chip-slots.ok {
    color: var(--success);
}

.chip-slots.low {
    color: var(--warning);
}

.chip-slots.full {
    color: var(--danger);
}

.chip-slots.booked {
    color: var(--accent);
    font-style: italic;
}

.date-session-chip.chip-booked {
    opacity: 0.55;
    cursor: default;
}

.date-row.booked-row {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.date-total.booked {
    color: var(--accent);
    font-style: italic;
}

/* ---- Session List ---- */
.session-list {
    display: grid;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.session-row {
    background: #fff;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.session-row:hover {
    background: var(--accent-light);
}

.session-row.selected {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.session-row.full {
    cursor: pointer;
}

.session-row.full .sess-avail {
    font-style: italic;
}

.sess-name {
    font-size: 14px;
    font-weight: 600;
}

.sess-time {
    font-size: 12px;
    color: var(--muted);
    margin-left: 8px;
}

.sess-avail {
    font-size: 12px;
    font-weight: 600;
}

.sess-avail.ok {
    color: var(--success);
}

.sess-avail.low {
    color: var(--warning);
}

.sess-avail.full {
    color: var(--danger);
}

.session-row.booked-row {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.sess-avail.booked {
    color: var(--accent);
    font-style: italic;
}

/* ---- Review ---- */
.review-box {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.review-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.review-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

.review-table td:first-child {
    color: var(--muted);
    width: 100px;
    font-weight: 500;
}

.review-table td:last-child {
    font-weight: 600;
}

.review-table tr:last-child td {
    border-bottom: none;
}

.terms-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 14px 0 0;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}

.terms-row input {
    margin-top: 3px;
}

/* ---- Buttons ---- */
.btn-confirm {
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 14px;
}

.btn-confirm:hover {
    background: var(--accent-dark);
}

.btn-confirm:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-secondary {
    background: #fff;
    color: var(--fg);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
    background: var(--section-bg);
    border-color: #d1d5db;
}

.btn-secondary.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---- Success Banner ---- */
.success-banner {
    background: var(--success-light);
    border: 1px solid var(--success-border);
    border-radius: 6px;
    padding: 24px;
    text-align: center;
}

.success-icon {
    width: 48px;
    height: 48px;
    background: var(--success);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.success-icon svg {
    width: 24px;
    height: 24px;
}

.success-title {
    font-size: 18px;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 4px;
}

.success-text {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

.success-links {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.success-links a {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
}

.link-primary {
    background: var(--accent);
    color: #fff;
}

.link-primary:hover {
    background: var(--accent-dark);
}

.link-secondary {
    background: #fff;
    color: var(--fg);
    border: 1px solid var(--border);
}

.link-secondary:hover {
    background: var(--section-bg);
}

/* ---- Pending Message ---- */
.pending-msg {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}

/* ---- Dividers ---- */
.step-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0 0;
}

/* ---- Footer ---- */
.footer {
    background: var(--bg);
    color: var(--muted);
    text-align: center;
    padding: 24px 16px;
    font-size: 11px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   Animations & Keyframes
   ============================================================ */

@keyframes revealFade {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* General reveal class (Rule 3: first-time content slide-up fade) */
.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 1.8s ease, transform 1.8s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Utility fade-in */
.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Smooth page transitions */
#app-content {
    animation: fadeIn 0.2s ease;
}

/* ============================================================
   Calendar Grid (Admin Slots Page)
   ============================================================ */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background-color: var(--border);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.calendar-header-cell {
    background-color: #1e293b;
    color: #fff;
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-cell {
    background-color: #fff;
    min-height: 5rem;
    padding: 0.25rem;
    font-size: 0.75rem;
    position: relative;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.calendar-cell:hover {
    background-color: var(--accent-light);
}

.calendar-cell.today {
    background-color: var(--accent-light);
}

.calendar-cell.other-month {
    background-color: var(--section-bg);
    color: #94a3b8;
}

.calendar-cell .date-number {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.calendar-cell .event-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--accent);
    margin: 0.0625rem;
}

.calendar-cell .event-label {
    display: block;
    padding: 0.0625rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    line-height: 1.2;
    margin-bottom: 0.0625rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--accent-light);
    color: var(--accent);
}

/* ============================================================
   Modal (Rule 5: backdrop opacity 0->0.5, panel scale+slide)
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: background-color 0.2s ease;
    padding: 1rem;
}

.modal-backdrop.active {
    background-color: rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease;
}

.modal-panel {
    background-color: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(8px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-backdrop.active .modal-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-panel-lg {
    max-width: 48rem;
}

.modal-panel-xl {
    max-width: 64rem;
}

/* Scrollbar for modals */
.modal-panel::-webkit-scrollbar {
    width: 6px;
}

.modal-panel::-webkit-scrollbar-track {
    background: transparent;
}

.modal-panel::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.modal-close-btn {
    color: #9ca3af;
    font-size: 1.5rem;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.modal-close-btn:hover {
    color: #4b5563;
}

.modal-body {
    padding: 1rem 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #f3f4f6;
}

/* ============================================================
   Toast Notifications (Rule 6: slide in from right)
   ============================================================ */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 24rem;
    width: calc(100% - 2rem);
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    color: #fff;
    font-size: 0.875rem;
    line-height: 1.4;
    animation: toast-in 0.3s ease forwards;
    position: relative;
    overflow: hidden;
}

.toast.removing {
    animation: toast-out 0.3s ease forwards;
}

.toast-success {
    background-color: var(--success);
}

.toast-error {
    background-color: var(--danger);
}

.toast-info {
    background-color: var(--accent);
}

.toast-warning {
    background-color: var(--warning);
    color: #1e293b;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    margin-top: 0.0625rem;
}

.toast-message {
    flex: 1;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.15s ease;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.4);
    animation: toast-progress var(--toast-duration) linear forwards;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
        max-height: 8rem;
        margin-bottom: 0;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
        max-height: 0;
        margin-bottom: -0.5rem;
    }
}

@keyframes toast-progress {
    from { width: 100%; }
    to { width: 0%; }
}

/* ============================================================
   Loading Spinner
   ============================================================ */

.spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 1.25rem;
    height: 1.25rem;
    border-width: 2px;
}

.spinner-lg {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

.spinner-white {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 40;
    gap: 1rem;
}

.loading-overlay .loading-text {
    color: #475569;
    font-size: 0.875rem;
}

/* ============================================================
   Badge (semantic colour variants)
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-green {
    background: var(--success-light);
    color: #065f46;
}

.badge-amber {
    background: #fef3c7;
    color: #92400e;
}

.badge-red {
    background: #fee2e2;
    color: #991b1b;
}

.badge-blue {
    background: var(--accent-light);
    color: var(--accent-dark);
}

.badge-grey {
    background: var(--section-bg);
    color: var(--muted);
    border: 1px solid var(--border);
}

/* ============================================================
   Compact Card (My Bookings list items)
   ============================================================ */

.compact-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    transition: background 0.15s;
}

.compact-card:hover {
    background: var(--section-bg);
}

.compact-card + .compact-card {
    margin-top: 8px;
}

/* ============================================================
   Admin Tables (compact, no shadows, blue header)
   ============================================================ */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.admin-table thead th {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
}

.admin-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
    vertical-align: middle;
}

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

.admin-table tbody tr:hover {
    background: var(--section-bg);
}

/* Pages that opt into full browser width (e.g. User Management with many
   columns). Uses :has() so no per-page cleanup of body classes is needed.
   Cancels the 1100px cap on #app-content.page and lets the table consume
   the viewport; cells wrap naturally when the viewport is too narrow. */
#app-content:has(> .page-fullwidth) {
    max-width: none;
    overflow-x: visible;
    padding-left: 24px;
    padding-right: 24px;
}
.page-fullwidth {
    width: 100%;
}
.admin-users-wide .admin-table {
    table-layout: auto;
}
.admin-users-wide .admin-table td {
    word-break: break-word;
}

/* ============================================================
   Form Elements (compact inputs, labels, selects)
   ============================================================ */

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    max-width: 100%;
    padding: 7px 10px;
    font-size: 16px; /* prevents Safari auto-zoom on focus */
    font-family: inherit;
    color: var(--fg);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.5;
    -webkit-appearance: none;
}

@media (min-width: 768px) {
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 13px;
    }
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: #9ca3af;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    padding-right: 28px;
}

.form-group {
    margin-bottom: 12px;
}

/* ---- Find Me a Slot ---- */
.slot-finder-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    margin-bottom: 16px;
}
.slot-finder-btn:hover {
    background: var(--accent);
    color: #fff;
}

.slot-finder-panel {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 20px;
    transition: opacity var(--fade-speed) ease, max-height var(--fade-speed) ease;
}

.slot-finder-header {
    background: var(--section-bg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
}

.slot-finder-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}
.slot-finder-toggle input { margin: 0; }

.slot-finder-list {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.slot-finder-list::-webkit-scrollbar { width: 6px; }
.slot-finder-list::-webkit-scrollbar-track { background: var(--section-bg); }
.slot-finder-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.slot-finder-row {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
}
.slot-finder-row:last-child { border-bottom: none; }
.slot-finder-row:hover { background: var(--accent-light); }
.slot-finder-row.waitlist-row { opacity: 0.7; }
.slot-finder-row.waitlist-row:hover { opacity: 1; background: #fef3c7; }

.slot-finder-event { font-size: 12px; color: var(--muted); }
.slot-finder-date { font-size: 14px; font-weight: 600; }
.slot-finder-session { font-size: 12px; color: var(--muted); }
.slot-finder-avail { font-size: 12px; font-weight: 600; }
.slot-finder-avail.ok { color: var(--success); }
.slot-finder-avail.low { color: var(--warning); }
.slot-finder-avail.full { color: var(--danger); font-style: italic; }

.slot-finder-empty {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* Medium breakpoint: 768px */
@media (max-width: 767px) {
    /* Hamburger visible, desktop links hidden */
    .nav-hamburger {
        display: block;
    }

    .nav-links {
        display: none;
    }

    .nav-mobile-menu.open {
        display: flex;
    }

    .nav-user {
        display: none;
    }

    /* Mini calendar stacks to single column */
    .mini-cal-strip {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }

    /* Admin tables scroll horizontally */
    .admin-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .admin-table {
        min-width: 600px;
    }
}

@media (min-width: 768px) {
    /* Desktop: mobile menu stays hidden, desktop nav-links are visible */
    .nav-mobile-menu {
        display: none !important;
    }

    .nav-hamburger {
        display: none;
    }
}

/* Small breakpoint: 640px */
@media (max-width: 639px) {
    .page {
        padding: 16px 12px 40px;
    }

    h1 {
        font-size: 20px;
    }

    /* Event cards stack content */
    .event-card {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    /* Date rows: stack header elements */
    .date-row-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    /* Session rows: stack vertically */
    .session-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    /* Review table: labels on top */
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    /* Choice bars wrap text */
    .choice-bar {
        flex-wrap: wrap;
    }

    /* Success links stack */
    .success-links {
        flex-direction: column;
        align-items: center;
    }

    .page {
        padding: 16px 8px 40px;
    }

    /* All sections use full width on mobile */
    section[style*="padding"] {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    /* How It Works: stack to single column */
    .how-it-works-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Register form: stack name fields */
    .reg-name-grid {
        grid-template-columns: 1fr !important;
    }

    /* Hero section: stack text + GWR logo */
    .hero-inner {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }

    .hero-section {
        padding: 16px 8px !important;
    }

    .hero-title {
        font-size: 14px !important;
    }

    .hero-title span {
        font-size: 14px !important;
        font-weight: 700 !important;
    }

    .hero-inner p {
        font-size: 12px !important;
    }

    /* Hide GWR logo on narrow screens */
    .gwr-badge {
        display: none !important;
    }

    /* Landing nav: logo on top, links below */
    .landing-nav {
        flex-direction: column !important;
        padding: 6px 10px !important;
        gap: 4px;
    }
    .landing-logo img {
        height: 52px !important;
    }
    .landing-nav-links {
        gap: 2px !important;
        flex-wrap: wrap;
        justify-content: center;
    }
    .landing-nav-links .btn-primary {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }

    /* App nav: tighter on mobile */
    .nav-inner {
        padding: 0 8px !important;
    }
    .nav-actions img {
        height: 40px !important;
    }

    /* Event cards: stack map below text */
    .event-card[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Maps: full width on mobile */
    .mini-map {
        width: 100% !important;
        height: 120px !important;
    }

    .detail-map {
        width: 100% !important;
        height: 180px !important;
    }

    /* Social links: single column */
    .social-links-grid {
        grid-template-columns: 1fr !important;
    }

    /* YouTube scroll: smaller cards */
    .yt-card {
        flex: 0 0 260px !important;
    }

    .yt-card .yt-thumb {
        width: 260px !important;
        height: 146px !important;
    }

    /* CTA banner: stack */
    .cta-inner {
        flex-direction: column !important;
        text-align: center;
    }

    /* Sponsor footer: stack on mobile */
    .sponsor-row {
        flex-direction: column !important;
        text-align: center;
    }

    /* Presentation steps: single column */
    .pres-steps {
        flex-direction: column !important;
        gap: 16px !important;
    }

    /* Modal: full width on mobile */
    .modal-panel {
        max-width: calc(100vw - 24px) !important;
        margin: 12px;
    }

    /* Modal iframes: constrain on mobile */
    .modal-body iframe {
        height: 45vh !important;
    }

    /* Hub grid: single column on narrow */
    .hub-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tables: prevent overflow */
    table {
        table-layout: fixed;
        word-wrap: break-word;
    }

    /* Review table: full width */
    .review-table {
        width: 100%;
    }
    .review-table td {
        display: block;
        width: 100%;
        padding: 2px 0;
    }
    .review-table td:first-child {
        font-weight: 600;
        font-size: 11px;
        color: var(--muted);
    }

    /* Buttons: prevent overflow */
    .btn-primary, .btn-secondary, .btn-danger, .btn-confirm {
        max-width: 100%;
        white-space: normal;
    }

    /* Inline flex containers: allow wrapping */
    [style*="display:flex"] {
        flex-wrap: wrap;
    }

    /* Images: constrain */
    img {
        max-width: 100%;
        height: auto;
    }
}

/* Mobile: let header scroll away to maximise viewing area */
@media (max-width: 767px) {
    .nav, .landing-nav {
        position: static !important;
    }
}

/* ---- YouTube Video Section ---- */
.yt-search-wrap {
    position: relative;
    margin: 12px 0;
}

.yt-search-wrap input {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    color: var(--fg);
    outline: none;
    transition: border-color 0.15s;
}

.yt-search-wrap input:focus {
    border-color: var(--accent);
}

.yt-search-wrap .yt-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    color: var(--muted);
    cursor: pointer;
    display: none;
    padding: 2px 4px;
    line-height: 1;
}

.yt-search-results-count {
    font-size: 12px;
    color: var(--muted);
    margin: 8px 0 12px;
}

.yt-archive-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 10px 0;
    margin-top: 8px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    width: 100%;
    text-align: left;
}

.yt-archive-toggle .chevron {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 12px;
}

.yt-archive-toggle[aria-expanded="true"] .chevron {
    transform: rotate(90deg);
}

.yt-archive-body {
    display: none;
}

.yt-archive-body.open {
    display: block;
}

.yt-year-heading {
    font-size: 13px;
    font-weight: 700;
    color: var(--fg);
    margin: 16px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.yt-year-heading:first-child {
    margin-top: 0;
}

.yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.yt-grid .yt-card {
    flex: none !important;
    width: 100% !important;
}

.yt-grid .yt-card .yt-thumb {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
}

.yt-grid .yt-card .yt-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================================
   Layout Data (candata) dashboard
   ============================================================ */

.candata-page { max-width: 1200px; }
.candata-header h1 { margin: 0 0 4px; }
.candata-sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; }

.candata-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.candata-tab {
    background: none; border: 0; padding: 10px 18px; cursor: pointer;
    font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
    font-family: inherit;
}
.candata-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.candata-tab:hover:not(.active) { color: var(--fg); }

.candata-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    background: var(--section-bg); padding: 12px 14px; border-radius: 8px;
    margin-bottom: 14px; border: 1px solid var(--border);
}
.candata-field { display: flex; flex-direction: column; gap: 3px; min-width: 120px; }
.candata-field label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.candata-field .form-select, .candata-field .form-input { font-size: 13px; padding: 6px 8px; }
.candata-status { min-width: 200px; }
.candata-status-text { font-size: 12px; color: var(--muted); padding: 7px 0; }

.candata-tiles {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px; margin-bottom: 16px;
}
.candata-tile {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.tile-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 22px; font-weight: 700; color: var(--fg); line-height: 1.1; }
.tile-hint { font-size: 11px; color: var(--muted); }

.candata-grid {
    display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px;
}
.candata-card {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 14px 16px; grid-column: span 6;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.candata-card.card-wide { grid-column: span 8; }
.candata-card.card-tall { grid-column: span 4; grid-row: span 2; }
.candata-card h3 { margin: 0 0 2px; font-size: 15px; }
.candata-card .card-sub { font-size: 11px; color: var(--muted); margin: 0 0 8px; }
.candata-card canvas { display: block; width: 100%; }
@media (max-width: 900px) {
    .candata-card, .candata-card.card-wide, .candata-card.card-tall {
        grid-column: span 12; grid-row: auto;
    }
}

.heatmap { overflow-x: auto; padding: 4px 0 8px; }
.heatmap-inner { display: grid; gap: 1px; min-width: 600px; }
.hm-label { font-size: 12px; padding: 2px 6px 2px 0; color: var(--muted); font-family: monospace; }
.hm-cell { height: 14px; border-radius: 1px; background: #f3f4f6; }

.byte-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.byte-col { border: 1px solid var(--border); border-radius: 6px; padding: 8px; background: #fff; }
.byte-name { font-weight: 700; font-size: 13px; color: var(--accent); }
.byte-unique { font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.byte-row { display: flex; align-items: center; gap: 4px; font-size: 11px; margin: 2px 0; }
.byte-val { width: 26px; text-align: right; color: var(--fg); font-family: monospace; }
.byte-bar { flex: 1; height: 8px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.byte-bar-fill { display: block; height: 100%; background: var(--accent); }
.byte-count { width: 40px; text-align: right; color: var(--muted); font-family: monospace; }

.byte-filter-row {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 8px 12px; font-size: 12px; color: var(--muted); margin-bottom: 12px;
}
.byte-input { display: inline-flex; align-items: center; gap: 4px; }
.byte-input label { font-family: monospace; font-size: 12px; color: var(--muted); }
.byte-input input {
    width: 54px; padding: 3px 5px; font-size: 12px; font-family: monospace;
    border: 1px solid var(--border); border-radius: 4px;
}
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; }

.lookup-meta { font-size: 12px; color: var(--muted); margin: 8px 2px; }
.lookup-results { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.lookup-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lookup-table th, .lookup-table td {
    padding: 6px 8px; text-align: left; border-bottom: 1px solid #f1f5f9;
}
.lookup-table thead th {
    background: var(--section-bg); color: var(--muted); font-weight: 600;
    text-transform: uppercase; font-size: 10px; letter-spacing: .04em;
    position: sticky; top: 0;
}
.lookup-table td.mono { font-family: monospace; }
.lookup-table td.strong { font-weight: 700; color: var(--accent); }
.lookup-table tbody tr:hover { background: #f9fafb; }
.lookup-pager { text-align: center; padding: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 16px; font-size: 12px; }

/* New full-width card variant + head row */
.candata-card.card-full { grid-column: span 12; }
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* Live strip chart — reset button aligned right */
#cd-live-reset { white-space: nowrap; }

/* Tag button in tables */
.btn-tag {
    background: #eff6ff; border: 1px solid #dbeafe; color: var(--accent);
    border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer;
    font-family: inherit; white-space: nowrap;
}
.btn-tag:hover { background: #dbeafe; }

/* Trains tab */
.train-pill {
    display: inline-block; background: #ecfeff; color: #0e7490;
    padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.lookup-table tr.has-train { background: #fafdff; }
.lookup-table td.tiny { font-size: 11px; }

.unknown-grid { display: flex; flex-direction: column; gap: 6px; }
.unknown-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    background: #fff;
}
.unknown-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.un-can { font-size: 12px; font-weight: 600; color: var(--fg); }
.un-hex { font-family: monospace; font-size: 12px; color: #6b7280; letter-spacing: 2px; }
.unknown-count { font-size: 12px; color: var(--muted); min-width: 80px; text-align: right; }
.un-register { padding: 4px 12px; font-size: 12px; }

/* Replay tab */
.replay-nav {
    display: flex; gap: 8px; align-items: center; margin: 12px 0;
    flex-wrap: wrap;
}
.replay-nav .btn-secondary { padding: 6px 12px; font-size: 12px; }
.replay-cursor {
    flex: 1; text-align: center; font-family: monospace; font-size: 12px;
    color: var(--muted); padding: 0 12px;
}

/* Tag modal specifics */
.tag-preview {
    background: var(--section-bg); padding: 8px 10px; border-radius: 6px;
    margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px;
}
.tag-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tag-preview .mono { font-family: monospace; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.form-error {
    background: #fef2f2; color: #b91c1c; padding: 8px 12px;
    border-radius: 4px; font-size: 12px; margin: 8px 0;
}
.modal-actions {
    display: flex; justify-content: space-between; gap: 8px;
    margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border);
}
.modal-actions > div { display: flex; gap: 8px; }
.btn-danger {
    background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
    border-radius: 4px; padding: 6px 14px; font-size: 13px; cursor: pointer;
    font-family: inherit;
}
.btn-danger:hover { background: #fee2e2; }

/* Trains tab — unified status pills, highlighted rows, legend */
.tag-pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.tag-pill.reg   { background: #dbeafe; color: #1e40af; }
.tag-pill.unreg { background: #fef3c7; color: #92400e; }

.trains-table tr.row-unregistered { background: #fffbeb; }
.trains-table tr.row-unregistered:hover { background: #fef3c7; }
.trains-table td .muted { color: var(--muted); font-size: 12px; }
.trains-table td .strong { font-weight: 700; color: var(--accent); }

.btn-name-train {
    background: #f59e0b; color: #fff; border: 1px solid #d97706;
    border-radius: 4px; padding: 4px 10px; font-size: 12px; font-weight: 600;
    cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn-name-train:hover { background: #d97706; }

.candata-tile.tile-warn { border-color: #fde68a; background: #fffbeb; }
.candata-tile.tile-warn .tile-value { color: #b45309; }
.candata-tile.tile-warn .tile-hint { color: #92400e; font-weight: 600; }

.legend-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 2px;
    margin: 0 4px 0 8px; vertical-align: middle;
}
.legend-dot.reg   { background: #2563eb; }
.legend-dot.unreg { background: #f59e0b; }

/* Small inline chip for reader/vPort lists */
.chip {
    display: inline-block; background: var(--section-bg); color: var(--fg);
    border: 1px solid var(--border); border-radius: 4px;
    padding: 0 6px; margin-right: 3px; font-family: monospace; font-size: 11px;
}

/* ASCII preview under the tag hex in the modal */
.tag-preview .tag-ascii {
    font-size: 11px; color: var(--muted); font-family: monospace;
}

/* Replay: highlight frames that are RFID tag reads (even if unregistered) */
.lookup-table tr.has-rfid { background: #fffbeb; }
.train-pill.unreg-pill { background: #fef3c7; color: #92400e; }

/* 4-char tag display chip — stands out as the primary identifier */
.tag-chip {
    display: inline-block; font-family: 'SFMono-Regular', ui-monospace, monospace;
    background: #1a1a1a; color: #f8fafc; padding: 2px 8px;
    border-radius: 3px; font-size: 13px; font-weight: 700;
    letter-spacing: .05em; white-space: pre;
}
.tag-chip.small { font-size: 11px; padding: 1px 6px; }

/* Clickable chip (for vport names etc) */
.chip-btn {
    cursor: pointer; border: 1px solid var(--border); background: var(--section-bg);
    color: var(--fg); padding: 1px 8px; border-radius: 4px;
    font-family: monospace; font-size: 11px; margin-right: 3px;
    font-weight: inherit;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.chip-named { background: #dbeafe; border-color: #93c5fd; color: #1e40af; font-family: inherit; font-weight: 600; }
.chip-btn.chip-named:hover { background: #bfdbfe; }

/* Per-line stats table */
.line-stats-table th, .line-stats-table td { vertical-align: middle; padding: 6px 10px; }
.line-stats-table tr.line-focused { background: #e0e7ff !important; }
.line-stats-table tr.line-focused td { border-color: #c7d2fe; }
.line-stats-table tr.line-unnamed { background: #fffbeb; }
.line-stats-table tr.line-live { animation: line-pulse 1.4s ease-in-out infinite; }

@keyframes line-pulse {
    0%, 100% { box-shadow: inset 3px 0 0 transparent; }
    50%      { box-shadow: inset 3px 0 0 #22c55e; }
}

.line-num { min-width: 120px; }
.num-cell { display: flex; flex-direction: column; gap: 2px; font-family: monospace; }
.num-cell .num { font-size: 14px; font-weight: 700; color: var(--fg); line-height: 1.1; }
.bar-track {
    display: block; height: 4px; background: #f1f5f9;
    border-radius: 2px; overflow: hidden;
}
.bar-fill {
    display: block; height: 100%; border-radius: 2px;
    transition: width 0.4s ease;
}
.bar-fill.interval   { background: #22c55e; }
.bar-fill.cumulative { background: #2563eb; }

/* Replay density canvas hint */
#rp-density { display: block; width: 100%; cursor: pointer; }

/* Distance Travelled cards */
.distance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}
.distance-card {
    border: 1px solid var(--border); border-radius: 6px;
    padding: 10px 12px; background: #fff;
}
.distance-head { margin-bottom: 4px; }
.distance-title { font-size: 14px; font-weight: 600; color: var(--fg); }
.distance-meta {
    font-size: 11px; color: var(--muted); margin-top: 2px;
    display: flex; flex-wrap: wrap; gap: 0; align-items: center;
}
.distance-canvas { display: block; width: 100%; }

.form-help {
    font-size: 11px; color: var(--muted); margin: -4px 0 8px;
}

