:root {
    --bg: #f4f8fb;
    --panel: #ffffff;
    --ink: #11243a;
    --muted: #627489;
    --line: #d8e6ef;
    --accent: #0b7faa;
    --accent-strong: #075c82;
    --green: #15936b;
    --green-soft: #e9f8f2;
    --blue-soft: #eaf5fb;
    --warning: #a76000;
    --danger: #b42318;
    --soft-shadow: 0 10px 28px rgba(15, 58, 94, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
    overflow-x: hidden;
}

a {
    color: inherit;
}

.container {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-top: 3px solid var(--accent);
    border-bottom: 1px solid #c7ddeb;
    background: rgba(249, 253, 255, 0.96);
    backdrop-filter: blur(14px);
    box-shadow: 0 10px 28px rgba(14, 91, 122, 0.08);
}

.top-header__inner {
    width: min(1440px, calc(100% - 32px));
    min-height: 76px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr) minmax(180px, 1fr);
    gap: 18px;
    align-items: center;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    font-weight: 800;
    min-width: 0;
}

.brand-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    padding: 6px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(199, 221, 235, 0.9);
    box-shadow: 0 10px 22px rgba(16, 92, 126, 0.13);
}

.brand-name {
    font-size: 1.08rem;
    white-space: nowrap;
}

.brand-name__gis {
    color: #0c6f99;
}

.brand-name__it {
    color: #f16a21;
}

.tool-heading {
    text-align: center;
    min-width: 0;
}

.tool-heading h1 {
    margin: 0;
    font-size: clamp(1.18rem, 2vw, 1.52rem);
    color: var(--accent-strong);
    line-height: 1.1;
}

.tool-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.25;
}

.tools-menu {
    position: relative;
    justify-self: end;
}

.tools-menu__button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border: 1px solid #94c5dd;
    border-radius: 12px;
    background: #fff;
    color: #24364a;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(7, 92, 130, 0.08);
}

.tools-menu__button::-webkit-details-marker {
    display: none;
}

.tools-menu__grid {
    width: 15px;
    height: 15px;
    display: inline-grid;
    background: radial-gradient(circle, #375d7c 1.5px, transparent 1.7px) 0 0 / 6px 6px;
}

.tools-menu__chevron {
    transition: transform 160ms ease;
}

.tools-menu[open] .tools-menu__chevron {
    transform: rotate(180deg);
}

.tools-menu__list {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    min-width: 220px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--soft-shadow);
}

.tools-menu__list a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}

.tools-menu__list a:hover,
.tools-menu__list a:focus {
    background: rgba(11, 127, 170, 0.1);
    color: var(--accent-strong);
    outline: none;
}

.hero-section {
    padding: 52px 0 32px;
    background:
        linear-gradient(135deg, rgba(234, 245, 251, 0.95), rgba(255, 255, 255, 0.92)),
        linear-gradient(45deg, rgba(21, 147, 107, 0.08), rgba(11, 127, 170, 0.08));
    border-bottom: 1px solid var(--line);
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    gap: 28px;
    align-items: center;
}

.section-kicker {
    display: inline-flex;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-section h2 {
    margin: 12px 0 12px;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1;
}

.hero-subtitle {
    max-width: 760px;
    margin: 0;
    color: #334b63;
    font-size: clamp(1.08rem, 2vw, 1.28rem);
    line-height: 1.55;
}

.hero-instruction {
    max-width: 720px;
    margin: 14px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.hero-card {
    display: grid;
    gap: 9px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--soft-shadow);
}

.hero-card strong {
    color: var(--accent-strong);
    font-size: 1.05rem;
}

.hero-card span {
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--blue-soft);
    color: #25445d;
    font-weight: 700;
}

.tool-section {
    padding: 34px 0 44px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 18px;
}

.section-head h2 {
    margin: 6px 0 0;
    font-size: clamp(1.45rem, 3vw, 2.1rem);
    overflow-wrap: anywhere;
}

.section-head p {
    max-width: 440px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(320px, 0.58fr) minmax(0, 1.42fr);
    gap: 18px;
    align-items: stretch;
    min-width: 0;
}

.map-panel,
.panel-card,
.results-panel,
.content-card,
.faq-grid details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--soft-shadow);
}

.map-panel {
    height: 680px;
    min-height: 680px;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

.map-canvas {
    width: 100%;
    height: 680px;
    min-height: 680px;
}

.maplibregl-popup-content {
    border-radius: 8px;
    color: var(--ink);
    line-height: 1.45;
    box-shadow: 0 10px 28px rgba(15, 58, 94, 0.16);
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 680px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    scrollbar-color: #94c5dd #edf6fa;
    scrollbar-width: thin;
    min-width: 0;
    max-width: 100%;
}

.panel-card {
    padding: 20px;
    min-width: 0;
    max-width: 100%;
    flex: 0 0 auto;
}

.accordion-card {
    padding: 0;
}

.accordion-summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 14px 18px;
    color: #071b31;
    font-weight: 900;
    cursor: pointer;
    list-style: none;
}

.accordion-summary::-webkit-details-marker {
    display: none;
}

.accordion-summary::after {
    content: "⌄";
    margin-left: auto;
    color: var(--accent-strong);
    transition: transform 150ms ease;
}

.accordion-card[open] > .accordion-summary::after {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 0 18px 18px;
    min-width: 0;
}

.panel-card__header--compact {
    margin-bottom: 10px;
}

.accordion-card.is-disabled .accordion-body {
    opacity: 0.62;
}

.download-panel {
    display: grid;
    gap: 12px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--soft-shadow);
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    flex: 0 0 auto;
}

.download-panel.is-disabled {
    opacity: 1;
}

.download-panel.is-disabled .download-grid,
.download-panel.is-disabled .panel-card__header p {
    opacity: 0.72;
}

.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

.download-button {
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #94c5dd;
    border-radius: 8px;
    background: #f8fcfe;
    color: #075c82;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
    transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.download-button:hover,
.download-button:focus {
    border-color: var(--accent);
    background: var(--blue-soft);
    outline: none;
}

.download-button:disabled {
    color: #7a8ea2;
    cursor: not-allowed;
    background: #f4f8fb;
}

.download-button.is-loading {
    cursor: wait;
    opacity: 0.78;
}

.download-button--pdf,
.download-button--recommend {
    grid-column: 1 / -1;
}

.download-button--pdf {
    justify-content: flex-start;
    padding-left: 18px;
}

.download-button--recommend {
    background: #e9f8f2;
    border-color: rgba(21, 147, 107, 0.35);
    color: #0d694c;
    justify-content: flex-start;
}

.download-button span:last-child {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.file-icon {
    width: 32px;
    height: 26px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 32px;
    border-radius: 6px;
    background: #0b7faa;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.file-icon--pdf { background: #c03232; }
.file-icon--geojson { background: #0b7faa; }
.file-icon--gpkg { background: #5b63d6; }
.file-icon--shp { background: #15936b; }
.file-icon--best { background: #0d694c; }
.file-icon--csv { background: #a76000; }
.file-icon--grid { background: #2d6cdf; }
.file-icon--clear { background: #637083; }

.panel-card__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    min-width: 0;
}

.download-panel .panel-card__header {
    margin-bottom: 0;
}

.panel-card__header > div {
    min-width: 0;
}

.panel-card h3,
.placeholder-card h3,
.result-card h3 {
    margin: 0;
    color: #071b31;
}

.panel-card p,
.placeholder-card p,
.result-card p {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.status-message {
    margin: 14px 0;
    padding: 11px 12px;
    border-radius: 8px;
    background: var(--blue-soft);
    color: #164866;
    font-weight: 700;
    line-height: 1.4;
}

.status-message[data-state="warning"] {
    background: #fff5df;
    color: var(--warning);
}

.status-message[data-state="error"] {
    background: #ffebe9;
    color: var(--danger);
}

.status-message[data-state="success"] {
    background: var(--green-soft);
    color: #0d694c;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-field,
.field-grid label {
    display: grid;
    gap: 7px;
    margin-top: 12px;
}

.form-field--first {
    margin-top: 0;
}

.form-field span,
.field-grid span {
    color: var(--accent-strong);
    font-size: 0.77rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

input,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #bfd6e6;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input[readonly] {
    background: #f7fbfd;
    color: #33536c;
}

.button-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 16px;
}

.button-row--triple,
.comparison-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
    font: inherit;
}

.primary-button,
.secondary-button {
    min-height: 46px;
    padding: 11px 16px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.primary-button {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
}

.primary-button:hover,
.primary-button:focus {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    outline: none;
}

.primary-button[disabled] {
    opacity: 0.68;
    cursor: wait;
}

.secondary-button {
    border: 1px solid #a9c5d7;
    background: #fff;
    color: #244056;
}

.secondary-button:hover,
.secondary-button:focus {
    border-color: var(--accent);
    color: var(--accent-strong);
    outline: none;
}

.secondary-button--full {
    width: 100%;
    margin-top: 12px;
}

.secondary-button.is-ready {
    border-color: rgba(21, 147, 107, 0.55);
    background: var(--green-soft);
    color: #0d694c;
    box-shadow: 0 8px 18px rgba(21, 147, 107, 0.12);
}

.secondary-button:disabled,
.primary-button:disabled {
    cursor: not-allowed;
}

.primary-button:disabled {
    background: #8dbbd0;
    border-color: #8dbbd0;
}

.mode-badge,
.small-info {
    padding: 9px 10px;
    border-radius: 8px;
    background: #f5fafc;
    color: #29465c;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1.35;
}

.mode-badge {
    display: inline-flex;
    margin-bottom: 4px;
    border: 1px solid rgba(11, 127, 170, 0.14);
    color: var(--accent-strong);
}

.polygon-controls {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #d8e6ef;
    border-radius: 8px;
    background: #f8fcfe;
}

.polygon-controls p,
.advanced-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.advanced-panel {
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fcfe;
    padding: 12px;
}

.advanced-panel summary {
    color: var(--accent-strong);
    cursor: pointer;
    font-weight: 900;
}

.weights-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.weights-grid label {
    display: grid;
    gap: 6px;
}

.weights-grid span {
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.weight-warning {
    background: #fff5df;
    color: var(--warning);
}

.results-panel {
    padding: 0;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    flex: 0 0 auto;
}

.comparison-card {
    display: grid;
    gap: 12px;
}

.comparison-panel {
    min-width: 0;
}

.comparison-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.comparison-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.comparison-table th,
.comparison-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e4eef4;
    text-align: left;
    vertical-align: top;
}

.comparison-table th {
    position: sticky;
    top: 0;
    background: #eaf5fb;
    color: var(--accent-strong);
    font-weight: 900;
    z-index: 1;
}

.comparison-table tr:last-child td {
    border-bottom: 0;
}

.comparison-summary {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--green-soft);
    color: #0d694c;
    font-weight: 800;
}

.placeholder-card {
    padding: 18px;
    border: 1px dashed #b7d3e2;
    border-radius: 8px;
    background: #f8fcfe;
}

.skeleton-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.skeleton-line {
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, #eaf5fb, #f8fcfe, #eaf5fb);
    background-size: 200% 100%;
    animation: shimmer 1.2s linear infinite;
}

.skeleton-line:nth-child(2) { width: 72%; }
.skeleton-line:nth-child(3) { width: 48%; }

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

.results-grid {
    display: grid;
    gap: 12px;
}

.result-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.score-card {
    background: linear-gradient(135deg, #0b7faa, #15936b);
    color: #fff;
    border: 0;
}

.score-card h3,
.score-card p {
    color: #fff;
}

.score-value {
    display: block;
    margin-top: 8px;
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 900;
    line-height: 1;
}

.pill {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--green-soft);
    color: #0d694c;
    font-weight: 800;
}

.count-list,
.breakdown-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.count-row,
.breakdown-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    background: #f5fafc;
    color: #29465c;
    font-weight: 700;
    min-width: 0;
}

.count-row {
    border: 1px solid rgba(11, 127, 170, 0.12);
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.count-row:hover,
.count-row:focus-visible,
.count-row.is-active {
    border-color: rgba(7, 92, 130, 0.42);
    box-shadow: 0 8px 18px rgba(15, 58, 94, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.count-row__label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.count-row__swatch {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(16, 35, 59, 0.16);
}

.breakdown-bar {
    height: 8px;
    margin-top: 7px;
    border-radius: 999px;
    background: #dcecf4;
    overflow: hidden;
}

.breakdown-bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--green));
}

.muted-note {
    opacity: 0.92;
}

.recommendation-list {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.recommendation-list h4 {
    margin: 0 0 4px;
    color: var(--accent-strong);
    font-size: 0.88rem;
}

.recommendation-list ul {
    margin: 0;
    padding-left: 18px;
    color: #334b63;
    line-height: 1.5;
}

.score-help {
    display: inline-grid;
    width: 19px;
    height: 19px;
    margin-left: 6px;
    place-items: center;
    border-radius: 50%;
    background: #eaf5fb;
    color: var(--accent-strong);
    font-size: 0.75rem;
    font-weight: 900;
    cursor: help;
}

.map-legend {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 5;
    display: grid;
    gap: 8px;
    max-width: min(360px, calc(100% - 28px));
    padding: 12px;
    border: 1px solid rgba(199, 221, 235, 0.92);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 24px rgba(15, 58, 94, 0.12);
    color: #29465c;
    font-size: 0.78rem;
}

.map-legend strong {
    color: var(--accent-strong);
}

.legend-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 10px;
}

.legend-grid span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
}

.legend-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(16, 35, 59, 0.16);
}

.legend-dot--high { background: #15936b; }
.legend-dot--medium { background: #d4a017; }
.legend-dot--low { background: #c03232; }

.content-section {
    padding: 24px 0 44px;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.content-card {
    padding: 22px;
}

.content-card h2 {
    margin: 0 0 10px;
    color: var(--accent-strong);
    font-size: 1.26rem;
}

.content-card p {
    margin: 0 0 12px;
    color: #334b63;
    line-height: 1.62;
}

.content-card p:last-child {
    margin-bottom: 0;
}

.faq-section {
    padding: 10px 0 48px;
}

.faq-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.faq-grid details {
    padding: 16px 18px;
}

.faq-grid summary {
    color: #10233b;
    font-weight: 800;
    cursor: pointer;
}

.faq-grid p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.site-footer {
    border-top: 1px solid var(--line);
    background: #0f2638;
    color: #e6f2f7;
}

.footer-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-weight: 700;
}

@media (max-width: 980px) {
    .top-header__inner {
        grid-template-columns: 1fr auto;
        padding: 10px 0;
    }

    .tool-heading {
        grid-column: 1 / -1;
        grid-row: 2;
        text-align: left;
    }

    .hero-grid,
    .dashboard,
    .content-grid,
    .faq-grid {
        grid-template-columns: 1fr;
    }

    .section-head {
        display: block;
    }

    .section-head p {
        margin-top: 10px;
    }

    .map-panel,
    .map-canvas {
        height: 480px;
        min-height: 480px;
    }

    .control-panel {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }
}

@media (max-width: 620px) {
    .container,
    .top-header__inner {
        width: min(100% - 24px, 1240px);
    }

    .brand-name {
        font-size: 0.98rem;
    }

    .brand-logo {
        width: 40px;
        height: 40px;
    }

    .tools-menu__button {
        padding: 8px 11px;
    }

    .hero-section {
        padding-top: 34px;
    }

    .hero-card {
        padding: 16px;
    }

    .field-grid,
    .button-row {
        grid-template-columns: 1fr;
    }

    .button-row--triple,
    .comparison-actions,
    .weights-grid {
        grid-template-columns: 1fr;
    }

    .map-panel,
    .map-canvas {
        height: 400px;
        min-height: 400px;
    }

    .map-panel {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .panel-card,
    .results-panel,
    .content-card {
        padding: 16px;
    }

    .footer-inner {
        min-height: 90px;
        display: grid;
        align-content: center;
    }

    .download-grid {
        grid-template-columns: 1fr;
    }

    .download-button--pdf,
    .download-button--recommend {
        grid-column: auto;
    }

    .map-legend {
        position: static;
        margin: 10px;
        max-width: none;
    }
}
