:root {
    --color-primary:      #1d4ed8;
    --color-primary-dark: #1e3a8a;
    --color-primary-light:#dbeafe;
    --color-success:      #166534;
    --color-success-bg:   #dcfce7;
    --color-gain-bar:     #22c55e;
    --color-error:        #991b1b;
    --color-error-bg:     #fee2e2;
    --color-text:         #1e293b;
    --color-muted:        #64748b;
    --color-border:       #cbd5e1;
    --color-bg:           #f1f5f9;
    --color-card:         #ffffff;
    --radius:             10px;
    --shadow:             0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
    --font:               -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Auth pages ─────────────────────────────────────────── */
body.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

/* Live app preview (rvexplorer.php?demo=1) behind the login card */
.auth-bg-demo {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.auth-bg-demo iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.auth-bg-demo::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(241, 245, 249, 0.2); /* --color-bg at 30% */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

body.auth-page .auth-container,
body.auth-page .site-footer {
    position: relative;
    z-index: 1;
    background: var(--color-bg); /* solid over the demo preview */
}

body.auth-page .auth-container {
    border-radius: var(--radius); /* match the card's rounded corners */
    padding: 1.5rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-brand h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.5px;
}

.auth-brand p {
    color: var(--color-muted);
    margin-top: .25rem;
    font-size: .95rem;
}

.card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .9rem;
    color: var(--color-muted);
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Form elements ──────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .35rem;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: .6rem .75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--color-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input-wrap {
    position: relative;
}

.input-wrap input { padding-right: 2.75rem; }

.toggle-pw {
    position: absolute;
    right: .6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-muted);
    padding: .25rem;
    line-height: 1;
}

.toggle-pw:hover { color: var(--color-text); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.25rem;
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s;
    text-decoration: none;
}

.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover { background: var(--color-primary-dark); }

.btn-primary:disabled {
    background: var(--color-border);
    color: var(--color-muted);
    cursor: not-allowed;
}
.btn-primary:disabled:hover { background: var(--color-border); }

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}

.btn-ghost:hover {
    background: var(--color-primary-light);
}

.btn-full { width: 100%; margin-top: .5rem; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    font-size: .9rem;
    margin-bottom: 1rem;
}

.alert-error   { background: var(--color-error-bg);   color: var(--color-error); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }

/* ── Toast notification ─────────────────────────────────── */
.map-toast {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: .6rem 1rem;
    font-size: .85rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 1;
    transition: opacity .4s ease;
}
.map-toast.is-hiding { opacity: 0; }

/* ── OSM reload control ──────────────────────────────────── */
.leaflet-top.leaflet-right {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
    padding-top: 10px;
    padding-right: 10px;
}
.leaflet-top.leaflet-right > .leaflet-control {
    float: none;
    margin: 0 0 0 5px !important;
}
.osm-reload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    background: #fff;
    border-radius: 4px;
    transition: background-color .15s;
}
.osm-reload-btn:hover { background-color: #f4f4f4; }
.osm-reload-btn--loading {
    cursor: default;
    pointer-events: none;
}
.osm-reload-btn--loading span {
    display: inline-block;
    animation: osm-spin .9s linear infinite;
}
.osm-reload-btn--countdown {
    font-size: .7rem;
    font-weight: 700;
    color: #2563eb;
}
.osm-reload-btn--disabled {
    opacity: .35;
}
@keyframes osm-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── RvExplorer layout ──────────────────────────────────── */
.site-header {
    background: var(--color-card);
    box-shadow: 0 1px 0 var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1001; /* above Leaflet's control layer (z-index 1000) */
}

.site-header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
}

.site-logo-img {
    height: 2rem;
    width: auto;
    display: block;
}

.site-logo-group {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.site-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}
.site-name:hover { text-decoration: underline; }

.header-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .9rem;
    color: var(--color-muted);
}

.main-content {
    max-width: 1000px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
    flex: 1;
}
.main-content--wide {
    max-width: none;
}

.welcome-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 2.25rem;
}

.welcome-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .35rem;
}

.welcome-card .subtitle {
    color: var(--color-muted);
    font-size: .95rem;
    margin-bottom: 1.5rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.meta-item {
    background: var(--color-bg);
    border-radius: 8px;
    padding: .875rem 1rem;
}

.meta-item .meta-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    margin-bottom: .2rem;
}

.meta-item .meta-value {
    font-size: .95rem;
    font-weight: 500;
    color: var(--color-text);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .card { padding: 1.5rem; }
    .welcome-card { padding: 1.5rem; }
}

/* ── Social login buttons ───────────────────────────────── */
.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    width: 100%;
    padding: .6rem 1rem;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    border: 1.5px solid var(--color-border);
    transition: background .15s;
}

.btn-google {
    background: #fff;
    color: #3c4043;
}

.btn-google:hover { background: #f8f9fa; }

.btn-microsoft {
    background: #2f2f2f;
    color: #fff;
    border-color: #2f2f2f;
}

.btn-microsoft:hover { background: #1a1a1a; }

.social-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1rem 0;
    color: var(--color-muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.social-divider::before,
.social-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ── Terms of Use box ───────────────────────────────────── */
.terms-box {
    height: 160px;
    overflow-y: scroll;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    padding: .75rem;
    background: var(--color-bg);
    font-size: .8rem;
    line-height: 1.55;
    color: var(--color-muted);
    white-space: pre-wrap;
    margin-bottom: .6rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-top: .15rem;
    flex-shrink: 0;
}

/* ── Badge (unread count) ───────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #dc2626;
    color: #fff;
    border-radius: 9px;
    font-size: .68rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

/* ── Admin header badge ─────────────────────────────────── */
.admin-badge {
    display: inline-block;
    padding: .2rem .55rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* ── Data table (admin panel) ───────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table th,
.data-table td {
    padding: .6rem .85rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-muted);
    background: var(--color-bg);
    white-space: nowrap;
}

.data-table tbody tr:hover td { background: var(--color-bg); }
.data-table tbody tr:last-child td { border-bottom: none; }

.row-inactive td { opacity: .55; }

.action-cell { white-space: nowrap; }

/* ── Role badge ─────────────────────────────────────────── */
.role-badge {
    display: inline-block;
    padding: .15rem .45rem;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.role-admin {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.role-user {
    background: var(--color-bg);
    color: var(--color-muted);
    border: 1px solid var(--color-border);
}

.role-management {
    background: #fef3c7;
    color: #92400e;
}

/* ── Inline link-style buttons ──────────────────────────── */
.btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: .875rem;
    color: var(--color-primary);
    cursor: pointer;
    font-family: var(--font);
    text-decoration: none;
}

.btn-link:hover { text-decoration: underline; }

.btn-link-danger { color: var(--color-error); }
.btn-link-muted  { color: var(--color-muted); }

/* ── Danger button ──────────────────────────────────────── */
.btn-danger {
    background: #dc2626;
    color: #fff;
    border: none;
}

.btn-danger:hover { background: #b91c1c; }

/* ── Page title bar ─────────────────────────────────────── */
.page-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title-bar h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

/* ── TOTP setup ─────────────────────────────────────────── */
.totp-secret {
    font-family: 'Courier New', Courier, monospace;
    font-size: .9rem;
    letter-spacing: .1em;
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    padding: .6rem .75rem;
    word-break: break-all;
    color: var(--color-text);
}

.qrcode-wrap {
    display: flex;
    justify-content: center;
    margin: .5rem 0;
}

/* ── Message rows ───────────────────────────────────────── */
.message-row {
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background .1s;
}

.message-row:last-child { border-bottom: none; }
.message-row:hover { background: var(--color-bg); }

.message-unread .message-subject { font-weight: 700; }

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.message-subject { font-size: .95rem; }

.message-meta {
    font-size: .8rem;
    color: var(--color-muted);
    white-space: nowrap;
}

.message-body {
    padding: .25rem 1.1rem 1rem;
    font-size: .9rem;
    color: var(--color-text);
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

/* ── Select / Textarea ──────────────────────────────────── */
select,
textarea {
    width: 100%;
    padding: .6rem .75rem;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--color-text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ── Dark mode (follows browser preference) ─────────────── */
@media (prefers-color-scheme: dark) {
    :root {
        --color-primary:      #3b82f6;
        --color-primary-dark: #60a5fa;
        --color-primary-light:#1e3a8a;
        --color-success:      #4ade80;
        --color-success-bg:   #14532d;
        --color-gain-bar:     #4ade80;
        --color-error:        #f87171;
        --color-error-bg:     #7f1d1d;
        --color-text:         #f1f5f9;
        --color-muted:        #94a3b8;
        --color-border:       #334155;
        --color-bg:           #0f172a;
        --color-card:         #1e293b;
        --shadow:             0 4px 24px rgba(0,0,0,.5), 0 1px 4px rgba(0,0,0,.3);
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        background: #1e293b;
        color: var(--color-text);
    }

    .btn-google {
        background: #2d2d2d;
        color: #e8eaed;
        border-color: var(--color-border);
    }

    .btn-google:hover { background: #3a3a3a; }

}

/* ── Site footer ────────────────────────────────────────── */
.site-footer {
    width: 100%;
    text-align: center;
    padding: 1.5rem;
    font-size: .8rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.site-footer a {
    color: var(--color-muted);
    text-decoration: none;
}

.funding-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    margin-bottom: .75rem;
    font-size: .78rem;
    color: var(--color-muted);
}

.funding-logo {
    height: 36px;
    width: auto;
}

/* ── Hamburger nav ────────────────────────────────────── */
.nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    color: var(--color-text);
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
    transform-origin: center;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.site-nav {
    display: none;
    position: absolute;
    top: 60px;
    right: 1.5rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 210px;
    z-index: 20;
    padding: .35rem 0;
}

.site-nav.is-open { display: block; }

.nav-user {
    padding: .5rem 1rem .6rem;
    font-size: .8rem;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: .25rem;
}

.nav-link, button.nav-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1rem;
    font-size: .9rem;
    color: var(--color-text);
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
    cursor: pointer;
    line-height: 1.4;
}

.nav-link:hover, button.nav-link:hover { background: var(--color-bg); }

.nav-divider { height: 1px; background: var(--color-border); margin: .25rem 0; }

/* ── Wind Farm Tool ───────────────────────────── */
.tool-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem 2rem;
    margin-top: 1.5rem;
}

.tool-heading {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: .4rem;
}

.tool-step { margin-bottom: 1.75rem; }

.tool-step-label {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--color-text);
    margin-bottom: .75rem;
}

.step-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.step-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: .45rem .9rem;
    font-size: .875rem;
    font-family: var(--font);
    color: var(--color-muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color .15s;
}

.step-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.step-tab:hover:not(.is-active) { color: var(--color-text); }

.step-panel { padding-top: .5rem; }

.file-drop {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .875rem;
    color: var(--color-muted);
    transition: border-color .15s, color .15s;
    max-width: 100%;
}
.file-drop:hover { border-color: var(--color-primary); color: var(--color-primary); }
.file-drop input[type="file"] { display: none; }
.file-drop-icon { font-size: 1.1rem; }

.form-hint { font-size: .8rem; color: var(--color-muted); margin-top: .5rem; }

.session-banner {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .8rem;
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: .35rem .65rem;
    margin-bottom: .6rem;
}
.session-banner-icon { flex-shrink: 0; }
.session-banner-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: inherit;
    opacity: .6;
    padding: 0 .15rem;
}
.session-banner-close:hover { opacity: 1; }
.session-banner[hidden] { display: none; }

.session-expired-banner {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: .85rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: .5rem .75rem;
    margin-bottom: .6rem;
}
.session-expired-banner a,
.session-expired-banner button.session-expired-reload {
    margin-left: auto;
    flex-shrink: 0;
    background: #d97706;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: .25rem .65rem;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.session-expired-banner button.session-expired-reload:hover { background: #b45309; }
.session-expired-banner[hidden] { display: none; }

@media (prefers-color-scheme: dark) {
    .session-expired-banner {
        color: #fcd34d;
        background: rgba(217,119,6,.12);
        border-color: rgba(217,119,6,.35);
    }
    .session-expired-banner button.session-expired-reload {
        background: #b45309;
    }
    .session-expired-banner button.session-expired-reload:hover { background: #92400e; }
}


@media (prefers-color-scheme: dark) {
    .session-banner {
        color: #93c5fd;
        background: rgba(59,130,246,.1);
        border-color: rgba(59,130,246,.3);
    }
}

.wr-saved-notice {
    margin-top: .5rem;
    font-size: .8rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: .35rem .65rem;
}
@media (prefers-color-scheme: dark) {
    .wr-saved-notice {
        color: #fde68a;
        background: rgba(251,191,36,.12);
        border-color: rgba(251,191,36,.35);
    }
}
.form-hint code { font-size: .78rem; background: var(--color-bg); padding: .1rem .3rem; border-radius: 4px; }

.coord-pair { display: flex; gap: 1rem; flex-wrap: wrap; }
.coord-pair .form-group { flex: 1; min-width: 10rem; }

.table-scroll { overflow-x: auto; }

.turbine-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.turbine-table th {
    text-align: left;
    padding: .4rem .5rem;
    font-weight: 600;
    font-size: .78rem;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
}
.turbine-table td { padding: .25rem .3rem; vertical-align: middle; }
.turbine-table .t-num {
    width: 100%;
    padding: .3rem .5rem;
    font-size: .875rem;
    font-family: var(--font);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    min-width: 7rem;
}
.turbine-table .t-num:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.input-invalid {
    border-color: var(--color-error) !important;
    background:   var(--color-error-bg) !important;
}

.turb-type-invalid {
    border-color: var(--color-error) !important;
    background:   var(--color-error-bg) !important;
    color:        var(--color-error) !important;
}

/* ── Modal overlay (shared by all JS-created dialogs) ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay[hidden] { display: none !important; }
.modal-box {
    background: var(--color-card);
    color: var(--color-text);
    border-radius: .5rem;
    padding: 1.5rem;
    width: 90%;
    box-shadow: var(--shadow);
}
.modal-title {
    margin: 0 0 .5rem;
    font-size: 1rem;
}
.modal-title-error {
    margin: 0 0 .75rem;
    font-size: 1rem;
    color: var(--color-error);
}
.modal-body {
    margin: 0 0 .75rem;
    font-size: .9rem;
    line-height: 1.5;
}
.modal-sub {
    margin: 0 0 1rem;
    font-size: .85rem;
    line-height: 1.4;
    color: var(--color-muted);
}
.modal-list {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
    font-size: .9rem;
}
.modal-choice-desc {
    display: block;
    font-size: .78rem;
    color: var(--color-muted);
    margin-top: .1rem;
}
.modal-cancel {
    color: var(--color-muted) !important;
    font-size: .82rem !important;
    margin-top: .2rem !important;
}

/* ── Map popup elements ──────────────────────────── */
button.popup-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: .95rem;
    color: var(--color-muted);
    padding: 0 0 0 6px;
    line-height: 1;
    transition: color .15s;
}
button.popup-delete-btn:hover { color: var(--color-error); }

.popup-label {
    color: var(--color-muted);
    padding-right: 10px;
    white-space: nowrap;
    vertical-align: middle;
}
.popup-input {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-card);
    color: var(--color-text);
}
.popup-bar-label {
    font-size: .72rem;
    color: var(--color-muted);
    margin-bottom: 3px;
    white-space: nowrap;
}
.popup-bar-track {
    position: relative;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}
.popup-bar-base {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    background: var(--color-muted);
    transition: width .4s;
}
.popup-bar-gain {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--color-gain-bar);
    transition: width .4s, left .4s;
}

/* ── Leaflet popup theming ───────────────────────── */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: var(--color-card) !important;
    color: var(--color-text) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-popup-content-wrapper {
    border: 1px solid var(--color-border) !important;
}

/* Leaflet tooltips (POI markers) */
.leaflet-tooltip {
    background: var(--color-card) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-tooltip-top::before {
    border-top-color: var(--color-border) !important;
}
.leaflet-tooltip-bottom::before {
    border-bottom-color: var(--color-border) !important;
}
.leaflet-tooltip-left::before {
    border-left-color: var(--color-border) !important;
}
.leaflet-tooltip-right::before {
    border-right-color: var(--color-border) !important;
}

/* Layer control button + panel */
.leaflet-control-layers-toggle {
    background-color: var(--color-card) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow) !important;
    filter: none !important;
}
.leaflet-control-layers {
    background: var(--color-card) !important;
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow) !important;
    color: var(--color-text) !important;
}
.leaflet-control-layers-list label {
    color: var(--color-text) !important;
}
.leaflet-control-layers-separator {
    border-color: var(--color-border) !important;
}

.power-input-row { display: flex; align-items: center; gap: .6rem; }
.power-input-row input[type="number"] {
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
}
.power-input-row input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.unit-label { font-size: .9rem; color: var(--color-muted); font-weight: 600; }

.tool-result {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.result-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    padding: .75rem 0;
}
.result-value-inline {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    white-space: nowrap;
}

.result-json {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    font-size: .8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
}

/* ── Turbine type summary table ─────────────────── */
.type-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
}
.type-summary-table th,
.type-summary-table td {
    padding: .3rem .5rem;
    text-align: center;
    border: 1px solid var(--color-border);
}
.type-summary-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-muted);
}
.type-summary-table td:first-child {
    text-align: left;
    font-weight: 500;
    color: var(--color-text);
    max-width: 12rem;
    word-break: break-word;
}
.type-summary-yes { color: #16a34a; font-weight: 700; }
.type-summary-no  { color: var(--color-muted); }

.result-breakdown {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin: .6rem 0 0;
}
.rb-item {
    flex: 1;
    min-width: 5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .5rem .6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
}
.rb-label {
    font-size: .7rem;
    color: var(--color-muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.rb-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary);
}

.result-sentence {
    margin: .5rem 0 0;
    font-size: .95rem;
    color: var(--color-text);
    line-height: 1.5;
}
.result-sentence:first-child {
    margin-top: 0;
}
.result-sentence strong {
    color: var(--color-primary);
    font-weight: 700;
}

.calc-hints {
    margin: .5rem 0 .75rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.turb-hover-hint {
    font-size: .78rem;
    color: var(--color-muted);
    margin: 0;
}
.session-storage-hint {
    font-size: .75rem;
    color: var(--color-muted);
    margin: 0;
    line-height: 1.4;
}
.calc-attribution {
    font-size: .7rem;
    color: var(--color-muted);
    margin: 0;
    line-height: 1.4;
    padding-top: .25rem;
    border-top: 1px solid var(--color-border);
}
.calc-attribution a {
    color: var(--color-muted);
    text-decoration: underline;
}
abbr[title] {
    text-decoration: underline dotted;
    cursor: help;
}

.result-note {
    margin: .75rem 0 0;
    font-size: .78rem;
    color: var(--color-muted);
    padding: .4rem .65rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    border-left: 2px solid var(--color-border);
}

/* ── Result hero metric card ────────────────────────────── */
.result-hero-stack {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: .5rem 0 .75rem;
}
.result-hero {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1rem;
    background: var(--color-primary-light);
    border-radius: var(--radius);
}
.result-hero--loss {
    background: var(--color-error-bg);
}
.result-hero--loss .result-hero-num,
.result-hero--loss .result-hero-prefix,
.result-hero--loss .result-hero-suffix,
.result-hero--loss .result-hero-title {
    color: var(--color-error);
}
.result-hero--gain {
    background: var(--color-success-bg);
}
.result-hero--gain .result-hero-num,
.result-hero--gain .result-hero-prefix,
.result-hero--gain .result-hero-suffix,
.result-hero--gain .result-hero-title {
    color: var(--color-success);
}
.result-hero-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-shrink: 0;
    gap: .05rem;
}
.result-hero-prefix {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--color-primary);
    opacity: .75;
    line-height: 1;
}
.result-hero-suffix {
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--color-primary);
    opacity: .75;
    line-height: 1;
}
.result-hero-num {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    line-height: 1;
    letter-spacing: -.03em;
    white-space: nowrap;
}
.result-hero-unit {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0;
}
.result-hero-text {
    flex: 1;
    min-width: 0;
}
.result-hero-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-primary);
}
.result-hero-desc {
    font-size: .75rem;
    color: var(--color-muted);
    margin-top: .1rem;
    line-height: 1.4;
}
.result-hero-wake {
    display: flex;
    align-items: baseline;
    gap: .3rem;
    flex-wrap: wrap;
    font-size: .75rem;
    color: var(--color-muted);
    margin-top: .45rem;
    padding-top: .35rem;
    border-top: 1px solid rgba(100,116,139,.25);
}
.result-hero-wake strong {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    letter-spacing: -.02em;
    line-height: 1;
}

/* ── Result breakdown section label ─────────────────────── */
.result-breakdown-section {
    margin-bottom: .5rem;
}
.result-breakdown-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--color-muted);
    margin-bottom: .35rem;
}

/* ── Debug output section ───────────────────────────────── */
.debug-section {
    margin-top: .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    font-size: .82rem;
}
.debug-summary {
    padding: .4rem .65rem;
    cursor: pointer;
    color: var(--color-muted);
    user-select: none;
    list-style: none;
}
.debug-summary::-webkit-details-marker { display: none; }
.debug-summary::before { content: '▶ '; font-size: .7rem; }
details[open] .debug-summary::before { content: '▼ '; }
.debug-body {
    padding: .5rem .65rem .65rem;
    border-top: 1px solid var(--color-border);
}
.debug-aep {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: .4rem;
    color: var(--color-text);
}
.debug-note {
    margin: 0 0 .5rem;
    color: var(--color-muted);
    font-size: .78rem;
}
.debug-label {
    margin: 0 0 .25rem;
    font-weight: 600;
    color: var(--color-text);
}
.debug-sublabel {
    margin: .4rem 0 .2rem;
    font-size: .78rem;
    color: var(--color-muted);
}
.debug-table-wrap {
    overflow-x: auto;
}
.debug-table {
    border-collapse: collapse;
    font-size: .8rem;
    white-space: nowrap;
}
.debug-table th,
.debug-table td {
    padding: .2rem .5rem;
    border: 1px solid var(--color-border);
    text-align: center;
    color: var(--color-text);
}
.debug-table thead th {
    background: var(--color-card);
    font-weight: 600;
}

/* ── Debug options panel ─────────────────────────────── */
.debug-opts {
    margin-top: .5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    font-size: .82rem;
}
.debug-opts-summary {
    padding: .35rem .65rem;
    cursor: pointer;
    color: var(--color-muted);
    user-select: none;
    list-style: none;
}
.debug-opts-summary::-webkit-details-marker { display: none; }
.debug-opts-summary::before { content: '▶ '; font-size: .7rem; }
details[open] .debug-opts-summary::before { content: '▼ '; }
.debug-opts-body {
    padding: .5rem .65rem .6rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.debug-opts-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--color-text);
}

.site-footer a:hover { color: var(--color-text); text-decoration: underline; }

/* ── RvExplorer map layout ───────────────────────────── */
body.dash-page {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dash-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Header lives inside the sidebar on the RvExplorer page */
body.dash-page .site-header {
    position: relative;
    box-shadow: none;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
body.dash-page .site-header-inner {
    max-width: none;
    margin: 0;
    padding: 0 .9rem;
    height: 52px;
}
body.dash-page .site-nav {
    top: 52px;
    right: .9rem;
}
body.dash-page .dash-sidebar {
    overflow-y: hidden;
}
body.dash-page .dash-sidebar-inner {
    overflow-y: auto;
}

.dash-sidebar {
    width: 580px;
    min-width: 220px;
    flex-shrink: 0;
    background: var(--color-card);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-resize-handle {
    width: 5px;
    flex-shrink: 0;
    cursor: col-resize;
    background: var(--color-border);
    transition: background .12s;
    position: relative;
    z-index: 10;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.is-dragging {
    background: var(--color-primary);
}

.dash-sidebar-inner {
    padding: 1.1rem 1.25rem 1rem;
    flex: 1;
}

.dash-welcome-sm {
    font-size: .875rem;
    color: var(--color-muted);
    margin-bottom: .9rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--color-border);
}

.dash-map {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Map controls overlay */
.map-ctrl {
    position: absolute;
    top: 10px;
    left: 50px;
    z-index: 1000;
    display: flex;
    gap: .4rem;
    pointer-events: auto;
}

.map-ctrl-btn {
    background: var(--color-card);
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    padding: .38rem .75rem;
    font-size: .78rem;
    font-family: var(--font);
    cursor: pointer;
    color: var(--color-text);
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    font-weight: 500;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}

.map-ctrl-btn:hover { background: var(--color-bg); }

.map-ctrl-btn.is-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.map-ctrl-btn.mode-toggle::before {
    content: '';
    display: inline-block;
    width: 1.8em;
    height: 1em;
    border-radius: .5em;
    background-color: #aaa;
    background-image: radial-gradient(circle at .42em 50%, #fff 0, #fff .3em, transparent .3em);
    vertical-align: middle;
    margin-right: .4em;
}
.map-ctrl-btn.mode-toggle.is-active::before {
    background-color: rgba(255,255,255,.35);
    background-image: radial-gradient(circle at calc(100% - .42em) 50%, #fff 0, #fff .3em, transparent .3em);
}

/* Location search overlay — centred on the map */
.map-location-search {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    pointer-events: none;
    width: min(340px, 90%);
    transition: opacity .25s;
}
.map-location-search[hidden] { display: none; }
.map-location-search-inner {
    pointer-events: all;
    background: var(--color-card);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,.18);
    overflow: hidden;
}
#map-search-input {
    width: 100%;
    box-sizing: border-box;
    border: none;
    outline: none;
    padding: .6rem .85rem;
    font-size: .9rem;
    background: transparent;
    color: var(--color-text);
}
#map-search-input::placeholder { color: var(--color-muted); }
#map-search-results {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--color-border);
    max-height: 220px;
    overflow-y: auto;
}
#map-search-results[hidden] { display: none; }
#map-search-results li {
    padding: .5rem .85rem;
    font-size: .82rem;
    cursor: pointer;
    line-height: 1.35;
    color: var(--color-text);
}
#map-search-results li:hover,
#map-search-results li.is-active { background: var(--color-primary-light); }
#map-search-results li + li { border-top: 1px solid var(--color-border); }

/* Turbine marker */
.t-marker {
    width: 28px;
    height: 28px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.32);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    cursor: grab;
}

/* GPS reference marker */
.gps-marker {
    width: 14px;
    height: 14px;
    background: #f59e0b;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(245,158,11,.35), 0 2px 6px rgba(0,0,0,.25);
    cursor: grab;
}

.map-expand-handle { display: none; }

@media (max-width: 768px) {
    .dash-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .dash-sidebar {
        width: 100% !important;
        border-right: none;
        max-height: 65vh;
        overflow-y: auto;
        transition: max-height .3s ease;
    }
    /* Scroll the sidebar as a whole so the footer sits at the end of the
       content instead of staying pinned (desktop keeps the pinned footer) */
    body.dash-page .dash-sidebar { overflow-y: auto; }
    body.dash-page .dash-sidebar-inner { flex: none; overflow-y: visible; }
    .sidebar-resize-handle { display: none; }
    .map-expand-handle {
        display: block;
        height: 0;
        flex-shrink: 0;
        position: relative;
        overflow: visible;
        z-index: 1001;
    }
    .map-expand-btn {
        position: absolute;
        left: 50%;
        top: 0;
        transform: translate(-50%, -50%);
        background: var(--color-card);
        border: 1.5px solid var(--color-border);
        border-radius: 20px;
        cursor: pointer;
        color: var(--color-muted);
        font-size: .6rem;
        line-height: 1;
        padding: .25rem .75rem;
        letter-spacing: .1em;
        box-shadow: 0 1px 4px rgba(0,0,0,.15);
        white-space: nowrap;
        transition: color .15s, border-color .15s;
    }
    .map-expand-btn:hover {
        color: var(--color-primary);
        border-color: var(--color-primary);
    }
    .dash-map {
        height: 25vh;
        min-height: 180px;
        transition: height .3s ease;
    }
    .dash-map.map-expanded {
        height: 75vh;
    }
    .dash-layout.map-expanded .dash-sidebar {
        max-height: 25vh;
    }
}


/* ── Calculation progress modal ──────────────────────── */
.calc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}
.calc-modal-overlay[hidden] { display: none; }
.calc-modal-box {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    padding: 2rem 2.25rem;
    min-width: 280px;
    max-width: 360px;
    width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.calc-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}
.calc-modal-bar-track {
    width: 100%;
    height: 8px;
    background: var(--color-bg);
    border-radius: 99px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.calc-modal-bar {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: 99px;
    transition: width .25s ease;
}
.calc-modal-pct {
    font-size: .9rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}
.calc-modal-elapsed {
    font-size: .78rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}
.calc-modal-cancel {
    margin-top: .25rem;
}

/* ── Password requirements checklist ────────────────────── */
.pw-requirements {
    list-style: none;
    padding: 0;
    margin: .4rem 0 0;
    font-size: .8rem;
    color: var(--color-muted);
    line-height: 1.7;
}
.pw-requirements li::before { content: '\25CB\00A0'; }
.pw-requirements li.pw-req-met  { color: var(--color-success); }
.pw-requirements li.pw-req-met::before  { content: '\2713\00A0'; }

/* ── Leaflet zoom controls — dark mode ──────────────────── */
@media (prefers-color-scheme: dark) {
    #farm-map .leaflet-bar a {
        background-color: #1e293b;
        color: #f1f5f9;
        border-bottom-color: #334155;
    }
    #farm-map .leaflet-bar a:hover {
        background-color: #334155;
        color: #f1f5f9;
    }
    #farm-map .leaflet-bar {
        border: 1px solid #334155;
        box-shadow: 0 1px 5px rgba(0,0,0,.6);
    }
}
