:root {
  /* พื้นผิว (พื้นหลังสีขาวโทนอบอุ่น) */
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-alt: #f4ead9;
  --surface-hover: #ede0c7;
  --card: #ffffff;
  --border: #e6d7bd;
  --border-light: #d9c6a3;

  /* ตัวอักษร */
  --text: #2e2013;
  --text-muted: #7d6a4f;
  --text-dim: #a3927a;

  /* โทนเขียว (สถานะผ่านเกณฑ์ / ข้าวโพด) */
  --green-900: #163a20;
  --green-800: #1f6b3d;
  --green-700: #2f8a4d;
  --green-600: #3aa15c;
  --green-500: #256b3d;
  --accent: #2f8a4d;

  /* โทนส้ม (แบรนด์หลัก / ปุ่ม / จุดเน้น) */
  --orange-700: #b8571f;
  --orange-600: #cf642a;
  --orange-500: #d9711f;

  /* โทนน้ำตาล (โครงสร้าง / ข้าว) */
  --brown-800: #3a2818;
  --brown-700: #4a3222;
  --brown-500: #8b5e34;
  --rice-500: #7a4f2a;

  /* สถานะ */
  --amber-500: #a8760a;
  --amber-bg: #d9a441;
  --red-500: #b3352f;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 20px rgba(74, 50, 34, 0.12), 0 1px 2px rgba(74, 50, 34, 0.08);
  --shadow-sm: 0 2px 8px rgba(74, 50, 34, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Thai", "Sarabun", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% -10%, rgba(217, 113, 31, 0.07) 0%, transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(47, 138, 77, 0.06) 0%, transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* สกอร์ลบาร์แบบมินิมอล */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--orange-600); }

#app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brown-700) 0%, var(--brown-800) 60%, #2a1c10 100%);
  border-right: 1px solid var(--border);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}
.sidebar .brand .logo {
  font-size: 26px;
  filter: drop-shadow(0 0 10px rgba(217, 113, 31, 0.45));
}
.sidebar .brand .name { font-weight: 700; font-size: 15px; line-height: 1.3; color: #fff; letter-spacing: 0.2px; }
.sidebar .brand .sub { font-size: 11px; color: #d9c9b4; margin-top: 1px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: #ecdfcb;
  text-decoration: none;
  font-size: 14.5px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(217, 113, 31, 0.4);
}
.nav-item .icon { font-size: 17px; width: 20px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  font-size: 11px;
  color: #c9b89e;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* ---------- Main content ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 60px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar h1 { font-size: 21px; margin: 0; color: var(--text); letter-spacing: 0.2px; }
.topbar .desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--orange-500), var(--orange-700));
  color: #fff;
  box-shadow: 0 2px 10px rgba(217, 113, 31, 0.3);
  transition: box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.btn:hover { box-shadow: 0 4px 16px rgba(217, 113, 31, 0.45); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-light); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-hover); border-color: var(--orange-600); box-shadow: none; transform: translateY(-1px); }
.btn.danger { background: linear-gradient(135deg, var(--red-500), #8f2a25); box-shadow: 0 2px 10px rgba(179, 53, 47, 0.25); }
.btn.danger:hover { box-shadow: 0 4px 16px rgba(179, 53, 47, 0.4); }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Cards / grids ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  position: relative;
  background: linear-gradient(160deg, var(--surface-alt), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--green-600), var(--green-800));
}
.stat-card .value { font-size: 27px; font-weight: 700; color: var(--text); letter-spacing: 0.2px; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.stat-card.warn::before { background: linear-gradient(180deg, var(--amber-bg), var(--amber-500)); }
.stat-card.warn .value { color: var(--amber-500); }
.stat-card.bad::before { background: linear-gradient(180deg, #d9645e, var(--red-500)); }
.stat-card.bad .value { color: var(--red-500); }

.section-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 26px 0 12px; letter-spacing: 0.2px; }

/* ---------- Dashboard: harvest timeline (day 1-120) ---------- */
.harvest-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.harvest-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.harvest-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.harvest-dot.good, .harvest-row-fill.good, .harvest-row-marker.good { background: var(--green-600); }
.harvest-dot.warning, .harvest-row-fill.warning, .harvest-row-marker.warning { background: var(--amber-bg); }
.harvest-dot.critical, .harvest-row-fill.critical, .harvest-row-marker.critical { background: #d9645e; }
.harvest-row-remaining.good { color: var(--green-500); }
.harvest-row-remaining.warning { color: var(--amber-500); }
.harvest-row-remaining.critical { color: var(--red-500); }

.harvest-axis {
  position: relative; height: 18px; margin: 0 0 8px 196px; border-bottom: 1px solid var(--border-light);
}
.harvest-axis span {
  position: absolute; bottom: 4px; transform: translateX(-50%); font-size: 10.5px; color: var(--text-dim);
}

.harvest-list { max-height: 380px; overflow-y: auto; padding-right: 4px; }
.harvest-row {
  display: grid; grid-template-columns: 180px 1fr 116px; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.harvest-row:last-child { border-bottom: none; }
.harvest-row-label { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.harvest-row-track { position: relative; height: 8px; background: var(--surface-alt); border: 1px solid var(--border-light); border-radius: 999px; }
.harvest-row-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; min-width: 8px; }
.harvest-row-marker {
  position: absolute; top: -20px; transform: translateX(-50%); color: #2a1d10; font-weight: 700;
  font-size: 10px; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
}
.harvest-row-days { text-align: right; white-space: nowrap; }
.harvest-row-date { font-size: 12.5px; font-weight: 700; color: var(--text); }
.harvest-row-remaining { font-size: 10.5px; font-weight: 600; margin-top: 1px; }

/* ---------- Dashboard: weekly harvest area chart ---------- */
.weekly-chart { display: flex; gap: 16px; overflow-x: auto; padding: 4px 4px 8px; align-items: flex-end; }
.weekly-bar-col { flex: 0 0 68px; display: flex; flex-direction: column; align-items: center; }
.weekly-bar-value { font-size: 11px; font-weight: 700; color: var(--text); margin-bottom: 5px; white-space: nowrap; }
.weekly-bar-track {
  width: 30px; height: 170px; background: var(--surface-alt); border: 1px solid var(--border-light);
  border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden;
}
.weekly-bar-fill {
  width: 100%; background: linear-gradient(180deg, var(--green-600), var(--green-800));
  border-radius: 4px 4px 0 0; min-height: 3px;
}
.weekly-bar-label { font-size: 10.5px; color: var(--text-muted); margin-top: 7px; text-align: center; white-space: nowrap; }

/* ---------- Dashboard: district breakdown chart ---------- */
.district-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.district-dot.corn { background: var(--green-600); }
.district-dot.rice { background: var(--rice-500); }
.district-list { display: flex; flex-direction: column; }
.district-row {
  display: grid; grid-template-columns: 150px 1fr 110px; align-items: center; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.district-row:last-child { border-bottom: none; }
.district-row-label { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.district-row-track {
  position: relative; height: 14px; background: var(--surface-alt); border: 1px solid var(--border-light);
  border-radius: 999px; display: flex; overflow: hidden;
}
.district-row-fill.corn { background: var(--green-600); height: 100%; }
.district-row-fill.rice { background: var(--rice-500); height: 100%; }
.district-row-value { font-size: 12px; text-align: right; white-space: nowrap; font-weight: 600; color: var(--text); }

/* ---------- Dashboard: recent photos by promoter ---------- */
.promoter-photo-block { margin-bottom: 18px; }
.promoter-name { font-weight: 700; color: var(--orange-700); margin-bottom: 8px; font-size: 13.5px; }
.photo-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.photo-card {
  flex: 0 0 160px; cursor: pointer; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform 0.15s, border-color 0.15s;
}
.photo-card:hover { transform: translateY(-3px); border-color: var(--orange-600); }
.photo-card img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--surface); }
.photo-card .pc-info { padding: 6px 8px; }
.photo-card .pc-farmer { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-card .pc-meta { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-alt);
  color: var(--orange-700);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: rgba(217, 113, 31, 0.05); }
tbody tr:last-child td { border-bottom: none; }
.empty-row td { text-align: center; color: var(--text-muted); padding: 30px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge-green { background: rgba(47, 138, 77, 0.12); color: var(--green-500); border-color: rgba(47, 138, 77, 0.25); }
.badge-amber { background: rgba(217, 164, 65, 0.18); color: var(--amber-500); border-color: rgba(217, 164, 65, 0.35); }
.badge-red { background: rgba(179, 53, 47, 0.1); color: var(--red-500); border-color: rgba(179, 53, 47, 0.25); }
.badge-gray { background: rgba(74, 50, 34, 0.05); color: var(--text-muted); border-color: var(--border-light); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 6px; }
.form-grid.two-col { grid-template-columns: repeat(2, 1fr); }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item.wide { grid-column: 1 / -1; }
.form-item label { font-size: 12.5px; font-weight: 600; color: var(--orange-700); }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange-600);
  box-shadow: 0 0 0 3px rgba(217, 113, 31, 0.18);
}
textarea { resize: vertical; }

.fields-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; margin-top: 10px; }
.field-item { display: flex; flex-direction: column; gap: 4px; }
.field-item input[readonly] { background: var(--surface-alt); color: var(--text-muted); cursor: default; }

.field-groups { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.field-group { background: var(--surface-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 10px 12px; }
.field-group .fields-grid { margin-top: 6px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.field-group-title { font-size: 12px; font-weight: 700; color: var(--orange-700); }
.field-group.total-group { background: rgba(47, 138, 77, 0.08); border-color: rgba(47, 138, 77, 0.3); }
.field-group.total-group .field-group-title { color: var(--green-500); }
.field-item.field-wide { grid-column: 1 / -1; }
.field-item label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.field-other { margin-top: 4px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px 16px; padding: 6px 0; }
.chk-item { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.chk-item input { width: auto; accent-color: var(--orange-600); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(42, 29, 16, 0.45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border-light); border-radius: 14px; max-width: 640px; width: 100%;
  box-shadow: 0 24px 60px rgba(58, 40, 24, 0.35); animation: pop 0.15s ease-out;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 16.5px; margin: 0; color: var(--text); }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-muted); background: none; border: none; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Inspection form ---------- */
.phase-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.phase-tab {
  padding: 8px 13px; border-radius: var(--radius-sm); background: var(--surface-alt); border: 1px solid var(--border-light);
  font-size: 12.5px; cursor: pointer; color: var(--text-muted); font-weight: 600; transition: all 0.15s;
}
.phase-tab:hover { border-color: var(--orange-600); color: var(--text); }
.phase-tab.active { background: linear-gradient(135deg, var(--orange-500), var(--orange-700)); color: #fff; border-color: var(--orange-600); box-shadow: 0 2px 10px rgba(217, 113, 31, 0.3); }
.phase-tab.has-data::after { content: " ●"; color: var(--green-600); }
.phase-tab.active.has-data::after { color: #fff; }

.phase-header { margin-bottom: 14px; }
.phase-header h2 { font-size: 17px; margin: 0 0 2px; color: var(--text); }
.phase-header .sub { font-size: 13px; color: var(--text-muted); }

.item-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.item-card.critical { border-left: 3px solid var(--red-500); background: linear-gradient(180deg, rgba(179, 53, 47, 0.05), var(--card) 40%); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.item-no { display: inline-block; background: var(--orange-600); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: 12px; margin-right: 8px; }
.item-criteria { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.critical-note { font-size: 12px; color: var(--red-500); font-weight: 700; margin-top: 5px; }

.result-radio { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.result-radio label {
  padding: 6px 14px; border: 1px solid var(--border-light); border-radius: 999px; font-size: 12.5px;
  cursor: pointer; font-weight: 600; color: var(--text-muted); user-select: none; transition: all 0.15s;
}
.result-radio label:hover { border-color: var(--orange-600); }
.result-radio input { display: none; }
.result-radio input:checked + span { color: inherit; }
.result-radio label.opt-pass.checked, .result-radio label.opt-pass:has(input:checked) { background: rgba(47, 138, 77, 0.12); border-color: var(--green-600); color: var(--green-500); }
.result-radio label.opt-fail.checked, .result-radio label.opt-fail:has(input:checked) { background: rgba(179, 53, 47, 0.12); border-color: var(--red-500); color: var(--red-500); }
.result-radio label.opt-na.checked, .result-radio label.opt-na:has(input:checked) { background: rgba(217, 164, 65, 0.18); border-color: var(--amber-bg); color: var(--amber-500); }

.moisture-avg-banner {
  margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700;
  background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border-light);
}
.moisture-avg-banner.pass { background: rgba(47, 138, 77, 0.1); color: var(--green-500); border-color: rgba(47, 138, 77, 0.3); }
.moisture-avg-banner.fail { background: rgba(179, 53, 47, 0.1); color: var(--red-500); border-color: rgba(179, 53, 47, 0.3); }

.photo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.photo-slot { text-align: center; }
.photo-slot .slot-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 5px; }
.photo-slot .drop {
  border: 1.5px dashed var(--border-light); border-radius: var(--radius-sm); height: 110px; display: flex;
  align-items: center; justify-content: center; cursor: pointer; overflow: hidden; background: var(--surface-alt); position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.photo-slot .drop:hover { border-color: var(--orange-600); background: var(--surface-hover); }
.photo-slot .drop img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .drop .hint { font-size: 22px; opacity: 0.5; }
.photo-slot .remove-photo {
  position: absolute; top: 4px; right: 4px; background: rgba(42, 29, 16, 0.7); color: #fff; border: none;
  border-radius: 5px; font-size: 11px; padding: 2px 6px; cursor: pointer;
}
.photo-stamp {
  position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(0deg, rgba(0,0,0,0.75), rgba(0,0,0,0));
  color: #fff; font-size: 9.5px; line-height: 1.4; padding: 12px 6px 4px; text-align: left;
}

.summary-box { background: linear-gradient(160deg, rgba(47, 138, 77, 0.08), var(--surface)); border: 1px solid rgba(47, 138, 77, 0.3); border-radius: var(--radius); padding: 16px 18px; margin-top: 6px; }

/* ---------- Map ---------- */
#map-view-container { display: flex; gap: 16px; height: calc(100vh - 150px); min-height: 480px; }
#map-canvas { flex: 1; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.map-sidebar { width: 300px; flex-shrink: 0; overflow-y: auto; }
.map-farmer-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  margin-bottom: 8px; cursor: pointer; font-size: 13px; transition: border-color 0.15s, transform 0.1s;
}
.map-farmer-item:hover { border-color: var(--orange-600); transform: translateX(-2px); }
.map-farmer-item .name { font-weight: 700; color: var(--orange-700); }
.map-farmer-item .meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.map-farmer-item.no-gps { opacity: 0.5; }

.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(58, 40, 24, 0.3); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { font-family: inherit; font-size: 13px; }
.popup-title { font-weight: 700; color: var(--orange-700); margin-bottom: 4px; }

.leaflet-div-icon.radius-label-icon { background: transparent; border: none; }
.radius-label {
  background: rgba(42, 29, 16, 0.82); border: 1.5px solid; border-radius: 999px;
  padding: 2px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; text-align: center; color: #fff;
}

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 36px 32px; box-shadow: 0 24px 60px rgba(58, 40, 24, 0.25); text-align: center;
}
.login-logo { font-size: 44px; margin-bottom: 6px; filter: drop-shadow(0 0 14px rgba(217, 113, 31, 0.4)); }
.login-box h1 { font-size: 18px; margin: 0; color: var(--text); }
.login-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.login-box .form-item { text-align: left; }
.login-box .form-item label { color: var(--orange-700); }
.login-error { color: var(--red-500); font-size: 12.5px; margin-top: 12px; text-align: left; }

/* ---------- Toast ---------- */
#toast-box { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--brown-700); border: 1px solid var(--border-light); color: #fff; padding: 11px 18px; border-radius: var(--radius-sm); font-size: 13.5px;
  box-shadow: 0 10px 28px rgba(58, 40, 24, 0.35); opacity: 0; transform: translateY(8px); transition: all 0.25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: linear-gradient(135deg, var(--green-700), var(--green-900)); border-color: rgba(47, 138, 77, 0.3); }
.toast-error { background: linear-gradient(135deg, #b3352f, #7a2420); border-color: rgba(179, 53, 47, 0.35); }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.search-input { max-width: 260px; }
.pass-fail-summary { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.mini-badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; }

@media (max-width: 900px) {
  #app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .sidebar .brand { display: none; }
  .nav-item { flex-shrink: 0; margin-bottom: 0; }
  .sidebar-footer { display: none; }
  .main { padding: 16px; }
  #map-view-container { flex-direction: column; height: auto; }
  #map-canvas { height: 420px; }
  .map-sidebar { width: 100%; max-height: 260px; }
}
