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

:root {
    --primary: #0E4D90;
    --primary-light: #1a6bc4;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
}

/* ── Navbar ── */
.navbar {
    background: var(--primary);
    color: white;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.5rem 1rem;
    position: fixed; width: 100%; left: 0;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    margin-left: auto;
}

.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
    color: white;
    background: rgba(255,255,255,0.15);
}

/* ── Container ── */
.container { padding-top: 4rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    overflow-x: hidden;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    overflow-x: hidden;
    word-wrap: break-word;
}

.card h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--primary); }
.card h3 { font-size: 0.95rem; margin: 1rem 0 0.5rem; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid var(--border);
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Grids ── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }
table { display: table; }

th, td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr:hover { background: #f9fafb; }

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
}

.form-group small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

input[type="text"], input[type="password"], .scan-input, .search-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.15s;
    max-width: 100%;
}

input[type="text"]:focus, input[type="password"]:focus, .scan-input:focus, .search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 77, 144, 0.1);
}

.scan-input {
    font-size: 1rem;
    padding: 0.75rem;
    font-family: 'Courier New', monospace;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-form .search-input { flex: 1; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: #e5e7eb; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-webhook { background: #d1fae5; color: #065f46; }
.badge-manual { background: #dbeafe; color: #1e40af; }

/* ── Boarding Pass Display ── */
.boarding-pass {
    background: linear-gradient(135deg, #f8fafc, #eef2ff);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0;
}

.bp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px dashed var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bp-airline {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.bp-flight {
    font-size: 1.1rem;
    font-weight: 700;
}

.bp-route {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 1rem 0;
}

.bp-airport { text-align: center; }

.bp-code {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
}

.bp-name {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bp-arrow {
    font-size: 1.25rem;
    color: var(--text-muted);
}

.bp-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 2px dashed var(--border);
}

.bp-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.bp-value {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

.bp-raw {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.bp-raw code {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    word-break: break-all;
}

/* ── Detail Grid ── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.15rem;
}

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    word-break: break-word;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Misc ── */
.empty { color: var(--text-muted); padding: 1rem 0; }
.back-link { display: inline-block; margin-bottom: 1rem; color: var(--primary); text-decoration: none; font-size: 0.875rem; }
.back-link:hover { text-decoration: underline; }
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; justify-content: center; }
.raw-barcode { background: #f3f4f6; padding: 0.75rem; border-radius: 6px; font-size: 0.8rem; overflow-x: auto; word-break: break-all; }
code { font-family: 'Courier New', monospace; font-size: 0.8em; word-break: break-all; }

h1 { font-size: 1.35rem; margin-bottom: 1rem; }

a { color: var(--primary); }

/* ── Mobile ── */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 0.75rem;
    }
    .nav-brand a {
        font-size: 0.9rem;
    }
    .nav-links {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
    }
    .container { padding-top: 4rem;
        padding: 0.75rem;
    }
    .card {
        padding: 1rem;
    }
    .grid-2 { grid-template-columns: 1fr; }
    .bp-code { font-size: 1.5rem; }
    .bp-route { gap: 1rem; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    h1 { font-size: 1.2rem; }
    pre {
        overflow-x: auto;
        font-size: 0.7rem;
    }
}

@media (max-width: 400px) {
    .nav-links a {
        font-size: 0.65rem;
        padding: 0.25rem 0.35rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .bp-details {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Desktop/Mobile visibility ── */
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
    .mobile-only { display: block; }
    .desktop-only { display: none; }
}
