:root {
    --mw-blue: #29ade3;
    --mw-blue-dark: #078dca;
    --mw-navy: #07324b;
    --mw-ink: #102b3a;
    --mw-muted: #667b87;
    --mw-surface: #ffffff;
    --mw-bg: #f3f8fb;
    --mw-line: #dce8ee;
    --mw-green: #18a06c;
    --mw-amber: #b56a00;
    --bs-primary: #078dca;
    --bs-primary-rgb: 7, 141, 202;
    --bs-body-color: var(--mw-ink);
    --bs-body-font-family: "Onest", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    background: var(--mw-bg);
    color: var(--mw-ink);
    font-size: 1rem;
}

.app-body {
    display: flex;
    flex-direction: column;
    background-image: linear-gradient(rgba(7, 50, 75, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(7, 50, 75, .025) 1px, transparent 1px);
    background-size: 32px 32px;
}

.app-body > main,
.login-body > main { flex: 1; width: 100%; }

a { color: var(--mw-blue-dark); }

.btn {
    --bs-btn-border-radius: .75rem;
    font-weight: 700;
}

.btn-primary {
    --bs-btn-bg: var(--mw-blue-dark);
    --bs-btn-border-color: var(--mw-blue-dark);
    --bs-btn-hover-bg: #067ab0;
    --bs-btn-hover-border-color: #067ab0;
    --bs-btn-active-bg: #056e9f;
    --bs-btn-active-border-color: #056e9f;
    box-shadow: 0 .5rem 1.25rem rgba(7, 141, 202, .18);
}

.topbar {
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--mw-line);
    backdrop-filter: blur(14px);
}

.brand-lockup,
.login-brand {
    display: inline-flex;
    align-items: center;
    gap: .85rem;
    text-decoration: none;
}

.brand-lockup img,
.login-brand img {
    width: min(178px, 34vw);
    height: auto;
}

.brand-divider {
    width: 1px;
    height: 28px;
    background: var(--mw-line);
}

.brand-parks {
    color: var(--mw-navy);
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.btn-scada {
    color: var(--mw-navy);
    background: #eaf8fd;
    border: 1px solid #c5eaf8;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.btn-scada:hover { color: white; background: var(--mw-navy); border-color: var(--mw-navy); }

.btn-icon {
    width: 42px;
    height: 42px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    color: var(--mw-navy);
    background: white;
    border: 1px solid var(--mw-line);
}

.btn-icon:hover { color: white; background: var(--mw-navy); border-color: var(--mw-navy); }

.account-role-icon { width: 32px; height: 32px; display: inline-grid; place-items: center; color: var(--mw-muted); font-size: 1rem; }

.page-space { padding-top: clamp(2.25rem, 5vw, 4.75rem); padding-bottom: 4.5rem; }

.dashboard-heading { margin-bottom: 2rem; }
.dashboard-heading h1,
.detail-title h1,
.form-card-heading h1 {
    color: var(--mw-navy);
    font-size: clamp(2rem, 4.2vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -.045em;
    line-height: 1.03;
    margin: .5rem 0 .7rem;
}

.dashboard-heading p,
.detail-title p,
.form-card-heading p,
.login-heading p {
    color: var(--mw-muted);
    font-size: 1.05rem;
    margin: 0;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--mw-blue-dark);
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.park-count {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding: .65rem .8rem;
    background: white;
    border: 1px solid var(--mw-line);
    border-radius: 1rem;
    box-shadow: 0 .7rem 2rem rgba(14, 60, 82, .06);
}

.park-count strong { color: var(--mw-blue-dark); font-size: 1.65rem; line-height: 1; }
.park-count span { color: var(--mw-muted); font-size: .7rem; font-weight: 700; line-height: 1.1; text-transform: uppercase; letter-spacing: .035em; }
.dashboard-tools { display: flex; align-items: stretch; gap: .65rem; }
.sort-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .1rem .25rem; min-width: 0; padding: .4rem .5rem; background: white; border: 1px solid var(--mw-line); border-radius: 1rem; box-shadow: 0 .7rem 2rem rgba(14, 60, 82, .06); }
.sort-control label { grid-column: 1 / -1; color: var(--mw-muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sort-control .form-select { min-width: 0; border: 0; padding-left: 0; font-size: .82rem; font-weight: 700; }
.sort-control .form-select:focus { box-shadow: none; }
.btn-sort { width: 34px; height: 34px; padding: 0; color: var(--mw-blue-dark); background: #eaf8fd; border: 0; }

.park-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--mw-surface);
    border: 1px solid var(--mw-line);
    border-radius: 1.15rem;
    box-shadow: 0 .75rem 2.25rem rgba(14, 60, 82, .06);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.park-card:hover { transform: translateY(-3px); border-color: #a6ddf3; box-shadow: 0 1.1rem 2.7rem rgba(14, 60, 82, .1); }
.card-accent { position: absolute; inset: 0 0 auto; height: 4px; background: linear-gradient(90deg, var(--mw-blue), #8bd6f4); }
.park-card-body { padding: .85rem 1.1rem .65rem; flex: 1; }
.park-number { color: #9aabb4; font-size: .8rem; font-weight: 800; letter-spacing: .12em; }
.protocol-badge { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .4rem; border-radius: 999px; font-size: .64rem; font-weight: 700; letter-spacing: .035em; }
.protocol-badge.secure { color: #3b8068; background: #eff9f5; }
.protocol-badge.attention { color: #987544; background: #fff7e9; }
.park-identity { display: flex; align-items: flex-start; gap: .75rem; margin-top: .6rem; }
.park-copy { min-width: 0; }
.park-icon { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; margin: 0; color: var(--mw-blue-dark); background: #eaf8fd; border-radius: .7rem; font-size: 1rem; }
.park-card h2 { margin: 0 0 .55rem; font-size: 1.26rem; font-weight: 800; letter-spacing: -.02em; }
.park-card h2 a { color: var(--mw-navy); text-decoration: none; }
.park-card h2 a:hover { color: var(--mw-blue-dark); }
.endpoint,
.park-meta { display: flex; align-items: center; gap: .45rem; color: var(--mw-muted); font-size: .9rem; margin: 0; }
.park-meta { margin-top: .45rem; }
.park-card-footer { display: flex; align-items: center; gap: .7rem; padding: .6rem 1.1rem .7rem; border-top: 1px solid #edf3f6; }
.card-actions { display: flex; align-items: center; gap: .4rem; }
.card-edit { display: grid; place-items: center; width: 29px; height: 29px; color: var(--mw-muted); border: 1px solid var(--mw-line); border-radius: .55rem; text-decoration: none; }
.card-edit:hover { color: white; background: var(--mw-blue-dark); border-color: var(--mw-blue-dark); }
.btn-open { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; color: var(--mw-navy); background: #eaf8fd; border: 1px solid #c8ebf8; }
.btn-open:hover { color: white; background: var(--mw-blue-dark); border-color: var(--mw-blue-dark); }
.details-link { font-size: .9rem; font-weight: 700; text-decoration: none; }

.back-link { display: inline-flex; align-items: center; gap: .45rem; margin-bottom: 1.5rem; color: var(--mw-muted); font-weight: 700; text-decoration: none; }
.back-link:hover { color: var(--mw-blue-dark); }
.detail-hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: clamp(1.5rem, 4vw, 3rem); background: linear-gradient(135deg, white 0%, #edf9fd 100%); border: 1px solid var(--mw-line); border-radius: 1.35rem; box-shadow: 0 1rem 3rem rgba(14, 60, 82, .07); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 1.25rem; margin-top: 1.25rem; }
.detail-panel { padding: clamp(1.3rem, 3vw, 2rem); background: white; border: 1px solid var(--mw-line); border-radius: 1.15rem; }
.detail-panel h2 { color: var(--mw-navy); font-size: 1.1rem; font-weight: 800; margin: 0 0 1.2rem; }
.detail-panel dl { margin: 0; }
.detail-panel dl > div { display: grid; grid-template-columns: 145px 1fr; gap: 1rem; padding: .9rem 0; border-top: 1px solid #edf3f6; }
.detail-panel dt { color: var(--mw-muted); font-weight: 600; }
.detail-panel dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.detail-panel code { color: var(--mw-navy); font-size: .88rem; }
.detail-note { background: var(--mw-navy); color: white; border-color: var(--mw-navy); }
.detail-note h2 { color: white; }
.detail-note p { color: #d6e5ec; margin: 0; line-height: 1.7; }
.detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }
.narrow-page { max-width: 860px; }
.form-card { position: relative; padding: clamp(1.4rem, 4vw, 3rem); background: white; border: 1px solid var(--mw-line); border-radius: 1.25rem; box-shadow: 0 1rem 3rem rgba(14, 60, 82, .07); }
.edit-delete-trigger { position: absolute; top: 1rem; right: 1rem; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; color: #a7868a; background: transparent; border: 0; border-radius: 50%; }
.edit-delete-trigger:hover,
.edit-delete-trigger:focus-visible { color: #b42332; background: #fff0f1; }
.form-card-heading { margin-bottom: 2rem; }
.form-label { color: var(--mw-navy); font-weight: 750; }
.form-control,
.input-group-text { border-color: #cddde5; border-radius: .75rem; }
.form-control:focus { border-color: var(--mw-blue); box-shadow: 0 0 0 .25rem rgba(41, 173, 227, .15); }
.form-control-lg { font-size: 1rem; min-height: 3.1rem; }

.login-body { display: flex; flex-direction: column; background: var(--mw-navy); background-image: radial-gradient(circle at 15% 20%, rgba(41, 173, 227, .28), transparent 34%), linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px); background-size: auto, 36px 36px, 36px 36px; }
.login-shell { display: grid; place-items: center; padding: 2rem 1rem; }
.login-panel { width: min(100%, 470px); padding: clamp(1.5rem, 5vw, 2.5rem); background: white; border: 1px solid rgba(255, 255, 255, .5); border-radius: 1.35rem; box-shadow: 0 2rem 5rem rgba(0, 15, 25, .3); }
.login-brand { margin-bottom: 2.6rem; }
.login-heading h1 { color: var(--mw-navy); margin: .55rem 0 .65rem; font-size: clamp(1.45rem, 4vw, 1.85rem); font-weight: 800; letter-spacing: -.035em; }
.login-heading { margin-bottom: 1.5rem; }
.input-group-text { color: var(--mw-blue-dark); background: #eff9fd; }
.input-group > .form-control { border-left: 0; }
.login-panel .form-control::placeholder { color: #aebbc4; opacity: 1; }
.remember-check { color: var(--mw-muted); font-size: .9rem; }
.remember-check .form-check-input:checked { background-color: var(--mw-blue); border-color: var(--mw-blue); }
.turnstile-wrap { display: flex; align-items: center; justify-content: center; }
.security-note { color: var(--mw-muted); text-align: center; font-size: .8rem; margin: 1.25rem 0 0; }
.empty-state { padding: clamp(3rem, 8vw, 6rem) 1rem; background: white; border: 1px solid var(--mw-line); border-radius: 1.25rem; }
.empty-state > i { color: var(--mw-blue); font-size: 2.5rem; }
.empty-state h1,
.empty-state h2 { color: var(--mw-navy); font-weight: 800; margin: 1rem 0 .6rem; }
.empty-state p { color: var(--mw-muted); }
.error-code { color: var(--mw-blue); font-size: clamp(3rem, 10vw, 7rem); font-weight: 900; letter-spacing: -.08em; }

.site-footer { padding: 1rem 0 1.25rem; color: var(--mw-muted); font-size: .75rem; text-align: center; }
.login-body .site-footer { color: #aac0cb; }
.flash-toast { position: fixed; z-index: 1080; right: 1rem; bottom: 1rem; display: flex; align-items: center; gap: .55rem; width: min(390px, calc(100vw - 2rem)); margin: 0; padding: .8rem 1rem; border-radius: .85rem; font-weight: 650; animation: toast-life 5.5s ease forwards; }
@keyframes toast-life { 0%, 82% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(10px); visibility: hidden; } }
.backup-page { max-width: 1040px; }
.backup-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.backup-heading h1 { color: var(--mw-navy); font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; letter-spacing: -.045em; margin: .5rem 0 .65rem; }
.backup-heading p { max-width: 700px; color: var(--mw-muted); margin: 0; }
.backup-list { display: grid; gap: .75rem; }
.backup-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.1rem; background: white; border: 1px solid var(--mw-line); border-radius: 1rem; }
.backup-icon { display: grid; place-items: center; width: 42px; height: 42px; color: var(--mw-blue-dark); background: #eaf8fd; border-radius: .75rem; }
.backup-info h2 { color: var(--mw-navy); font-size: 1rem; font-weight: 800; margin: 0; }
.backup-info p { color: var(--mw-muted); font-size: .82rem; margin: .2rem 0; }
.backup-info code { color: var(--mw-muted); font-size: .75rem; }
.backup-type { padding: .2rem .45rem; color: #08764e; background: #e6f7f0; border-radius: 999px; font-size: .66rem; font-weight: 800; text-transform: uppercase; }
.backup-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; }
.backup-actions form { margin: 0; }
.delete-backup { position: relative; }
.delete-backup summary { list-style: none; cursor: pointer; }
.delete-backup summary::-webkit-details-marker { display: none; }
.delete-backup[open] form { position: absolute; z-index: 5; top: calc(100% + .45rem); right: 0; width: 230px; padding: .85rem; background: white; border: 1px solid #f0b7bd; border-radius: .75rem; box-shadow: 0 1rem 2.5rem rgba(14, 60, 82, .18); }
.delete-backup[open] p { color: var(--mw-ink); font-size: .82rem; margin: 0 0 .65rem; }
.delete-park-page { max-width: 700px; }
.delete-park-panel { margin-top: 1.25rem; padding: clamp(1.4rem, 4vw, 2.25rem); background: white; border: 1px solid #f0c9cd; border-radius: 1.15rem; box-shadow: var(--mw-shadow); }
.delete-park-panel h1 { color: var(--mw-navy); font-size: clamp(1.55rem, 4vw, 2.15rem); font-weight: 800; margin: .85rem 0 .65rem; }
.delete-park-panel > p { color: var(--mw-muted); margin-bottom: 1.4rem; }
.delete-warning-icon { display: grid; place-items: center; width: 42px; height: 42px; color: #b42332; background: #fff0f1; border-radius: 50%; font-size: 1.15rem; }

@media (max-width: 767.98px) {
    .topbar .container-xl { padding-inline: .85rem; }
    .brand-lockup { gap: .55rem; }
    .brand-lockup img { width: 128px; }
    .brand-divider { height: 22px; }
    .brand-parks { font-size: 1rem; }
    .dashboard-heading { align-items: stretch; }
    .dashboard-tools { flex-direction: row; width: 100%; gap: .45rem; }
    .park-count { flex: .82; }
    .sort-control { flex: 1.18; }
    .detail-hero { align-items: stretch; flex-direction: column; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-panel dl > div { grid-template-columns: 1fr; gap: .3rem; }
    .backup-heading { align-items: stretch; flex-direction: column; }
    .backup-item { grid-template-columns: auto 1fr; }
    .backup-actions { grid-column: 1 / -1; justify-content: stretch; flex-wrap: wrap; }
    .backup-actions .btn { flex: 1; }
}

@media (max-width: 390px) {
    .brand-lockup .brand-divider,
    .brand-lockup .brand-parks { display: none; }
    .park-card-footer { align-items: stretch; flex-direction: column; }
    .details-link { text-align: center; padding: .35rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
    .flash-toast { animation-duration: 8s; transform: none; }
}
