:root {
  --blue: #0d47a1;
  --blue-2: #1565c0;
  --ink: #1d2733;
  --muted: #5b6672;
  --line: #dde2e8;
  --soft: #f3f6fa;
  --panel: #ffffff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(16, 32, 64, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Kanit", system-ui, sans-serif; font-weight: 300; color: var(--ink); background: var(--soft);
  display: grid; grid-template-rows: auto 1fr auto; height: 100vh; height: 100dvh;
}
button, input, select { font: inherit; }
.hidden { display: none !important; }

/* header like the Treasury site: blue bar, emblem, system name */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, var(--blue), var(--blue-2)); color: #fff; padding: 8px 16px; min-height: 56px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2); z-index: 1100;  /* above the map's controls (1000): the user menu opens over them */
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { flex: none; display: block; }
.title { font-weight: 500; font-size: 18px; line-height: 1.2; }
.subtitle { font-size: 13px; opacity: .85; }
/* the user icon and menu, measured on the Treasury D-Value site 2026-10-03: a 27 px yellow circle (255,210,31) with the
   user's initial in blue (10,88,202), 16 px; its menu white, radius 6 px, at least 160 px wide, items with a bullet */
.user { position: relative; display: flex; align-items: center; }
.avatar {
  width: 27px; height: 27px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: rgb(255, 210, 31); color: rgb(10, 88, 202); font-size: 16px; font-weight: 400; line-height: 27px; text-align: center;
}
.avatar:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.usermenu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1300; min-width: 160px; background: #fff; color: rgb(57, 57, 57);
  border-radius: 6px; padding: 6px 0; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); font-size: 16px;
}
.usermenu-head { padding: 6px 14px 8px; font-weight: 400; border-bottom: 1px solid var(--line); margin-bottom: 4px; white-space: nowrap; }
.usermenu-head small { display: block; color: var(--muted); font-size: 13px; }
.usermenu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: rgb(57, 57, 57); padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.usermenu button:hover, .usermenu button:focus-visible { background: var(--soft); outline: 0; }

main { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #2b3138; }

/* left search panel (desktop) / bottom sheet (mobile) */
.panel {
  position: absolute; z-index: 800; left: 12px; top: 12px; width: 380px; max-height: calc(100% - 24px);
  overflow: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.tabs { display: flex; background: var(--soft); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 400; }
.tab.active { background: #fff; color: var(--blue); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
form.mode label, .login label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
form.mode select, form.mode input, .login input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.primary { width: 100%; border: 0; border-radius: 8px; padding: 11px; background: var(--blue); color: #fff; font-weight: 400; cursor: pointer; }
.primary:disabled { opacity: .6; cursor: progress; }
.secondary { width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fff; color: var(--muted); cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* result card */
.result { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.badge {
  display: inline-block; font-weight: 500; font-size: 16px; color: #fff; background: var(--c, var(--muted));
  border-radius: 8px; padding: 6px 12px; margin-bottom: 8px;
}
.basis { font-size: 12px; color: var(--muted); margin: -2px 0 8px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 6px 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 400; }
/* The panel sits where the Treasury D-Value site's does, for farmers and officers alike (D-6; its own CSS, read
   2026-10-03; owner: "หน้าค้นหา คุณทำผิด รูปแบบเดิมอีก แก้"): from 1024 px a left panel 464 px wide, 20 px from the
   edges, corners 15 px; under 1024 px a sheet over the lower half (below). A result takes the form's place, under a
   bar with a way back. */
.dvsite .panel { left: 20px; top: 20px; bottom: 20px; width: 464px; max-height: none; border-radius: 15px; padding: 16px; }
.dvsite .panel.showing .tabs, .dvsite .panel.showing .mode { display: none; }
.dvsite .panel.showing .result { margin-top: 0; border-top: 0; padding-top: 0; }
.dv-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: #002183; font-size: 16px; }
.dv-bar b { font-weight: 600; }
.dv-bar span { margin-left: auto; font-size: 14px; color: #757575; }
.dv-bar button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: #ebf6ff; color: #0070e8; font-size: 18px; cursor: pointer; }
/* a result, shown the way the Treasury D-Value site shows a parcel (D-6); colours measured on that site. Officers get
   the same card, with the parcel's notices and payments under it (.dv-fees). */
.card.dv { border: 2px solid rgba(26, 112, 241, .91); background: rgba(26, 112, 241, .027); }
.dv-sheet { color: #002183; font-size: 16px; font-weight: 400; margin-top: 6px; }
.dv-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.dv-pair, .dv-price { font-size: 15px; color: #757575; }
.dv-pair b, .dv-row b, .dv-prov { color: #393939; font-weight: 600; }
.dv-price b { color: #fe8218; font-weight: 600; }
.dv-cut { height: 2px; margin: 10px 0 8px; background: repeating-linear-gradient(90deg, #7fb2f0 0 16px, transparent 16px 24px, #f2a0a0 24px 40px, transparent 40px 48px); }
.dv-title { color: #294b9d; font-weight: 600; font-size: 15px; }
.dv-prov { font-size: 15px; }
.dv-sub { color: #757575; font-size: 14px; }
.dv-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 1px 0; }
.dv-row span { color: #757575; flex: none; max-width: 58%; }
.dv-row b { text-align: right; }
.dv hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.dv-two { display: block; font-size: 12px; font-weight: 400; color: #b45f06; }   /* the second source's value, where they differ */
.dv-pin div {
  position: absolute; transform: translate(-50%, -115%); background: #fff; border: 3px solid #1a70f1; border-radius: 22px;
  padding: 3px 12px; text-align: center; line-height: 1.2; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.dv-pin div::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: #1a70f1; }
.dv-pin b { display: block; color: #002183; font-weight: 500; font-size: 14px; }
.dv-pin span { display: block; color: #393939; font-weight: 600; font-size: 13px; }
.contact { background: var(--soft); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-top: 8px; }
.contact span { display: block; color: var(--muted); font-size: 12px; }
.legal { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.busy { color: var(--muted); font-size: 14px; }
.dv-fees { margin-top: 10px; }
.dv-fees h3 { font-size: 15px; font-weight: 600; color: #294b9d; margin: 0 0 4px; }
.dv-fees .card { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 8px 0 0; margin: 0; background: none; }
.dv-pick { display: block; width: 100%; text-align: left; border: 2px solid rgba(26, 112, 241, .91); background: rgba(26, 112, 241, .027);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font: inherit; color: #002183; cursor: pointer; }

/* back office details */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; font-size: 13px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 400; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
.warn { color: #b3261e; font-weight: 500; }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 14px; background: var(--soft); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
.sum b { font-weight: 500; text-align: right; }
.note { font-size: 12px; color: var(--muted); }

/* right tool column */
.lc-tools a { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: var(--ink); }
.zone-label { color: #ffe066; font-weight: 500; font-size: 13px; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; }

/* bottom bar: coordinates and the legal notice */
.statusbar {
  display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: #dfe6ee; background: #1b2633;
  padding: 4px 12px; white-space: nowrap; overflow: hidden;
}
.statusbar .notice { overflow: hidden; text-overflow: ellipsis; }

/* login */
/* the login card, as the Treasury D-Value site's (measured 2026-10-03): labels 16 px (57,57,57) with a red *, fields
   44 px with an icon, the button (0,61,153) 50 px high with fully round ends, white 16 px text */
.login-wrap { position: absolute; inset: 0; z-index: 1200; display: grid; place-items: center; background: rgba(15, 25, 40, .55); }
.login { width: min(420px, calc(100% - 32px)); background: #fff; border-radius: 16px; padding: 28px 28px 22px; box-shadow: var(--shadow); color: rgb(57, 57, 57); }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-lock { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: rgb(0, 61, 153); color: #fff; }
.login h2 { margin: 0; font-weight: 500; font-size: 20px; color: rgb(0, 61, 153); }
.login-head p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.login .flabel { display: block; font-size: 16px; color: rgb(57, 57, 57); margin: 0 0 6px; }
.login .req { color: #d32f2f; }
.login .field {
  display: flex; align-items: center; gap: 8px; height: 44px; margin-bottom: 14px; padding: 0 10px;
  border: 1px solid #cfd6df; border-radius: 8px; background: #fff; color: #8a94a0;
}
.login .field:focus-within { border-color: rgb(0, 61, 153); box-shadow: 0 0 0 3px rgba(0, 61, 153, .12); }
.login .field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0; font-size: 16px; color: #000; background: transparent; }
.login .eye { border: 0; background: none; color: #8a94a0; cursor: pointer; padding: 4px; display: grid; place-items: center; }
.login .eye[aria-pressed="true"] { color: rgb(0, 61, 153); }
.login-btn { width: 100%; height: 50px; border: 0; border-radius: 50px; background: rgb(0, 61, 153); color: #fff; font-size: 16px; font-weight: 400; cursor: pointer; }
.login-cancel { width: 100%; height: 44px; margin-top: 10px; border: 1px solid rgb(0, 61, 153); border-radius: 50px; background: #fff; color: rgb(0, 61, 153); font-size: 16px; cursor: pointer; }
.error { color: #b3261e; font-size: 14px; min-height: 1.2em; margin: 4px 0 8px; }

.leaflet-container { font-family: inherit; }
.toast {
  position: absolute; z-index: 1100; left: 50%; top: 12px; transform: translateX(-50%); background: #1b2633; color: #fff;
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}

/* ---------- back office (after an officer's login) ---------- */
.officenav { display: flex; gap: 4px; margin: 0 auto; }
.officenav button { background: transparent; color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 400; opacity: .88; white-space: nowrap; }
.officenav button:hover { background: rgba(255, 255, 255, .14); opacity: 1; }
.officenav button.on { background: #fff; color: var(--blue); opacity: 1; }

/* the React root of the back office (office/office.js); it stays hidden, its panel sits beside the map */
.office { display: none; }
.unitsel { font-size: 13px; color: var(--muted); }

/* the layer list of a follow-up map, like QGIS's Layers panel */
.lc-legend { background: #fff; border-radius: 8px; box-shadow: 0 1px 6px rgba(0, 0, 0, .35); font-size: 13px; width: 250px; }
.lc-legend .lg-title { display: block; width: 100%; text-align: left; border: 0; background: var(--soft); border-radius: 8px 8px 0 0; padding: 6px 10px; font: inherit; font-weight: 500; cursor: pointer; }
.lc-legend.closed .lg-body { display: none; }
.lc-legend.closed .lg-title { border-radius: 8px; }
.lg-body { padding: 6px 10px 8px; }
.lg-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; cursor: pointer; }
.lg-sub { padding-left: 12px; }
.lg-group { margin: 6px 0 2px; color: var(--muted); font-size: 12px; }
.lg-n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-foot { margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.sw { display: inline-block; width: 14px; height: 14px; border: 1.5px solid; border-radius: 2px; flex: none; }
.sw-line { border: 0; border-top: 3px solid #ffd400; height: 0; width: 16px; }

/* a parcel's record, in the panel: a notice or a payment per row, read down with no sideways scroll (owner 2026-10-03:
   "ให้คนอ่านลำบาก เลื่อน scroll อ่าน") */
.rec-h { font-size: 13px; font-weight: 400; color: var(--muted); margin: 12px 0 2px; }
.rec-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.rec-list li { padding: 6px 0; border-top: 1px solid var(--line); }
.rec-top { display: flex; justify-content: space-between; gap: 8px; }
.rec-top b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-sub { font-size: 13px; color: var(--muted); }


@media (max-width: 1023px) {
  .dvsite .panel { left: 0; right: 0; top: 50%; bottom: 0; width: auto; border-radius: 15px 15px 0 0; padding: 8px 14px 14px; }
  .dvsite .panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 8px; }
  .dvsite .leaflet-control-zoom, .dvsite .leaflet-control-scale { display: none; }  /* the sheet covers them */
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .brand { flex: 1 1 0; }  /* the name wraps, so the user icon stays at the right of the first row */
  .officenav { order: 3; width: 100%; overflow-x: auto; margin: 0; }
  .office { padding: 12px; }
  .lc-legend { width: 210px; }
  .title { font-size: 16px; }
  .subtitle { font-size: 12px; }
  .panel {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 58%;
    border-radius: 16px 16px 0 0; padding: 10px 14px 14px;
  }
  .panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 8px; }
  .statusbar .notice { display: none; }
  .user span { display: none; }
  .leaflet-control-zoom, .leaflet-control-scale { display: none; }  /* pinch to zoom; the bottom sheet covers them */
}
