:root {
    --bg: #f5f1e8;
    --surface: rgba(255, 252, 247, 0.78);
    --surface-strong: #fffaf1;
    --text: #1f2a21;
    --muted: #59685c;
    --primary: #245c4a;
    --primary-strong: #173f32;
    --accent: #d38b43;
    --danger: #b5543a;
    --danger-strong: #8f3a2c;
    --border: rgba(36, 92, 74, 0.14);
    --shadow: 0 20px 60px rgba(31, 42, 33, 0.12);
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
            radial-gradient(circle at top right, rgba(211, 139, 67, 0.28), transparent 28%),
            radial-gradient(circle at left center, rgba(36, 92, 74, 0.2), transparent 22%),
            linear-gradient(160deg, #f8f4ec 0%, #e9efe7 100%);
}
.shell {
    width: min(1080px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 3rem 0 4rem;
}
.hero {
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--surface);
    backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
}
.eyebrow {
    margin: 0 0 0.75rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
}
h1 {
    margin: 0;
    font-size: clamp(2.3rem, 7vw, 4.8rem);
    line-height: 0.95;
}
.lead,
.form-intro {
    max-width: 46rem;
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.7;
}
.actions,
.form-actions,
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 1.2rem;
}
.button,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.9rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.98rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.button:hover,
button:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(31, 42, 33, 0.12);
}
.button:focus-visible,
button:focus-visible,
input[type="submit"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(211, 139, 67, 0.35);
    outline-offset: 2px;
}
.button.primary,
button.primary,
input[type="submit"].primary {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}
.button.secondary,
button.secondary {
    color: var(--primary-strong);
    background: rgba(255, 255, 255, 0.82);
    border-color: var(--border);
}
.button.danger,
button.danger {
    color: white;
    background: linear-gradient(135deg, var(--danger), var(--danger-strong));
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.card {
    padding: 1.4rem;
    border-radius: 22px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card h2 {
    margin: 0 0 0.65rem;
    font-size: 1.1rem;
}
.card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}
.form-panel {
    margin-top: 1.5rem;
    padding: 1.5rem;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    box-shadow: var(--shadow);
}
.form-grid {
    display: grid;
    gap: 1rem;
}
.field {
    display: grid;
    gap: 0.45rem;
}
.field label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-strong);
}
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.field textarea {
    min-height: 140px;
    resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder {
    color: #7f8a80;
}
.result-panel {
    margin-top: 1.2rem;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: #f2f5ef;
    border: 1px solid var(--border);
    color: var(--primary-strong);
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.split-layout {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.compact-panel {
    padding: 1.25rem;
    border-radius: 22px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.compact-panel h2 {
    margin: 0 0 0.85rem;
    font-size: 1.15rem;
}
.compact-panel p {
    margin: 0 0 1rem;
    color: var(--muted);
}
@media (max-width: 760px) {
    .shell {
        width: min(100% - 1.25rem, 1080px);
        padding-top: 1.25rem;
    }
    .hero,
    .card,
    .form-panel,
    .compact-panel {
        padding: 1.25rem;
        border-radius: 20px;
    }
    .card-grid,
    .split-layout {
        grid-template-columns: 1fr;
    }
    .actions,
    .form-actions,
    .page-actions {
        flex-direction: column;
    }
    .button,
    button,
    input[type="submit"] {
        width: 100%;
    }
}

.session-badge {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    color: var(--primary-strong);
    box-shadow: var(--shadow);
}
.session-badge strong {
    color: var(--primary);
}

.geo-status,
.geo-preview {
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.78);
    color: var(--primary-strong);
    line-height: 1.5;
}
.geo-status[data-state="idle"] {
    background: rgba(255, 255, 255, 0.78);
}
.geo-status[data-state="pending"] {
    background: rgba(211, 139, 67, 0.16);
    border-color: rgba(211, 139, 67, 0.34);
}
.geo-status[data-state="success"] {
    background: rgba(36, 92, 74, 0.12);
    border-color: rgba(36, 92, 74, 0.28);
}
.geo-status[data-state="error"] {
    background: rgba(181, 84, 58, 0.12);
    border-color: rgba(181, 84, 58, 0.28);
}

.offline-status {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.78);
    color: var(--primary-strong);
    line-height: 1.5;
}
.offline-status[data-state="online"] {
    background: rgba(36, 92, 74, 0.10);
    border-color: rgba(36, 92, 74, 0.28);
}
.offline-status[data-state="offline"] {
    background: rgba(211, 139, 67, 0.14);
    border-color: rgba(211, 139, 67, 0.34);
}

.offline-card-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.offline-card {
    padding: 1.25rem;
    border-radius: 22px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.offline-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.offline-card-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--primary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 700;
}
.offline-card h3 {
    margin: 0;
    font-size: 1.2rem;
}
.offline-card p {
    margin: 0.35rem 0;
    color: var(--muted);
    line-height: 1.5;
}
.offline-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(211, 139, 67, 0.16);
    border: 1px solid rgba(211, 139, 67, 0.34);
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.server-card-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.server-card {
    padding: 1.3rem;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 250, 241, 0.98), rgba(245, 249, 243, 0.98));
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.server-card h3 {
    margin: 0;
    font-size: 1.35rem;
}

.server-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(36, 92, 74, 0.10);
    border: 1px solid rgba(36, 92, 74, 0.22);
    color: var(--primary-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.server-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.server-meta-grid p,
.server-location-box p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.server-location-box {
    display: grid;
    gap: 0.5rem;
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--border);
}

.debug-panel {
    margin-top: 1.5rem;
}

.debug-panel summary {
    cursor: pointer;
    color: var(--primary-strong);
    font-weight: 700;
}

.debug-panel[open] .result-panel {
    margin-top: 0.85rem;
}

.map-hero {
    overflow: hidden;
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.95fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.map-canvas {
    min-height: 580px;
    border-radius: 26px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 250, 241, 0.92), rgba(233, 239, 231, 0.92));
}

.map-sidebar {
    display: grid;
    gap: 1rem;
}

.map-list-panel {
    min-height: 260px;
}

.map-results-list {
    display: grid;
    gap: 0.85rem;
}

.map-result-item {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.74);
}

.map-result-item h3 {
    margin: 0 0 0.45rem;
    font-size: 1.05rem;
}

.map-result-item p {
    margin: 0.2rem 0;
    color: var(--muted);
    line-height: 1.45;
}

.leaflet-popup-content-custom {
    color: var(--primary-strong);
    line-height: 1.55;
}

.leaflet-popup-content-custom strong {
    display: inline-block;
    margin-bottom: 0.35rem;
}

@media (max-width: 760px) {
    .offline-card-grid {
        grid-template-columns: 1fr;
    }
    .offline-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .server-card-grid,
    .server-meta-grid {
        grid-template-columns: 1fr;
    }

    .server-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .map-layout {
        grid-template-columns: 1fr;
    }

    .map-canvas {
        min-height: 420px;
        border-radius: 22px;
    }
}
