:root {
    color-scheme: light;
    --bg: #f8fafc;
    --panel: #ffffff;
    --panel-soft: #f1f5f9;
    --text: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --accent: #f59e0b;
    --focus: #f59e0b;
    --good: #10b981;
    --bad: #ef4444;
    --tag: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 22px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 50px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -10%, rgba(37, 99, 235, .12), transparent 30%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 360px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    line-height: 1.5;
}

body:not(.admin-body) {
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 50;
    padding: 10px 14px;
    border-radius: 6px;
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transition: top .18s ease;
}

.skip-link:focus { top: 12px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 20px;
}

.site-header h1,
.admin-top h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: 0;
}

.site-header p { margin: 6px 0 0; color: var(--muted); }
.site-main {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 12px 20px 44px;
    flex: 1 0 auto;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-logo,
.brand span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: var(--shadow-md);
    font-weight: 800;
}

.site-footer {
    width: 100%;
    max-width: 1180px;
    margin: auto auto 28px;
    padding: 0 20px;
    color: var(--muted);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 22px 0 0;
    border-top: 1px solid var(--line);
}

.footer-brand {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 14px;
    align-items: start;
}

.footer-logo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    grid-column: 1 / -1;
    margin-bottom: 0;
}

.site-footer strong {
    color: var(--text);
    font-size: 18px;
}

.site-footer p {
    max-width: 520px;
    margin: 0;
    color: #64748b;
    grid-column: 1 / -1;
}

.copyright {
    display: block;
    color: #94a3b8;
    font-size: 14px;
    grid-column: 1 / -1;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
}

.footer-title {
    color: var(--text);
    font-weight: 700;
    margin-right: 2px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
}

.footer-nav a,
.footer-links a {
    max-width: 100%;
    color: #475569;
}

.footer-nav a:hover,
.footer-links a:hover {
    color: var(--primary);
}

.content-page {
    max-width: 860px;
    margin: 10px auto 24px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-md);
}

.content-page h2 {
    margin: 0 0 16px;
    font-size: 30px;
}

.content-page p {
    margin: 0 0 14px;
    color: #475569;
    font-size: 16px;
}

.content-page details {
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.content-page details:first-of-type {
    border-top: 0;
}

.content-page summary {
    cursor: pointer;
    font-weight: 700;
}

.admin-link,
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 15px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

button:hover,
.button:hover,
.admin-link:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    text-decoration: none;
}

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

.ghost:hover {
    background: #eef4ff;
    color: var(--primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(249, 115, 22, .35);
    outline-offset: 2px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.search {
    display: flex;
    gap: 10px;
    flex: 1;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 13px;
    color: var(--text);
    background: #fff;
    font: inherit;
    transition: border-color .18s ease, box-shadow .18s ease;
}

textarea { resize: vertical; }
.search input { max-width: 520px; }
.count, .muted { color: var(--muted); }

.directory-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
    gap: 24px;
    align-items: stretch;
    margin-bottom: 20px;
    padding: 28px;
    border: 1px solid rgba(37, 99, 235, .16);
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .10), rgba(255, 255, 255, .88) 45%),
        #ffffff;
    box-shadow: var(--shadow-lg);
}

.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.eyebrow {
    width: max-content;
    margin-bottom: 12px;
    padding: 5px 10px;
    border: 1px solid rgba(37, 99, 235, .16);
    border-radius: 999px;
    background: #eff6ff;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
}

.hero-copy h2 {
    max-width: 620px;
    margin: 0 0 12px;
    font-size: 34px;
    line-height: 1.18;
    letter-spacing: 0;
}

.hero-copy p {
    max-width: 680px;
    margin: 0;
    color: #475569;
    font-size: 16px;
}

.hero-search {
    display: grid;
    align-content: center;
    gap: 16px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .86);
    box-shadow: var(--shadow-sm);
}

.hero-search .search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.hero-search .search input {
    max-width: none;
}

.filter-row {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.check-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin: 0;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}

.check-filter:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: var(--primary-dark);
}

.check-filter input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 12px;
}

.section-head h2 {
    margin: 0;
    font-size: 22px;
}

.section-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.faq-panel {
    margin-bottom: 16px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.faq-panel h2 {
    margin: 0 0 8px;
    font-size: 20px;
    letter-spacing: 0;
}

.faq-panel p {
    max-width: 780px;
    margin: 0;
    color: #475467;
}

.quick-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0 0;
}

.quick-facts div {
    padding: 12px;
    border: 1px solid #e6ebf2;
    border-radius: 10px;
    background: #f8fafc;
}

.quick-facts dt {
    color: var(--muted);
    font-size: 13px;
}

.quick-facts dd {
    margin: 4px 0 0;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.airport-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.airport-table th,
.airport-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.airport-table th {
    color: #364152;
    background: #f8fafc;
    font-weight: 700;
}

.airport-table tr:last-child td { border-bottom: 0; }
.airport-table tbody tr { transition: background-color .18s ease; }
.airport-table tbody tr:hover { background: #f8fbff; }
.col-serial { width: 78px; }

.tags,
.links,
.actions,
.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-flex;
    max-width: 100%;
    padding: 4px 8px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: var(--tag);
    color: #24466f;
    font-size: 13px;
    line-height: 1.35;
}

.links a {
    display: inline-flex;
    max-width: 100%;
    padding: 3px 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
}

.pagination a {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-jump label {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.page-jump input {
    width: 82px;
    min-height: 38px;
    padding: 7px 9px;
}

.page-jump button {
    min-height: 38px;
    padding: 7px 12px;
}

.faq-panel {
    margin-top: 18px;
}

.faq-panel details {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.faq-panel details:first-of-type { border-top: 0; }

.faq-panel summary {
    cursor: pointer;
    font-weight: 700;
}

.faq-panel p { margin-top: 8px; }

.auth-box,
.form-panel {
    max-width: 720px;
    margin: 42px auto;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.auth-box h2,
.form-panel h2 { margin: 0 0 14px; }

label {
    display: block;
    margin: 14px 0 7px;
    font-weight: 700;
}

label > input,
label > textarea {
    display: block;
    margin-top: 7px;
}

.field-hint {
    margin: 6px 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.flash {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 8px;
    background: #ecfdf3;
    color: var(--good);
    border: 1px solid #abefc6;
}

.flash.bad {
    background: #fef3f2;
    color: var(--bad);
    border-color: #fecdca;
}

.admin-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
    background: #f1f5f9;
}

.admin-sidebar {
    background: linear-gradient(180deg, #111827 0%, #1e1b4b 100%);
    color: #fff;
    padding: 22px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 26px;
}

.brand span {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    box-shadow: none;
}

.admin-sidebar nav {
    display: grid;
    gap: 8px;
}

.admin-sidebar a {
    padding: 10px 12px;
    border-radius: 8px;
    color: #e4e7ec;
    transition: background-color .18s ease, color .18s ease;
}

.admin-sidebar a:hover {
    background: #243447;
    text-decoration: none;
}

.admin-main {
    min-width: 0;
    padding: 24px;
}

.admin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.admin-user,
.admin-user form,
.actions form,
.user-actions form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.admin-toolbar { align-items: stretch; }
.admin-table .button { min-height: 32px; padding: 5px 10px; }

.status {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.status.on { color: var(--good); background: #ecfdf3; }
.status.off { color: var(--bad); background: #fef3f2; }

.form-actions,
.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.compact {
    max-width: none;
    margin: 0 0 18px;
}

.inline-form input { max-width: 240px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 30px;
    line-height: 1.1;
}

.stats-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.stats-section {
    margin-top: 18px;
}

@media (max-width: 760px) {
    .site-header,
    .toolbar,
    .admin-top,
    .admin-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .brand-block {
        align-items: flex-start;
    }

    .site-header h1,
    .admin-top h1 { font-size: 24px; }

    .site-main { padding: 10px 12px 34px; }

    .directory-hero {
        grid-template-columns: 1fr;
        padding: 18px;
        border-radius: 12px;
    }

    .hero-copy h2 {
        font-size: 27px;
    }

    .hero-search {
        padding: 14px;
    }

    .search,
    .hero-search .search,
    .form-actions,
    .inline-form { flex-direction: column; }

    .hero-search .search {
        display: flex;
    }

    .filter-row,
    .page-jump {
        width: 100%;
    }

    .check-filter {
        flex: 1;
        justify-content: center;
    }

    .search input,
    .inline-form input { max-width: none; }

    .admin-body { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; }
    .admin-sidebar nav { grid-template-columns: 1fr; }
    .admin-main { padding: 18px 14px; }

    .quick-facts { grid-template-columns: 1fr; }

    .stats-grid,
    .stats-columns,
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .site-footer {
        margin-bottom: 18px;
    }

    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .table-wrap {
        border: 0;
        background: transparent;
        overflow: visible;
    }

    .airport-table,
    .airport-table thead,
    .airport-table tbody,
    .airport-table tr,
    .airport-table th,
    .airport-table td {
        display: block;
        width: 100%;
    }

    .airport-table thead { display: none; }

    .airport-table tr {
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
    }

    .airport-table td {
        display: grid;
        grid-template-columns: 68px minmax(0, 1fr);
        gap: 10px;
        padding: 8px 0;
        border: 0;
    }

    .airport-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .page-jump {
        justify-content: center;
        order: 3;
    }

    .user-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .user-actions form {
        width: 100%;
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
