:root {
  --wine: #64243d;
  --wine-dark: #451729;
  --wine-soft: #f1e6e9;
  --cream: #f4f0e8;
  --paper: #fffdf9;
  --ink: #272420;
  --muted: #746f67;
  --line: #ddd6ca;
  --green: #4d6a45;
  --green-soft: #e9efe3;
  --gold: #b78638;
  --orange: #b45e2c;
  --red: #a94145;
  --shadow: 0 16px 42px rgba(65, 45, 32, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
html { background: var(--cream); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 9999; padding: 10px 16px; background: white; color: var(--wine); }
.skip-link:focus { top: 12px; }

body.auth-pending .shell, body.auth-pending .mobile-nav,
body.auth-locked .shell, body.auth-locked .mobile-nav,
body.auth-pending .skip-link, body.auth-locked .skip-link { display: none; }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% 15%, rgba(180,134,56,.16), transparent 28%), linear-gradient(145deg, #35101f, #64243d 58%, #421428); }
.login-card { width: min(100%, 430px); display: grid; gap: 26px; padding: 34px; border: 1px solid rgba(255,255,255,.3); border-radius: 24px; background: var(--paper); box-shadow: 0 28px 70px rgba(18,4,10,.35); }
.login-brand { display: grid; justify-items: center; gap: 4px; text-align: center; }
.login-brand img { object-fit: contain; }
.login-brand div { display: grid; }
.login-brand span { margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.login-copy h1 { margin: 5px 0 7px; font-family: Georgia, serif; font-size: 34px; }
.login-copy p:last-child { margin: 0; color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 15px; }
.login-form .field { margin: 0; }
.login-form .button { width: 100%; min-height: 50px; margin-top: 2px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 246px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 246px; display: flex; flex-direction: column; padding: 28px 20px; color: #fff; background: linear-gradient(165deg, #572037 0%, #3b1325 100%); }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0 8px 27px; text-align: center; }
.brand img { object-fit: contain; }
.brand div { display: grid; justify-items: center; }
.brand span { color: #d6bdc7; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.nav-list { display: grid; gap: 8px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 15px; border: 0; border-radius: 12px; color: #ddcbd2; background: transparent; text-align: left; font-weight: 650; }
.nav-item span { width: 22px; font-size: 21px; text-align: center; }
.nav-item:hover, .nav-item.is-active { color: #fff; background: rgba(255,255,255,.12); }
.sidebar .eyebrow { color: #ccb2bc; }

.main { grid-column: 2; min-width: 0; padding: 0 42px 52px; }
.topbar { height: 116px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 3px 0 0; font-family: Georgia, serif; font-size: clamp(26px, 3vw, 38px); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mobile-app-brand { display: none; }
.eyebrow { margin: 0; color: var(--wine); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.status-pill { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.58); color: var(--muted); font-size: 12px; font-weight: 700; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.status-pill.is-online i { background: #5e884e; box-shadow: 0 0 0 4px rgba(94,136,78,.13); }
.status-pill.is-offline i { background: var(--red); }

#app { max-width: 1450px; margin: 0 auto; }
.page-stack { display: grid; gap: 22px; }
.hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); min-height: 272px; border-radius: 26px; background: #21382b; color: #fff; box-shadow: var(--shadow); }
.hero::before { content: ""; position: absolute; inset: 0; opacity: .36; background: radial-gradient(circle at 85% 30%, #8aa66d 0, transparent 32%), repeating-linear-gradient(118deg, transparent 0 38px, rgba(255,255,255,.07) 39px 42px); }
.hero-copy { position: relative; z-index: 1; align-self: center; padding: 38px 42px; }
.hero-copy .eyebrow { color: #c3d5b4; }
.hero h2 { max-width: 650px; margin: 10px 0 14px; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 48px); font-weight: 500; line-height: 1.06; }
.hero p { max-width: 590px; margin: 0 0 24px; color: #d8e2d3; line-height: 1.55; }
.hero-map { position: relative; min-height: 272px; background: #304a38; }
.hero-map::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 30px 0 40px -32px #16271d; }
.hero-cover-photo { overflow: hidden; }
.hero-cover-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.stat-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,253,249,.8); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card strong { display: block; margin-top: 7px; font-family: Georgia, serif; font-size: 28px; font-weight: 600; }
.stat-card small { display: block; margin-top: 3px; color: var(--muted); }
.report-action-card { display: grid; align-content: center; gap: 8px; }
.report-action-card .button { width: 100%; min-height: 42px; }

.section-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.section-row h2, .panel h2 { margin: 4px 0 0; font-family: Georgia, serif; font-size: 25px; font-weight: 600; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 8px 28px rgba(65,45,32,.04); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 24px; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); gap: 20px; align-items: start; }
.list { display: grid; gap: 12px; }
.parcel-card, .visit-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.parcel-card { display: block; }
.parcel-card:hover { border-color: #bcae9c; }
.parcel-summary { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: center; cursor: pointer; }
.parcel-summary > .card-actions { justify-content: flex-start; }
.parcel-title-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.parcel-expand-button { flex: 0 0 36px; width: 36px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--wine); background: #fff; }
.parcel-chevron { flex: 0 0 auto; color: var(--muted); font-size: 20px; line-height: 1; transition: transform .2s; }
.parcel-card.is-expanded .parcel-chevron { transform: rotate(180deg); }
.parcel-information { margin-top: 15px; padding-top: 15px; border-top: 1px solid #eee8df; }
.parcel-information[hidden] { display: none; }
.parcel-meta { margin: 0 !important; }
.parcel-main { display: flex; gap: 14px; align-items: center; min-width: 0; }
.parcel-main > div:last-child, .parcel-information { min-width: 0; }
.parcel-icon { flex: 0 0 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--green-soft); color: var(--green); font-size: 24px; }
.parcel-card h3, .visit-card h3 { margin: 0; overflow-wrap: anywhere; font-size: 16px; }
.parcel-card p, .visit-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.visit-actions { display: grid; justify-items: end; gap: 8px; }
.visit-actions > strong { font-family: Georgia, serif; font-size: 18px; }
.visit-actions > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.compact-visit-list { gap: 7px; }
.compact-visit-list .visit-card { gap: 12px; padding: 12px 15px; border-radius: 11px; }
.compact-visit-list .visit-card p { margin-top: 3px; }
.home-recent .compact-visit-list { padding: 7px; }
.home-recent-list > .visit-card > strong { font-family: Georgia, serif; font-size: 18px; }
.summary-panel-header { align-items: end; }
.summary-search { width: min(310px, 38vw); }
.summary-search input { min-height: 40px; }
.parcel-search-header { justify-content: flex-start; padding-block: 14px; }
.parcel-search { width: min(390px, 100%); }
.parcel-search input { min-height: 40px; }
.parcel-result { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.parcel-result div { padding: 10px 12px; border-radius: 10px; background: #f5f2ec; }
.parcel-result span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.parcel-result strong { display: block; margin-top: 3px; font-size: 14px; }
.sigpac-info { display: grid; gap: 4px; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid #eee8df; font-size: 11px; line-height: 1.45; }
.sigpac-info span { overflow-wrap: anywhere; color: var(--muted); }
.sigpac-info small { color: var(--muted); }
.sigpac-info details { margin-top: 4px; }
.sigpac-info summary { cursor: pointer; color: var(--wine); font-weight: 750; }
.sigpac-recintos { max-height: 230px; display: grid; gap: 5px; margin-top: 9px; padding: 9px; overflow: auto; border-radius: 9px; background: #f6f3ed; }
.sigpac-recintos div { display: flex; justify-content: space-between; gap: 12px; }
.sigpac-recintos code { color: var(--ink); font-size: 11px; }
.parcel-fields { display: grid; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid #eee8df; }
.parcel-fields-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.parcel-fields-title span { color: var(--muted); font-size: 11px; }
.parcel-fields dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; overflow: hidden; border: 1px solid #ebe5dc; border-radius: 10px; background: #ebe5dc; }
.parcel-fields dl > div { min-width: 0; padding: 9px 11px; background: #faf8f4; }
.parcel-fields dt { color: var(--muted); font-size: 10px; font-weight: 750; overflow-wrap: anywhere; }
.parcel-fields dt small { color: var(--wine); }
.parcel-fields dd { margin: 3px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.add-field-row { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(150px, 1.2fr) auto; gap: 8px; align-items: end; }
.add-field-row .field { gap: 4px; }
.add-field-row .field input { min-height: 36px; padding: 7px 9px; font-size: 12px; }
.import-preview { display: grid; gap: 1px; margin-top: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--line); }
.import-preview > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 13px; background: #fff; font-size: 12px; }
.import-preview span, .import-preview p { color: var(--muted); }
.import-preview p { margin: 0; padding: 11px 13px; background: #faf8f4; font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 11px; font-weight: 750; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button.primary { color: #fff; background: var(--wine); }
.button.primary:hover { background: var(--wine-dark); }
.button.secondary { color: var(--wine); border-color: #cbb3bd; background: var(--wine-soft); }
.button.ghost { color: var(--ink); border-color: var(--line); background: transparent; }
.button.danger { color: var(--red); border-color: #e4c7c7; background: #fff7f7; }
.button.compact { min-height: 36px; padding: 7px 12px; border-radius: 9px; font-size: 12px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 28px; }

.map { width: 100%; min-height: 340px; z-index: 0; background: #dde4d7; }
.map-large { min-height: 470px; border-radius: 0 0 var(--radius) var(--radius); }
.zones-review-layout { align-items: stretch; }
.zones-map-column { min-height: 470px; }
.zones-review-layout .map-large { height: 100%; }
.map-card { min-height: 360px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.map-dialog { min-height: 390px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.map-select, .map-select.leaflet-grab, .map-select .leaflet-interactive { cursor: crosshair !important; }
.leaflet-control-attribution { font-size: 9px !important; }
.map-location-control button { position: relative; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; color: #245f9d; background: #fff; font-size: 19px; font-weight: 800; }
.map-location-control button span { position: absolute; right: 5px; bottom: 5px; width: 7px; height: 7px; border: 1px solid #fff; border-radius: 50%; background: #2e6db4; }
.leaflet-control-layers { border: 0 !important; border-radius: 9px !important; box-shadow: 0 2px 12px rgba(0,0,0,.22) !important; }
.leaflet-control-layers-toggle { width: 60px !important; height: 34px !important; display: grid !important; place-items: center; background-image: none !important; color: var(--wine); text-decoration: none; }
.leaflet-control-layers-toggle::after { content: "Capas"; font-size: 11px; font-weight: 800; }
.sample-marker { width: 30px !important; height: 30px !important; display: grid !important; place-items: center; border: 3px solid white; border-radius: 50%; color: white; background: var(--wine); box-shadow: 0 4px 13px rgba(0,0,0,.25); font-size: 12px; font-weight: 800; }
.vertex-handle { width: 16px !important; height: 16px !important; border: 3px solid var(--wine); border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.32); }
.midpoint-handle { width: 14px !important; height: 14px !important; display: grid !important; place-items: center; border: 1px solid #fff; border-radius: 50%; color: #fff; background: var(--wine); box-shadow: 0 2px 7px rgba(0,0,0,.28); font-size: 11px; font-weight: 900; line-height: 1; }
.vertex-delete-button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 8px; color: #fff; background: var(--red); font-size: 12px; font-weight: 750; }
.map-legend { padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.94); box-shadow: 0 2px 12px rgba(0,0,0,.16); font-size: 11px; }
.map-legend > strong { display: block; margin-bottom: 5px; }
.map-legend div { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.map-legend i { width: 12px; height: 12px; display: inline-block; border-radius: 3px; }

.empty-state { padding: 42px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }
.notice { display: flex; gap: 12px; padding: 15px 17px; border: 1px solid #e6d39c; border-radius: 12px; color: #66521d; background: #fff8e4; font-size: 13px; line-height: 1.45; }
.notice.error { border-color: #e5bdbc; color: #782e33; background: #fff1f1; }
.notice.success { border-color: #bdd2b5; color: #385234; background: #f0f6ec; }
.notice strong { display: block; margin-bottom: 2px; }
.inline-message { min-height: 36px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.inline-message.is-error { color: var(--red); }
.help { margin: 6px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.muted { color: var(--muted); }
.separator { height: 1px; margin: 22px 0; background: var(--line); }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.analysis-choice-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analysis-choice-grid .segment button { flex: 1; min-width: 0; }
.planting-spacing-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { color: #5c574f; font-size: 12px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbc3b8; border-radius: 10px; color: var(--ink); background: #fff; outline: none; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(100,36,61,.10); }
.field small { color: var(--muted); font-size: 11px; }
.segment { display: flex; gap: 7px; }
.segment button { min-width: 48px; min-height: 40px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fff; font-weight: 800; }
.segment button.is-active { border-color: var(--wine); color: #fff; background: var(--wine); }

.wizard { display: grid; gap: 20px; }
.stepper { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.step { position: relative; display: grid; justify-items: center; gap: 7px; color: #999188; font-size: 11px; font-weight: 750; text-align: center; }
.step::before { content: ""; position: absolute; top: 14px; left: calc(-50% + 18px); width: calc(100% - 36px); height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step b { z-index: 1; width: 29px; height: 29px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; background: var(--cream); }
.step.is-active, .step.is-done { color: var(--wine); }
.step.is-active b, .step.is-done b { border-color: var(--wine); color: #fff; background: var(--wine); }
.step.is-done::before, .step.is-active::before { background: var(--wine); }
.wizard-actions { display: flex; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.setup-column .standalone-actions { margin-top: 12px; padding-top: 0; border-top: 0; }
.zone-recommendation { display: grid; gap: 5px; margin-bottom: 16px; padding: 15px; border: 1px solid #c8d8c1; border-radius: 13px; background: #f1f7ed; }
.zone-recommendation > span { color: #54704e; font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.zone-recommendation > strong { color: #2f4e35; font-family: Georgia, serif; font-size: 19px; }
.zone-recommendation p { margin: 0; color: #526450; font-size: 12px; line-height: 1.45; }
.zone-recalculate { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.zone-recalculate .field { margin: 0; }
.zone-recalculate > .button { width: 100%; }
.zone-recalculate > small { color: var(--muted); font-size: 11px; }
.zone-list { display: grid; gap: 12px; }
.zone-row { display: grid; grid-template-columns: 16px 1fr auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.zone-swatch { width: 13px; height: 42px; border-radius: 6px; }
.zone-row h3 { margin: 0; font-size: 15px; }
.zone-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.sampling-intro { display: grid; grid-template-columns: 1fr auto; gap: 15px; align-items: center; }
.sampling-intro h2 { margin: 0 0 5px; }
.sampling-intro p { margin: 0; color: var(--muted); }
.sampling-method-selector .panel-body { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding-block: 15px; }
.sampling-method-selector .panel-body > div:first-child { display: grid; gap: 4px; }
.sampling-method-selector .panel-body > div:first-child strong { font-size: 15px; }
.sampling-method-selector .segment button { min-width: 145px; }
.zone-sample { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.zone-sample-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; color: white; }
.zone-sample-header h3 { margin: 0; font-family: Georgia, serif; font-size: 21px; }
.zone-sample-header p { margin: 3px 0 0; opacity: .82; font-size: 12px; }
.zone-sample-body { display: grid; gap: 18px; padding: 20px; }
.zone-settings { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.point-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.point-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.point-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.point-title strong { font-size: 14px; }
.point-title span { color: var(--muted); font-size: 11px; }
.point-fields { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.point-fields .direct-yield-field { grid-column: 1 / -1; }
.point-fields .field input { min-height: 41px; }
.checkbox { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--muted); font-size: 12px; }

.result-hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: hidden; border-radius: 22px; background: var(--wine); color: #fff; }
.result-total { display: grid; align-content: center; padding: 32px; background: rgba(0,0,0,.12); }
.result-total + .result-total { border-left: 1px solid rgba(255,255,255,.16); }
.result-total span { color: #ddc9d1; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.result-total strong { margin: 7px 0 2px; font-family: Georgia, serif; font-size: clamp(38px,6vw,64px); font-weight: 500; }
.result-total small { color: #ddc9d1; }
.zone-share-visual { display: grid; grid-template-columns: 210px minmax(220px, 1fr); gap: 28px; align-items: center; margin-bottom: 24px; padding: 4px 8px 24px; border-bottom: 1px solid var(--line); }
.zone-share-chart { position: relative; width: 210px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), 0 8px 25px rgba(65,45,32,.10); }
.zone-share-center { width: 45%; aspect-ratio: 1; display: grid; place-content: center; justify-items: center; border-radius: 50%; background: var(--paper); box-shadow: 0 2px 10px rgba(0,0,0,.10); }
.zone-share-center strong { font-family: Georgia, serif; font-size: 24px; line-height: 1; }
.zone-share-center span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.zone-share-legend { display: grid; gap: 8px; }
.zone-share-legend > div { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-width: 0; padding: 10px 12px; border-radius: 10px; background: #f7f4ef; }
.zone-share-legend i { width: 14px; height: 36px; border-radius: 5px; }
.zone-share-legend span { min-width: 0; display: grid; gap: 2px; }
.zone-share-legend strong { overflow-wrap: anywhere; font-size: 13px; }
.zone-share-legend small { color: var(--muted); font-size: 11px; }
.zone-share-legend b { color: var(--wine); font-size: 17px; }
.breakdown { width: 100%; border-collapse: collapse; }
.breakdown-wrap { overflow-x: auto; }
.breakdown th { padding: 10px 12px; color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.breakdown td { padding: 14px 12px; border-bottom: 1px solid #eee8df; font-size: 13px; }
.breakdown td:last-child, .breakdown th:last-child { text-align: right; }
.breakdown tr:last-child td { border-bottom: 0; }
.breakdown-details { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.breakdown-details summary { padding: 13px 15px; cursor: pointer; color: var(--wine); font-size: 13px; font-weight: 800; list-style-position: inside; }
.breakdown-details[open] summary { border-bottom: 1px solid var(--line); background: #faf7f2; }
.observations-panel textarea { min-height: 104px; }

.modal { width: min(900px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 21px; background: var(--paper); box-shadow: 0 28px 90px rgba(26,15,20,.28); }
.modal::backdrop { background: rgba(34,25,28,.58); backdrop-filter: blur(3px); }
.modal-card { margin: 0; }
.modal-header, .modal-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 19px 22px; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 3px 0 0; font-family: Georgia, serif; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-body { padding: 20px 22px; }
.modal-map-preview { width: min(1100px, calc(100vw - 28px)); height: min(820px, calc(100dvh - 28px)); max-height: none; }
.modal-map-preview .modal-card { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.modal-map-preview .modal-body { flex: 1; min-height: 0; }
.map-preview { height: 100%; min-height: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; }
.modal-actual { width: min(460px, calc(100vw - 28px)); }
.map-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.map-toolbar .button.is-active { border-color: var(--wine); color: #fff; background: var(--wine); }
.editor-recinto-count { align-self: center; color: var(--wine); font-size: 12px; font-weight: 800; }
#parcel-dialog { width: min(1180px, calc(100vw - 20px)); height: min(920px, calc(100dvh - 20px)); max-height: none; }
#parcel-dialog .modal-card { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
#parcel-dialog .parcel-modal-header { min-height: 52px; }
#parcel-dialog .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#parcel-dialog .map-dialog { flex: 1; min-height: 460px; }
.visit-choice-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); gap: 20px; align-items: stretch; }
.visit-parcel-results { max-height: 340px; display: grid; gap: 8px; margin-top: 12px; overflow: auto; }
.visit-parcel-option { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; text-align: left; }
.visit-parcel-option:hover { border-color: var(--wine); background: var(--wine-soft); }
.visit-parcel-option span { min-width: 0; display: grid; gap: 3px; }
.visit-parcel-option strong { overflow-wrap: anywhere; }
.visit-parcel-option small { color: var(--muted); }
.visit-parcel-option > b { flex: 0 0 auto; color: var(--wine); font-size: 12px; }
.compact-empty { padding: 24px 14px; }
.new-visit-parcel { display: grid; align-content: center; justify-items: start; gap: 14px; padding: 24px; border: 1px solid #cbb3bd; border-radius: 15px; background: var(--wine-soft); }
.new-visit-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--wine); font-size: 25px; }
.new-visit-parcel p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 9999; max-width: min(390px, calc(100vw - 32px)); padding: 13px 17px; border-radius: 12px; color: #fff; background: #28231f; box-shadow: 0 12px 36px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s; font-size: 13px; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .shell { grid-template-columns: 210px 1fr; }
  .sidebar { width: 210px; padding-inline: 14px; }
  .main { grid-column: 2; padding-inline: 26px; }
  .hero { grid-template-columns: 1fr .75fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .field-grid.three { grid-template-columns: repeat(2,1fr); }
  .point-fields { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 0 10px 24px; }
  .topbar { position: relative; height: 72px; align-items: center; gap: 8px; box-sizing: border-box; }
  .topbar > div:first-child { min-width: 0; max-width: 34%; }
  .mobile-app-brand { position: absolute; top: 50%; left: 50%; width: 62px; height: 57px; display: flex; align-items: center; justify-content: center; transform: translate(-50%,-50%); }
  .mobile-app-brand img { width: 58px; height: 53px; object-fit: contain; }
  .topbar h1 { max-width: 100%; margin-top: 0; overflow: hidden; font-size: 14px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  #page-title[data-mobile-title] { font-size: 0; }
  #page-title[data-mobile-title]::after { content: attr(data-mobile-title); font-size: 14px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions { position: absolute; top: 50%; right: 0; gap: 6px; transform: translateY(-50%); }
  .topbar-actions .status-pill { display: none; }
  #install-button { display: none !important; }
  #logout-button { min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .page-stack, .wizard { gap: 14px; }
  .hero { display: block; min-height: 0; border-radius: 18px; }
  .hero-copy { padding: 22px 18px; }
  .hero h2 { margin-top: 8px; font-size: 30px; }
  .hero p { margin-bottom: 18px; font-size: 14px; }
  .hero-copy .button { width: 100%; min-height: 52px; }
  .hero-map { display: none; }
  .stats-grid { gap: 9px; }
  .stat-card { padding: 14px 12px; }
  .stat-card span { font-size: 11px; }
  .stat-card strong { font-size: 22px; }
  .stat-card small { font-size: 10px; }
  .grid-two, .result-hero, .visit-choice-grid { grid-template-columns: 1fr; }
  .section-row { align-items: stretch; flex-direction: column; gap: 11px; }
  .section-row h2, .panel h2 { font-size: 22px; }
  .section-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-actions .button { width: 100%; padding-inline: 10px; }
  .panel { border-radius: 14px; }
  .panel-header, .panel-body { padding: 14px; }
  .button, .button.compact { min-height: 48px; padding: 10px 14px; font-size: 14px; }
  .icon-button { width: 46px; height: 46px; }
  .parcel-card, .visit-card { grid-template-columns: 1fr; }
  .parcel-card, .visit-card { padding: 14px; }
  .visit-actions { width: 100%; justify-items: stretch; }
  .visit-actions > strong { text-align: right; }
  .visit-actions > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visit-actions .button { width: 100%; min-width: 0; padding-inline: 8px; }
  .summary-visit-list .visit-card { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 11px 12px; }
  .summary-visit-list .visit-actions { display: contents; }
  .summary-visit-list .visit-actions > strong { grid-column: 2; grid-row: 1; align-self: center; font-size: 17px; text-align: right; }
  .summary-visit-list .visit-actions > div { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .summary-visit-list .visit-actions .button { min-height: 40px; padding: 6px 4px; font-size: 11px; }
  .home-recent-list .visit-card { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; }
  .home-recent-list > .visit-card > strong { align-self: center; font-size: 16px; text-align: right; }
  .summary-panel-header { align-items: stretch; flex-direction: column; }
  .summary-search { width: 100%; }
  .parcel-search { width: 100%; }
  .parcel-summary { grid-template-columns: 1fr; }
  .parcel-expand-button { flex-basis: 44px; width: 44px; height: 44px; }
  .card-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .7fr); width: 100%; }
  .card-actions .button { width: 100%; min-width: 0; padding-inline: 9px; }
  .field-grid, .field-grid.three, .zone-settings, .point-grid, .add-field-row { grid-template-columns: 1fr; }
  .analysis-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .analysis-choice-grid .segment { gap: 4px; }
  .analysis-choice-grid .segment button { min-height: 44px; padding-inline: 3px; font-size: 12px; }
  .planting-spacing-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .parcel-settings .zone-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .parcel-settings .missing-field { grid-column: 1 / -1; }
  .parcel-fields dl { grid-template-columns: repeat(2,1fr); }
  .field input, .field select, .field textarea { min-height: 50px; font-size: 16px; }
  .segment { width: 100%; }
  .segment button { flex: 1; min-height: 48px; }
  .map-card, .map-large { min-height: min(52dvh, 460px); }
  .zones-map-column { height: min(52dvh, 460px); min-height: 340px; }
  .zones-review-layout .map-large { height: 100%; min-height: 0; }
  .map-dialog { min-height: 320px; }
  .map-location-control button, .leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; }
  .leaflet-control-layers-toggle { width: 72px !important; height: 44px !important; }
  .sample-marker { width: 38px !important; height: 38px !important; font-size: 13px; }
  .stepper { gap: 3px; }
  .step { gap: 5px; font-size: 10px; }
  .step::before { top: 16px; }
  .step b { width: 33px; height: 33px; }
  .zone-list { gap: 9px; }
  .zone-row { padding: 12px 10px; gap: 9px; }
  .zone-row p { line-height: 1.35; }
  .sampling-intro { grid-template-columns: 1fr; gap: 11px; }
  .sampling-intro p { display: none; }
  .sampling-intro .button { width: 100%; }
  .sampling-method-selector .panel-body { display: grid; gap: 10px; padding: 13px 12px; }
  .sampling-method-selector .segment button { min-width: 0; padding-inline: 8px; }
  .zone-sample { border-radius: 14px; }
  .zone-sample-header { padding: 15px 14px; }
  .zone-sample-header h3 { font-size: 20px; }
  .zone-sample-body { gap: 14px; padding: 12px; }
  .point-card { padding: 14px 12px; }
  .checkbox { min-height: 46px; font-size: 13px; }
  .checkbox input { width: 22px; height: 22px; }
  .result-total { padding: 24px 18px; }
  .result-total + .result-total { border-top: 1px solid rgba(255,255,255,.16); border-left: 0; }
  .zone-share-visual { grid-template-columns: 1fr; justify-items: center; gap: 18px; margin-bottom: 18px; padding: 2px 0 20px; }
  .zone-share-chart { width: min(54vw, 190px); }
  .zone-share-center strong { font-size: 22px; }
  .zone-share-legend { width: 100%; }
  .zone-share-legend > div { padding: 9px 10px; }
  .breakdown-wrap { overflow: visible; }
  .breakdown, .breakdown tbody, .breakdown tr, .breakdown td { display: block; width: 100%; }
  .breakdown thead { display: none; }
  .breakdown tbody { display: grid; gap: 10px; }
  .breakdown tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .breakdown td { min-width: 0; padding: 11px 12px; border: 0; border-bottom: 1px solid #eee8df; text-align: left !important; }
  .breakdown td:nth-child(even) { border-right: 1px solid #eee8df; }
  .breakdown td:first-child { grid-column: 1 / -1; }
  .breakdown td:first-child { background: #f6f3ed; }
  .breakdown td:nth-child(4), .breakdown td:last-child { border-bottom: 0; }
  .breakdown td:last-child { background: var(--wine-soft); }
  .breakdown td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
  .breakdown-details summary { min-height: 48px; display: flex; align-items: center; padding: 12px; }
  .modal { width: calc(100% - 16px); max-width: calc(100% - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); margin: 8px auto; border-radius: 14px; }
  .modal-card { min-height: 100%; display: flex; flex-direction: column; }
  .modal-header, .modal-footer { flex: 0 0 auto; padding: 12px 14px; }
  .modal-body { flex: 1; min-height: 0; padding: 14px; overflow-y: auto; }
  .modal-footer .button { flex: 1; }
  .modal-map-preview .modal-body { display: flex; padding: 10px; overflow: hidden; }
  .map-preview { flex: 1; min-height: 0; }
  .modal-actual { width: calc(100% - 24px); max-width: 460px; height: auto; max-height: calc(100dvh - 24px); margin: auto; }
  .modal-actual .modal-card { min-height: 0; }
  .modal-actual .modal-body { flex: 0 0 auto; }
  .modal-visit .modal-header { padding: 10px 12px; }
  .modal-visit .modal-header h2 { font-size: 19px; }
  .modal-visit .visit-choice-grid { display: flex; flex-direction: column; gap: 9px; overflow: hidden; }
  .modal-visit .visit-choice-grid > section:first-child { min-height: 0; display: flex; flex: 1; flex-direction: column; }
  .modal-visit .field { gap: 4px; }
  .modal-visit .field input { min-height: 44px; }
  .visit-parcel-results { min-height: 0; max-height: none; gap: 5px; margin-top: 7px; overflow-y: auto; }
  .visit-parcel-option { min-height: 44px; padding: 7px 10px; }
  .visit-parcel-option span { display: flex; align-items: baseline; gap: 7px; }
  .visit-parcel-option b { font-size: 0; }
  .visit-parcel-option b::after { content: "→"; font-size: 17px; }
  .new-visit-parcel { order: -1; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 9px 10px; }
  .new-visit-icon { width: 34px; height: 34px; font-size: 20px; }
  .new-visit-parcel p { display: none; }
  .new-visit-parcel .button { min-height: 42px; padding: 7px 10px; font-size: 12px; }
  #parcel-dialog { width: calc(100% - 16px); max-width: calc(100% - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); margin: 8px auto; border-radius: 14px; }
  #parcel-dialog .modal-header { flex: 0 0 auto; min-height: 40px; padding: 5px 9px 5px 11px; }
  #parcel-dialog .modal-header .icon-button { width: 36px; height: 36px; }
  #parcel-dialog .modal-footer { flex: 0 0 auto; padding: 7px 10px; }
  #parcel-dialog .modal-footer .button { min-height: 42px; padding-block: 7px; }
  #parcel-dialog .modal-body { padding: 7px 10px; overflow: hidden; }
  #parcel-dialog .field { gap: 4px; }
  #parcel-dialog #new-parcel-name { min-height: 46px; padding-block: 8px; }
  #parcel-dialog .help { margin: 3px 0 6px; font-size: 11px; line-height: 1.3; }
  #parcel-dialog .map-toolbar { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
  #parcel-dialog .map-toolbar .button { flex: 1 1 0; width: auto; min-width: 0; min-height: 40px; padding: 6px 5px; font-size: 11px; line-height: 1.1; }
  #parcel-dialog .map-toolbar .toolbar-icon-button { flex: 0 0 40px; font-size: 17px; }
  #parcel-dialog #remove-holes { order: 2; flex: 1 0 100%; min-height: 36px; }
  #parcel-dialog .editor-recinto-count { order: 3; flex: 1 0 100%; }
  #parcel-dialog .map-dialog { flex: 1; min-height: min(44dvh, 380px); }
  #parcel-dialog .inline-message { flex: 0 0 auto; min-height: 24px; margin-top: 4px; font-size: 11px; line-height: 1.3; }
  .point-fields { grid-template-columns: 1fr; }
  .wizard-actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 10; margin: 0 -14px -14px; padding: 11px 14px calc(11px + env(safe-area-inset-bottom)); background: rgba(255,253,249,.97); box-shadow: 0 -8px 20px rgba(0,0,0,.08); }
  .wizard-actions .button { flex: 1; min-width: 0; padding-inline: 8px; }
  .setup-column .standalone-actions { position: static; margin: 10px 0 0; padding: 0; background: transparent; box-shadow: none; }
  .zone-recalculate { margin-bottom: 15px; }
  .mobile-nav { position: fixed; inset: auto 0 0 0; z-index: 1000; height: calc(64px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3,1fr); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,253,249,.96); backdrop-filter: blur(10px); }
  .mobile-nav-item { min-height: 56px; display: grid; justify-items: center; align-content: center; gap: 2px; border: 0; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
  .mobile-nav-item span { font-size: 20px; line-height: 1; }
  .mobile-nav-item.is-active { color: var(--wine); }
  .toast { right: 16px; bottom: 80px; }
}

@media (max-width: 440px) {
  .login-screen { place-items: stretch; align-content: center; padding: 14px; }
  .login-card { gap: 21px; padding: 25px 20px; border-radius: 19px; }
  .login-copy h1 { font-size: 30px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section-row .button { width: 100%; }
  .section-actions { width: 100%; }
  .wizard-actions .button { flex: 1; padding-inline: 7px; font-size: 13px; }
  .step span { font-size: 9px; }
  #parcel-dialog .modal-body { padding: 9px 10px; }
}
