:root {
  --wine: #5b1322;
  --wine-dark: #390914;
  --gold: #b79750;
  --paper: #f7f2e8;
  --ink: #251b19;
  --muted: #756a63;
  --line: #d9ccb4;
  --r10: #8b1d3a;
  --r11: #bd6b35;
  --r12: #665690;
  --r13: #9b7b2f;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: Inter, "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
button, .file-button { min-height: 44px; border: 1px solid var(--wine); border-radius: 12px 4px 12px 4px; padding: .72rem 1rem; cursor: pointer; }
button { background: white; color: var(--wine); font-weight: 750; }
button:hover, button:focus-visible, .file-button:hover, .file-button:focus-within { outline: 3px solid #b7975044; outline-offset: 2px; }
.primary, .search-box button { background: var(--wine); color: white; }
.quiet { border-color: #ffffff88; background: transparent; color: inherit; }
.danger-link { border: 0; color: #8a273a; background: transparent; text-decoration: underline; }
.topbar { min-height: 82px; padding: .8rem clamp(1rem, 3vw, 2.4rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: white; background: linear-gradient(120deg, var(--wine-dark), var(--wine) 64%, #7c2335); border-bottom: 4px solid var(--gold); }
.brand { display: flex; align-items: center; gap: .85rem; }
.version-badge { align-self: flex-start; margin-left: .15rem; padding: .23rem .5rem; border: 1px solid #e3d3aa88; border-radius: 8px 3px 8px 3px; color: #f5ead1; background: #2f071180; font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.brand p, .brand h1 { margin: 0; }
.brand p { color: #e3d3aa; font-size: .72rem; letter-spacing: .14em; font-weight: 800; }
.brand h1 { font-family: Georgia, serif; font-size: clamp(1.4rem, 4vw, 2rem); }
.monogram { width: 54px; aspect-ratio: 1; display: grid; place-items: center; border: 2px solid var(--gold); border-radius: 14px 4px 14px 4px; color: #ead9ad; font: 700 2rem Georgia, serif; box-shadow: inset 0 0 0 3px #5b1322, inset 0 0 0 4px #b7975070; }
.monogram small { font-size: .48em; align-self: end; margin: 0 0 8px -13px; }
main { padding: clamp(.8rem, 2vw, 1.5rem); }
.empty-state { max-width: 650px; margin: clamp(2rem, 8vh, 6rem) auto; padding: clamp(1.5rem, 5vw, 3rem); text-align: center; background: #fffdf8; border: 1px solid var(--gold); border-radius: 28px 8px 28px 8px; box-shadow: 0 18px 50px #3b1b1520; }
.file-mark { font-size: 4rem; line-height: 1; color: var(--gold); transform: rotate(180deg); }
.empty-state h2 { margin: .35rem 0 .8rem; font: 700 clamp(1.8rem, 6vw, 2.7rem) Georgia, serif; color: var(--wine); }
.empty-state > p:not(.eyebrow):not(.status) { max-width: 50ch; margin: 0 auto 1.5rem; line-height: 1.6; color: var(--muted); }
.package-form { max-width: 430px; margin: 1.2rem auto; display: grid; gap: .8rem; padding: 1rem; text-align: left; background: #f8f2e7; border: 1px solid var(--line); border-radius: 16px 5px 16px 5px; }
.package-form button { width: 100%; }
.file-fallback { max-width: 430px; margin: .8rem auto 0; color: var(--muted); font-size: .8rem; }
.file-fallback summary { cursor: pointer; font-weight: 750; }
.file-fallback .file-button { margin-top: .7rem; background: white; color: var(--wine); }
.file-button { display: inline-flex; align-items: center; justify-content: center; background: var(--wine); color: white; font-weight: 800; }
.file-button.small { min-height: 42px; padding: .55rem .75rem; background: white; color: var(--wine); }
.status { min-height: 1.3rem; margin: 1rem 0 0; color: var(--muted); }
.status.error { color: #9c1c2d; font-weight: 700; }
.viewer { max-width: 1500px; margin: 0 auto; }
.toolbar { display: grid; grid-template-columns: minmax(260px, 1.1fr) minmax(380px, 1.6fr) auto; gap: .8rem; align-items: end; padding: 1rem; background: #fffdf8; border: 1px solid var(--line); border-radius: 18px 5px 18px 5px; box-shadow: 0 7px 25px #3b1b1512; }
label { display: grid; gap: .3rem; color: #5f514a; font-size: .78rem; font-weight: 800; }
input, select { width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid #cfc2ad; border-radius: 9px 3px 9px 3px; background: white; color: var(--ink); }
.search-box > div { display: grid; grid-template-columns: 1fr auto; gap: .45rem; }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: end; gap: .45rem; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(90px, 150px)) 1fr; gap: .65rem; align-items: stretch; padding: .8rem 0; }
.summary > div, .summary > p { margin: 0; padding: .65rem .8rem; background: #efe7d8; border-left: 3px solid var(--gold); }
.summary b { display: block; color: var(--wine); font: 700 1.45rem Georgia, serif; }
.summary span, .summary p { color: var(--muted); font-size: .78rem; }
.summary p { display: flex; align-items: center; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: .9rem; }
.map-shell { position: relative; min-height: min(72vh, 780px); overflow: hidden; background: #e9e2d6; border: 1px solid var(--gold); border-radius: 24px 7px 24px 7px; }
#map { position: absolute; inset: 0; }
.map-key { position: absolute; z-index: 500; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: .45rem; padding: .5rem .65rem; background: #fffdf8e8; border: 1px solid #d8c7a6; border-radius: 10px 3px 10px 3px; backdrop-filter: blur(8px); }
.map-key span { display: flex; align-items: center; gap: .28rem; color: #4d403a; font-size: .72rem; font-weight: 800; }
.map-key i { width: 13px; height: 13px; border-radius: 50%; }
.r10 { background: var(--r10); }.r11 { background: var(--r11); }.r12 { background: var(--r12); }.r13 { background: var(--r13); }
.detail-card { align-self: start; min-height: 260px; padding: 1.2rem; background: #fffdf8; border: 1px solid var(--line); border-top: 5px solid var(--wine); border-radius: 5px 5px 20px 5px; box-shadow: 0 9px 25px #3b1b1516; }
.eyebrow { margin: 0; color: #9d7e40; font-size: .72rem; letter-spacing: .16em; font-weight: 900; }
.detail-card h2 { margin: .35rem 0 1rem; color: var(--wine); font: 700 1.6rem Georgia, serif; }
.detail-card dl { display: grid; grid-template-columns: auto 1fr; gap: .5rem .8rem; }
.detail-card dt { color: var(--muted); font-size: .78rem; font-weight: 800; }
.detail-card dd { margin: 0; font-weight: 750; }
.detail-card button { width: 100%; margin-top: 1rem; }
.area-label { color: #2c1a1d; font-weight: 800; text-shadow: 0 1px 2px white, 0 -1px 2px white; background: transparent; border: 0; box-shadow: none; }
.leaflet-tooltip.area-label::before { display: none; }
footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem, 3vw, 2.4rem); background: var(--wine-dark); color: #e7ddd0; font-size: .78rem; }
@media (max-width: 980px) {
  .toolbar { grid-template-columns: 1fr; }
  .actions { justify-content: start; }
  .map-layout { grid-template-columns: 1fr; }
  .detail-card { min-height: 0; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .topbar .quiet { font-size: .72rem; padding: .5rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:last-child { grid-column: 1 / -1; }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .summary > p { grid-column: 1 / -1; }
  .map-shell { min-height: 60vh; border-radius: 15px 4px 15px 4px; }
  footer { flex-direction: column; }
}
