:root {
  color-scheme: light;
  --c-primary: #1e40af;
  --c-primary-hover: #1e3a8a;
  --c-on-primary: #ffffff;
  --c-bg: #f1f5f9;
  --c-card: #ffffff;
  --c-text: #0f172a;
  --c-text-muted: #475569;
  --c-border: #d7dee8;
  --c-focus: #2563eb;

  /* Durum renkleri: metin/zemin çiftleri 4.5:1 üstü kontrast */
  --ok-fg: #166534;  --ok-bg: #dcfce7;  --ok-dot: #16a34a;
  --warn-fg: #92400e; --warn-bg: #fef3c7; --warn-dot: #d97706;
  --bad-fg: #991b1b;  --bad-bg: #fee2e2;  --bad-dot: #dc2626;
  --muted-fg: #374151; --muted-bg: #e5e7eb; --muted-dot: #6b7280;

  --radius: 10px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --panel-w: 420px;
  --topbar-h: 56px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
/* "hidden" özniteliği, display tanımlayan sınıflara (ör. .card { display:flex }) her zaman baskın gelsin */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }

.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;
}
.skip-link {
  position: absolute; left: var(--space-2); top: -48px; z-index: 2000;
  background: var(--c-primary); color: var(--c-on-primary); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius); text-decoration: none;
}
.skip-link:focus { top: var(--space-2); }

:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* ---------------------------------------------------------------- üst çubuk */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--c-primary); color: var(--c-on-primary);
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-icon { width: 28px; height: 28px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand h1 { font-size: 18px; font-weight: 650; }
.brand-sub { font-size: 13px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-badge {
  font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.45); white-space: nowrap;
}
.mode-badge.demo { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bg); }

/* ---------------------------------------------------------------- yerleşim */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #dfe6ee; }
#map.drawing { cursor: crosshair; }
.panel {
  overflow-y: auto; min-height: 0;
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-4);
  border-left: 1px solid var(--c-border);
}
.panel:focus { outline: none; }

@media (max-width: 900px) {
  .layout { display: block; height: auto; }
  .map-wrap { height: 58vh; height: 58dvh; }
  .panel { border-left: 0; overflow: visible; }
  .brand-sub { display: none; }
  .leaflet-container .leaflet-control-attribution { font-size: 10px; }
}

.map-hint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 500;
  max-width: calc(100% - 32px);
  background: rgba(15, 23, 42, .88); color: #fff; font-size: 14px;
  padding: 6px 12px; border-radius: 999px; pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
.map-hint.show { opacity: 1; }

/* ---------------------------------------------------------------- kartlar */
.card {
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3);
}
.card h2 { font-size: 17px; font-weight: 650; display: flex; align-items: center; gap: var(--space-2); }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-primary); color: var(--c-on-primary); font-size: 13px; font-weight: 700;
}
.help { color: var(--c-text-muted); font-size: 14px; }
.small { font-size: 13px; }

/* ---------------------------------------------------------------- form */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field + .field { margin-top: var(--space-3); }
label { font-size: 14px; font-weight: 600; }
input, select {
  width: 100%; min-width: 0;
  min-height: 44px; padding: 8px 12px; border: 1px solid #94a3b8; border-radius: 8px; background: #fff;
}
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--c-focus); }
input[aria-invalid="true"] { border-color: var(--bad-dot); }
.field-error { color: var(--bad-fg); font-size: 14px; min-height: 0; }
.field-error:empty { display: none; }

.coord-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--space-2); align-items: end; }
.coord-form .field + .field { margin-top: 0; }
@media (max-width: 380px) { .coord-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .coord-form .btn { grid-column: 1 / -1; } }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #94a3b8; border-radius: 8px; padding: 3px; margin: 0; gap: 3px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; border-radius: 6px; font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}
.segmented input:checked + span { background: var(--c-primary); color: var(--c-on-primary); }
.segmented input:focus-visible + span { outline: 3px solid var(--c-focus); outline-offset: 1px; }

/* ---------------------------------------------------------------- butonlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:disabled { cursor: not-allowed; opacity: .5; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:not(:disabled):hover { background: var(--c-primary-hover); }
.btn-secondary { background: #fff; color: var(--c-primary); border-color: var(--c-primary); }
.btn-secondary:not(:disabled):hover { background: #eff6ff; }
.btn-ghost { background: transparent; color: var(--c-text); border-color: var(--c-border); }
.btn-ghost:not(:disabled):hover { background: #f8fafc; }
.btn-block { width: 100%; margin-top: var(--space-4); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .8s linear infinite;
}
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.selection { font-size: 14px; padding: var(--space-2) var(--space-3); background: #f8fafc; border-radius: 8px; border: 1px dashed var(--c-border); }
.selection.ready { border-style: solid; border-color: #93c5fd; background: #eff6ff; }
.eval-status { font-size: 14px; color: var(--c-text-muted); margin-top: var(--space-2); }
.eval-status:empty { display: none; }

.note { font-size: 14px; padding: var(--space-2) var(--space-3); border-radius: 8px; }
.note.warn { background: var(--warn-bg); color: var(--warn-fg); }
.note.bad { background: var(--bad-bg); color: var(--bad-fg); }
.note.info { background: #eff6ff; color: #1e3a8a; }

/* ---------------------------------------------------------------- sonuçlar */
.result-head { display: flex; flex-direction: column; gap: var(--space-1); }
.result-head h3 { font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chip { font-size: 12.5px; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; border: 1px solid var(--c-border); color: var(--c-text-muted); }

.sources { display: flex; flex-direction: column; gap: var(--space-1); }
.source-row { display: flex; align-items: flex-start; gap: var(--space-2); font-size: 14px; }
.source-row .detail { color: var(--c-text-muted); font-size: 13px; }
.tech > summary { cursor: pointer; font-size: 12.5px; color: var(--c-text-muted); }
.tech code { display: block; font-size: 12px; color: var(--c-text-muted); word-break: break-word; background: #f8fafc; border-radius: 6px; padding: 4px 6px; margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 13px; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tone-ok { color: var(--ok-fg); background: var(--ok-bg); }
.tone-warn { color: var(--warn-fg); background: var(--warn-bg); }
.tone-bad { color: var(--bad-fg); background: var(--bad-bg); }
.tone-muted { color: var(--muted-fg); background: var(--muted-bg); }

.crop-list { display: flex; flex-direction: column; gap: var(--space-2); }
.crop {
  border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff;
}
.crop > summary {
  list-style: none; cursor: pointer; padding: var(--space-3); display: grid;
  grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-3); align-items: center;
  border-radius: var(--radius);
}
.crop > summary::-webkit-details-marker { display: none; }
.crop > summary:hover { background: #f8fafc; }
.crop-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: var(--space-2); }
.crop-name::before {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--c-text-muted); border-bottom: 2px solid var(--c-text-muted);
  transform: rotate(-45deg); transition: transform .15s ease; flex: none;
}
.crop[open] .crop-name::before { transform: rotate(45deg); }
.score { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); align-items: center; font-size: 14px; }
.score-text { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 92px; }
.score-text.none { color: var(--c-text-muted); font-weight: 500; }
.score-track { position: relative; height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.score-band { position: absolute; top: 0; bottom: 0; left: 0; background: var(--c-primary); }
.score-band.range { background: repeating-linear-gradient(45deg, #93c5fd, #93c5fd 3px, #dbeafe 3px, #dbeafe 6px); }

.rules { list-style: none; margin: 0; padding: 0 var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.rule { border-top: 1px solid #eef2f7; padding-top: var(--space-2); display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-2); }
.rule > .badge, .crop > summary > .badge { align-self: start; }
.rule-name { font-weight: 600; font-size: 14px; }
.rule-tags { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.tag { font-size: 11.5px; font-weight: 700; padding: 0 6px; border-radius: 4px; border: 1px solid currentColor; }
.tag.critical { color: var(--bad-fg); }
.tag.optimal { color: var(--ok-fg); }
.rule-meta { grid-column: 1 / -1; font-size: 13px; color: var(--c-text-muted); }
.rule-meta b { color: var(--c-text); font-weight: 600; font-variant-numeric: tabular-nums; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.data-table th { color: var(--c-text-muted); font-weight: 600; }
.data-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
details.more > summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--c-primary); padding: var(--space-1) 0; }

/* ekim takvimi, toprak sınırları, mevsimsel göstergeler ve 7 günlük tahmin */
.sowing-box { border-top: 1px solid #eef2f7; padding: var(--space-2) var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: 4px; background: #fbfdff; border-radius: 0 0 var(--radius) var(--radius); }
.sowing-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; font-size: 13.5px; }
.sowing-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.sowing-win { font-size: 13.5px; font-weight: 600; color: var(--c-text); margin: 0; }
.muted-cite { color: var(--c-text-muted); font-style: italic; }

.soil-box { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); background: #f8fafc; margin-top: var(--space-2); }
.soil-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; color: var(--c-text); }
.soil-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--c-text-muted); }

.ind-section { margin-top: var(--space-2); display: flex; flex-direction: column; gap: 6px; }
.ind-grid { display: flex; flex-direction: column; gap: 6px; }
.ind-card { border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); background: #fff; display: flex; flex-direction: column; gap: 3px; }
.ind-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.ind-label { font-size: 13.5px; font-weight: 650; }
.ind-val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-primary); white-space: nowrap; }
.ind-meta { font-size: 12px; color: var(--c-text-muted); font-variant-numeric: tabular-nums; margin: 0; }

.forecast-card { border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; margin-top: var(--space-2); }
.forecast-card > summary { list-style: none; cursor: pointer; padding: var(--space-2) var(--space-3); display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.forecast-card > summary::-webkit-details-marker { display: none; }
.forecast-card > summary:hover { background: #f8fafc; }
.fc-sum-left { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.fc-sum-quick { font-size: 12.5px; color: var(--c-text-muted); font-variant-numeric: tabular-nums; }
.fc-body { border-top: 1px solid #eef2f7; padding: var(--space-2) var(--space-3) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.fc-chart-wrap { display: flex; flex-direction: column; gap: 6px; }
.fc-svg { width: 100%; height: auto; display: block; background: #fbfdff; border: 1px solid #eef2f7; border-radius: 8px; }
.fc-grid { stroke: #e2e8f0; stroke-width: 1; }
.fc-zero { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 4 3; }
.fc-axis-label, .fc-day-label { font-size: 10px; fill: #64748b; font-variant-numeric: tabular-nums; }
.fc-bar { fill: rgba(59, 130, 246, 0.35); stroke: #2563eb; stroke-width: 1; }
.fc-line-tmax { fill: none; stroke: #ea580c; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fc-line-tmin { fill: none; stroke: #0284c7; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fc-dot-tmax { fill: #ea580c; stroke: #fff; stroke-width: 1.2; }
.fc-dot-tmin { fill: #0284c7; stroke: #fff; stroke-width: 1.2; }
.fc-hit { fill: transparent; cursor: pointer; }
.fc-hit:hover, .fc-hit:focus { fill: rgba(15, 23, 42, 0.05); outline: none; }
.fc-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: 12px; color: var(--c-text-muted); }
.fc-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.fc-swatch.tmax { background: #ea580c; }
.fc-swatch.tmin { background: #0284c7; }
.fc-swatch.rain { background: rgba(59, 130, 246, 0.45); border: 1px solid #2563eb; }
.fc-readout { font-size: 13px; font-weight: 600; color: var(--c-text); background: #f1f5f9; border-radius: 6px; padding: 6px 8px; font-variant-numeric: tabular-nums; }

.meta-list { margin-top: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }
.meta-item { border-top: 1px solid #eef2f7; padding-top: var(--space-1); display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }

/* alan özeti */
.dist { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #e2e8f0; }
.dist > span { display: block; height: 100%; }
.dist .ok { background: var(--ok-dot); } .dist .warn { background: var(--warn-dot); }
.dist .muted { background: var(--muted-dot); } .dist .bad { background: var(--bad-dot); }
.area-crop { display: flex; flex-direction: column; gap: 6px; padding: var(--space-3); border: 1px solid var(--c-border); border-radius: var(--radius); }
.area-crop-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; }
.area-crop-head strong { font-size: 16px; }
.area-counts { font-size: 13px; color: var(--c-text-muted); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: 13px; color: var(--c-text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }
.legend i.ok { background: var(--ok-dot); } .legend i.warn { background: var(--warn-dot); }
.legend i.muted { background: var(--muted-dot); } .legend i.bad { background: var(--bad-dot); }
.legend i.err { background: #fff; border: 2px solid #111827; }
.inline-field { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: center; }
.section-title { font-size: 14px; font-weight: 700; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: var(--space-2); }

.demo-row { display: grid; grid-template-columns: 1fr 170px; gap: var(--space-2); align-items: center; }
.demo-row + .demo-row { margin-top: var(--space-2); }

.attribution { font-size: 12.5px; color: var(--c-text-muted); display: flex; flex-direction: column; gap: var(--space-2); padding: 0 var(--space-1) var(--space-4); }

/* harita üstü etiket ve örnek nokta numarası */
.region-label {
  background: rgba(15, 23, 42, .85); color: #fff; border: 0; box-shadow: none;
  font-size: 13px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.sample-label { font-weight: 700; font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
