:root {
    --primary: #2f6f3e;
    --primary-dark: #1f4d2a;
    --accent: #bce9b6;
    --bg: #f6faf6;
    --card: #ffffff;
    --text: #213126;
    --muted: #5c6f61;
    --border: #d7e6d7;
    --danger-bg: #fff2f2;
    --danger-border: #efc0c0;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #f7fbf7 0%, #edf6ee 100%);
    color: var(--text);
    font-family: 'Comfortaa', system-ui, sans-serif;
    min-height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.brand-title,
.site-title,
.search-title {
    font-family: 'Cinzel', 'Times New Roman', serif;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    text-decoration: none;
}

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
}

.hub-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px 26px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 14px;
    text-decoration: none;
    background: #eef6ef;
    color: var(--primary-dark);
    border: 1px solid var(--border);
}

.site-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.icon-btn,
.primary-btn,
.secondary-btn,
.proceed-btn {
    text-decoration: none;
    border: none;
    cursor: pointer;
    border-radius: 14px;
    font-family: inherit;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--accent);
    color: var(--primary-dark);
    font-size: 1.2rem;
}

.primary-btn,
.proceed-btn {
    background: var(--primary);
    color: #fff;
    padding: 12px 18px;
    font-weight: 700;
}

.secondary-btn {
    background: #eef6ef;
    color: var(--primary-dark);
    padding: 10px 16px;
    border: 1px solid var(--border);
}

.landing-wrapper,
.gate-wrapper,
.search-page {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.landing-card,
.gate-card,
.search-card {
    width: 100%;
    max-width: 1100px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(36, 77, 42, 0.08);
}

.landing-card,
.gate-card {
    max-width: 760px;
    text-align: center;
    padding: 32px;
}

.search-card {
    padding: 24px;
}

.landing-logo {
    width: 180px;
    max-width: 60%;
    margin-bottom: 10px;
}

.brand-title {
    margin: 8px 0 4px;
    font-size: 2.2rem;
    color: var(--primary-dark);
}

.brand-title.small {
    font-size: 1.8rem;
}

.brand-subtitle {
    color: var(--muted);
    margin-bottom: 18px;
    font-weight: 600;
}

.system-description {
    line-height: 1.7;
    margin-bottom: 22px;
}

.warning-box,
.error-box {
    border-radius: 18px;
    padding: 18px;
    text-align: left;
}

.warning-box {
    background: #fffdf4;
    border: 1px solid #f0e0a0;
    margin-bottom: 22px;
}

.error-box {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #8b2222;
    margin-bottom: 14px;
}

.proceed-btn {
    display: inline-block;
    padding: 16px 26px;
    font-size: 1.05rem;
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.gate-form input,
.search-controls input,
.search-controls select {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.95rem;
}

.gate-note {
    color: var(--muted);
    margin-top: 14px;
    font-size: 0.92rem;
}

.search-header-row,
.results-meta-wrap,
.pagination-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.search-banner {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff8e8;
    border: 1px solid #ecd9a2;
    color: #6e5710;
    font-size: 0.92rem;
}

.search-controls {
    display: grid;
    grid-template-columns: 1fr 180px 140px;
    gap: 12px;
    margin: 18px 0 12px;
}

.suggestions-box {
    min-height: 24px;
    margin-bottom: 12px;
}

.suggestion-label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.suggestion-item {
    margin-right: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f7fbf7;
    cursor: pointer;
    font-family: inherit;
}

.results-meta {
    font-size: 0.95rem;
}

.swipe-tip {
    font-size: 0.88rem;
    color: var(--muted);
    text-align: right;
}

.table-area {
    position: relative;
}

.table-wrap {
    margin-top: 12px;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: white;
    position: relative;
    scroll-behavior: smooth;
}

#resultsTable {
    width: 100%;
    min-width: 1250px;
    border-collapse: separate;
    border-spacing: 0;
}

#resultsTable th,
#resultsTable td {
    padding: 12px 14px;
    border-bottom: 1px solid #edf2ed;
    text-align: left;
    vertical-align: top;
    font-size: 0.92rem;
    background: #ffffff;
    white-space: nowrap;
}

#resultsTable thead th {
    position: sticky;
    top: 0;
    background: #f2f8f2;
    color: var(--primary-dark);
    z-index: 5;
}

#resultsTable tbody tr:nth-child(even) td {
    background: #fcfdfc;
}

/* Temporary hide for reciprocated status columns. */
.results-column-hidden {
    display: none;
}

.empty-cell {
    text-align: center !important;
    color: var(--muted);
    padding: 26px !important;
}

/* Desktop frozen columns only */
@media (min-width: 992px) {
    #resultsTable th:nth-child(1),
    #resultsTable td:nth-child(1) {
        position: sticky;
        left: 0;
        min-width: 90px;
        width: 90px;
        z-index: 6;
        box-shadow: 1px 0 0 #dfe9df;
    }

    #resultsTable thead th:nth-child(1) {
        background: #eaf4ea;
        z-index: 8;
    }

    #resultsTable tbody td:nth-child(1) {
        background: #f2f8f2;
    }

    #resultsTable tbody tr:nth-child(even) td:nth-child(1) {
        background: #edf6ed;
    }

    #resultsTable th:nth-child(2),
    #resultsTable td:nth-child(2) {
        position: sticky;
        left: 90px;
        min-width: 190px;
        width: 190px;
        z-index: 6;
        box-shadow: 1px 0 0 #dfe9df;
    }

    #resultsTable thead th:nth-child(2) {
        background: #f2f8f2;
        z-index: 8;
    }

    #resultsTable tbody td:nth-child(2) {
        background: #ffffff;
    }

    #resultsTable tbody tr:nth-child(even) td:nth-child(2) {
        background: #fcfdfc;
    }
}

.pagination-wrap {
    margin-top: 14px;
    justify-content: center;
}

.table-scroll-buttons {
    position: fixed;
    right: 22px;
    bottom: 110px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

.table-scroll-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.table-scroll-btn:hover {
    transform: translateY(-2px);
}

.table-scroll-btn.hidden {
    display: none;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    font-size: 0.86rem;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.modal-content {
    position: relative;
    width: min(760px, calc(100% - 24px));
    max-height: 85vh;
    overflow-y: auto;
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.modal-body p {
    line-height: 1.7;
    margin: 0 0 14px;
}

@media (max-width: 991px) {
    .desktop-only {
        display: none;
    }
}

@media (max-width: 860px) {
    .search-controls {
        grid-template-columns: 1fr;
    }

    .results-meta-wrap,
    .site-footer,
    .search-header-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .swipe-tip {
        text-align: left;
    }

    .topbar {
        padding: 14px 16px;
    }

    .search-page {
        padding: 14px;
    }

    .search-card {
        padding: 16px;
    }
}
