/* ---------- โทเค็น ---------- */
:root {
  --brand: #4c1d95;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --soft: #f9fafb;
  --s-new: #f97316;
  --s-doing: #3b82f6;
  --s-done: #22c55e;
  --urgent: #ef4444;
  --cta: linear-gradient(90deg, #ef4444, #f97316);
  --shadow: 0 10px 30px rgba(17, 24, 39, .12), 0 2px 6px rgba(17, 24, 39, .06);
  --radius: 18px;
  --panel-w: 380px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "IBM Plex Sans Thai", "Sarabun", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; min-height: 40px;
}
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
button.small { min-height: 34px; padding: 4px 12px; }
button:disabled { opacity: .6; cursor: wait; }

#map { position: fixed; inset: 0; z-index: 0; background: #e8e8e8; }

/* ---------- ปุ่มบนแผนที่ ---------- */
.map-top {
  position: fixed; top: 14px; left: calc(var(--panel-w) + 32px); right: 70px; z-index: 400;
  display: flex; gap: 8px; align-items: center; pointer-events: none; flex-wrap: wrap;
}
.map-summary { display: flex; gap: 8px; }
.ms-item, .mode-pill {
  background: var(--card); border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow);
  font-size: 14px; white-space: nowrap;
}
.ms-item b { margin-left: 2px; }
.ms-item.urgent { background: var(--urgent); color: #fff; }
.mode-pill { color: var(--muted); font-size: 12px; padding: 5px 12px; }
.fab { display: none; }

.leaflet-top.leaflet-right { margin-top: 4px; }
.leaflet-bar, .leaflet-control-layers { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a { width: 38px !important; height: 38px !important; line-height: 38px !important; }
.locate-btn { display: block; width: 38px; height: 38px; line-height: 38px; text-align: center; background: #fff; color: #333; font-size: 20px; text-decoration: none; }

/* ---------- แผงด้านซ้าย ---------- */
.panel {
  position: fixed; z-index: 500; top: 14px; left: 14px; bottom: 14px; width: var(--panel-w);
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel-handle { display: none; }
.panel-top { padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line); }
.brand-row { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none;
  background: linear-gradient(135deg, #7c3aed, #4c1d95); color: #fff;
}
.brand-text { flex: 1; min-width: 0; }
.brand-text h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.brand-text small { color: var(--muted); font-size: 13px; }
.icon-btn { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 12px; font-size: 18px; }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px;
}
.search input { border: 0; background: transparent; padding: 10px 0; width: 100%; outline: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 4px; min-height: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
}
.stat b { font-size: 24px; line-height: 1.2; color: var(--c); }
.stat span { font-size: 12px; color: var(--muted); }
.stat.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); box-shadow: inset 0 0 0 1px var(--c); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border-radius: 999px; min-height: 32px; padding: 4px 12px; font-size: 14px; flex: none;
  background: var(--soft);
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.sort-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); }
.sort { display: flex; gap: 4px; }
.sort button { min-height: 28px; padding: 2px 10px; border-radius: 999px; font-size: 13px; border-color: transparent; background: transparent; color: var(--muted); }
.sort button.on { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

.job-list { list-style: none; margin: 0; padding: 10px 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; background: var(--soft); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: #c7d2fe; }
.card.active { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tag { font-size: 12px; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 2px 8px; }
.pill {
  font-size: 12px; border-radius: 999px; padding: 2px 8px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white);
}
.pill::before { content: "● "; font-size: 9px; vertical-align: 1px; }
.pill.urgent { --c: var(--urgent); }
.card h4 { margin: 0; font-size: 15px; line-height: 1.35; }
.card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.card-actions .att-count { flex: 1; font-size: 13px; color: var(--muted); }
.card-actions .link {
  min-height: 30px; padding: 2px 10px; font-size: 13px; border-radius: 999px; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); display: inline-flex; align-items: center;
}
.job-list .empty { color: var(--muted); text-align: center; padding: 24px; }

.panel-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.cta, .fab {
  width: 100%; min-height: 48px; border: 0; border-radius: 14px; color: #fff; font-weight: 700; font-size: 16px;
  background: var(--cta); box-shadow: 0 8px 20px rgba(239, 68, 68, .3);
}

/* ---------- หมุด ---------- */
.pin {
  width: 36px; height: 36px; border-radius: 50%; background: var(--c);
  border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.3);
  display: grid; place-items: center; font-size: 16px; position: relative;
}
.pin span { line-height: 1; }
.pin.urgent::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 3px solid var(--urgent);
  animation: pulse 1.6s ease-out infinite;
}
.pin.active { transform: scale(1.2); }
@keyframes pulse { from { opacity: .9; transform: scale(.8); } to { opacity: 0; transform: scale(1.4); } }
.pick-pin { --c: var(--brand); }

/* ---------- ป็อปอัปสีเข้ม ---------- */
.dark-pop .leaflet-popup-content-wrapper { background: #111827; color: #f3f4f6; border-radius: 20px; padding: 0; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,.35); }
.dark-pop .leaflet-popup-content { margin: 0; width: 290px !important; font-family: inherit; font-size: 14px; line-height: 1.45; }
.dark-pop .leaflet-popup-tip { background: #111827; }
.dark-pop a.leaflet-popup-close-button {
  top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 18px; line-height: 26px; text-align: center; z-index: 2;
}
.pc-media { position: relative; height: 150px; background: #1f2937; }
.pc-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-media.empty { height: 96px; display: grid; place-items: center; background: linear-gradient(135deg, #312e81, #1f2937); }
.pc-ph { font-size: 38px; opacity: .8; }
.pc-type {
  position: absolute; left: 10px; top: 10px; background: #2563eb; color: #fff; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.pc-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.pc-body h3 { margin: 0; font-size: 16px; color: #fff; }
.pc-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pc-meta .pill { background: color-mix(in srgb, var(--c) 25%, #111827); color: color-mix(in srgb, var(--c) 60%, white); }
.pc-date { font-size: 12px; color: #9ca3af; }
.pc-detail { margin: 0; color: #d1d5db; }
.pc-row { color: #d1d5db; font-size: 13px; }
.pc-row a { color: #93c5fd; }
.pc-coord { color: #9ca3af; font-size: 12px; }
.pc-main, .pc-two { display: flex; gap: 6px; }
.pc-main { margin-top: 6px; }
.pc-btn {
  flex: 1; min-height: 38px; border-radius: 12px; border: 1px solid #374151; background: #1f2937; color: #f3f4f6 !important;
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; text-decoration: none; padding: 4px 10px;
}
.pc-btn.sq { flex: 0 0 48px; }
.pc-btn.sq b { font-size: 12px; }
.pc-btn.blue { background: #2563eb; border-color: #2563eb; }
.dark-pop .att-strip { margin: 4px 0 0; }
.dark-pop .att-thumb { border-color: #374151; background: #1f2937; color: #d1d5db; }
.dark-pop .att-more { background: #1f2937; border-color: #374151; color: #fff; }

/* ---------- มือถือ ---------- */
@media (max-width: 760px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 78%;
    border-radius: 22px 22px 0 0; transition: transform .25s;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.collapsed { transform: translateY(calc(100% - 186px)); }
  .panel.collapsed .panel-foot { display: none; }
  .panel-handle {
    display: flex; justify-content: center; align-items: center; border: 0; background: transparent;
    min-height: 20px; padding: 8px 0 0; flex: none;
  }
  .panel-handle span { width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
  .panel-top { padding-top: 6px; gap: 10px; }
  .map-top { left: 12px; right: 60px; top: 12px; }
  .mode-pill { display: none; }
  .fab {
    display: block; position: fixed; z-index: 450; right: 12px; width: auto; min-height: 44px; padding: 0 18px;
    bottom: 196px; font-size: 15px;
  }
  .panel:not(.collapsed) ~ .fab, body:has(.panel:not(.collapsed)) .fab { display: none; }
}

/* dialog */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px); background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(20,10,30,.5); }
dialog form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0 0 4px; font-size: 19px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); flex: 1; min-width: 0; }
dialog input, dialog select, dialog textarea {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%;
}
dialog .row { display: flex; gap: 10px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 0 0; padding: 0; }
fieldset.loc { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
fieldset.loc legend { font-size: 14px; color: var(--muted); padding: 0 4px; }
.loc-row { display: flex; gap: 8px; }
.loc-row button { flex: 1; }
.hint { color: var(--muted); }
.form-error { color: var(--s-new); margin: 0; }
.status-choices { display: flex; gap: 8px; }
.status-choices label {
  flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 6px; color: var(--ink); cursor: pointer;
}
.status-choices input { width: auto; }
.status-choices label:has(input:checked) { border-color: currentColor; font-weight: 700; }

.pick-banner {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  background: var(--card); color: var(--ink); border-radius: 12px; padding: 8px 10px; z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); display: flex; gap: 8px; align-items: center; white-space: nowrap;
}
.pick-banner[hidden] { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }

/* ไฟล์แนบ */
.att-strip { display: flex; gap: 4px; margin: 6px 0 2px; }
.att-thumb {
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  border-radius: 8px; background: #eee; border: 1px solid #ddd; text-decoration: none; color: #444; flex: none;
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-thumb.sm { width: 52px; height: 52px; }
.att-thumb.lg { width: 100%; aspect-ratio: 1; }
.att-doc { display: flex; flex-direction: column; align-items: center; font-size: 22px; line-height: 1.1; }
.att-doc small { font-size: 11px; }
.att-more { width: 52px; height: 52px; min-height: 0; padding: 0; border-radius: 8px; font-weight: 700; }
.kind-row { display: flex; gap: 8px; flex-wrap: wrap; }
dialog .kind-row label {
  flex-direction: row; align-items: center; gap: 6px; flex: 0 1 auto; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
dialog .kind-row input { width: auto; }
dialog .kind-row label:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.att-pick { display: flex; flex-direction: column; gap: 8px; }
dialog label.file-btn {
  flex: 1; flex-direction: row; justify-content: center; align-items: center; min-height: 44px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); cursor: pointer; font-size: 15px;
}
dialog label.file-btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
dialog label.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.busy { opacity: .5; pointer-events: none; }
.att-list section h3 { font-size: 15px; margin: 10px 0 6px; }
.att-list section h3 small { color: var(--muted); font-weight: 400; }
.att-list .hint { margin: 0; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.att-cell { position: relative; }
.att-del {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; min-height: 0; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; font-size: 18px; line-height: 1;
}
#statusFiles { padding: 6px; }

/* ---------- โลโก้ / มาสคอต ---------- */
.logo { background: #ede9fe; padding: 3px; }
.logo svg { width: 100%; height: 100%; }
.mascot {
  position: fixed; z-index: 420; left: calc(var(--panel-w) + 30px); bottom: 26px;
  display: flex; align-items: flex-end; gap: 6px; cursor: pointer; max-width: 340px;
}
.mascot-art { width: 72px; height: 78px; flex: none; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 6px 8px rgba(0,0,0,.2)); order: 0; }
.mascot-art svg { width: 100%; height: 100%; }
.bubble {
  order: 1; background: var(--card); border-radius: 16px 16px 16px 4px; padding: 8px 12px; font-size: 13px;
  box-shadow: var(--shadow); margin-bottom: 44px; max-width: 240px;
}
.bubble:empty { display: none; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---------- สภาพอากาศ ---------- */
.weather { position: fixed; z-index: 420; right: 14px; bottom: 30px; }
.weather[hidden] { display: none; }
.wx-chip {
  display: none; border: 0; border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  font-weight: 700; padding: 6px 14px; min-height: 38px;
}
.weather.min .wx-chip { display: inline-flex; align-items: center; gap: 4px; }
.weather.min .wx-card { display: none; }
.wx-card {
  width: 236px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-radius: 20px; box-shadow: var(--shadow);
  padding: 12px 14px 14px; text-align: center;
}
.wx-head { display: flex; justify-content: space-between; align-items: center; }
.live { font-size: 11px; color: #16a34a; background: #dcfce7; border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.wx-x { min-height: 0; width: 26px; height: 26px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }
.wx-card h3 { margin: 8px 0 0; font-size: 15px; }
.wx-main { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 4px 0 0; }
.wx-main span { font-size: 40px; }
.wx-main b { font-size: 38px; font-weight: 700; }
.wx-desc { color: var(--muted); font-size: 13px; }
.wx-aqi {
  display: flex; align-items: center; gap: 6px; margin: 10px 0; padding: 8px 10px; background: var(--soft);
  border-radius: 12px; font-size: 13px; text-align: left;
}
.wx-aqi .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.wx-aqi .uv { margin-left: auto; color: #b45309; font-weight: 600; white-space: nowrap; }
.wx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.wx-grid div { display: flex; flex-direction: column; align-items: center; }
.wx-grid b { font-size: 13px; }
.wx-grid small { color: var(--muted); font-size: 11px; }

@media (max-width: 1100px) { .mascot .bubble { display: none; } }
@media (max-width: 760px) {
  .mascot { display: none; }
  .logo { width: 44px; height: 44px; }
  .weather { top: 60px; left: 12px; right: auto; bottom: auto; }
  .leaflet-control-zoom { display: none; }
  body.pop-open .fab { display: none; }
  .pc-media { height: 110px; }
  .wx-card { width: min(236px, calc(100vw - 24px)); }
}

/* ---------- ปุ่มเพิ่มเติม ---------- */
.brand-row .icon-btn { flex: none; }
.install-btn { width: 100%; margin-top: 8px; min-height: 36px; border-radius: 12px; font-size: 14px; background: var(--soft); }
.install-btn[hidden] { display: none; }
.addr-suggest { margin-top: -4px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.addr-suggest[hidden] { display: none; }
.link-btn { min-height: 0; padding: 2px 8px; font-size: 13px; border-radius: 999px; margin-left: 4px; background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

/* ---------- dialog กว้าง (รายละเอียด / สรุป) ---------- */
dialog.wide { width: min(640px, calc(100vw - 24px)); }
.dlg-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.dlg-body h2 { margin: 0; font-size: 19px; padding-right: 36px; }
.dlg-x { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; min-height: 0; padding: 0; border-radius: 50%; font-size: 20px; line-height: 1; }
h3.sec { margin: 10px 0 0; font-size: 15px; }
.detail-actions, .share-row { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-actions button, .share-row button { min-height: 36px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.line-btn { background: #06c755 !important; border-color: #06c755 !important; color: #fff; font-weight: 700; }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }
.sm-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); margin-top: 8px; }
.note-form { display: flex; gap: 8px; align-items: stretch; }
.note-form textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); resize: vertical; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .h-ico { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; flex: none; }
.timeline span { color: var(--ink); }
.timeline small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- กล่องถาม ---------- */
dialog.ask { width: min(400px, calc(100vw - 32px)); }
dialog.ask p { margin: 0; color: var(--muted); line-height: 1.5; }
#askInput[hidden] { display: none; }
button.danger { background: var(--urgent) !important; border-color: var(--urgent) !important; color: #fff; }

/* ---------- สรุปงาน ---------- */
.seg { display: inline-flex; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 3px; align-self: flex-start; }
.seg button { min-height: 32px; border: 0; background: transparent; border-radius: 9px; padding: 2px 14px; font-size: 14px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.dtiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dtile { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.dtile span { font-size: 13px; color: var(--muted); }
.dtile b { font-size: 24px; line-height: 1.3; }
.dtile small { font-size: 12px; color: var(--muted); }
.chart { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; cursor: default; }
.bar-col .bar { background: #6d28d9; border-radius: 4px 4px 0 0; min-width: 2px; }
.bar-col:hover .bar { background: #4c1d95; }
.bar-col small { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.axis-note { margin-top: 24px; font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.hrow { display: grid; grid-template-columns: 120px 1fr 32px; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.hl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htrack { display: flex; gap: 2px; height: 16px; }
.hseg { height: 100%; border-radius: 0; min-width: 4px; }
.hseg:last-child { border-radius: 0 4px 4px 0; }
.hv { text-align: right; }
.tech-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tech-table th, .tech-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tech-table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.tech-table td:not(:first-child), .tech-table th:not(:first-child) { text-align: right; }
.chart-tip { position: fixed; z-index: 3000; background: #111827; color: #fff; font-size: 13px; padding: 5px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap; }
.chart-tip[hidden] { display: none; }
@media (max-width: 560px) {
  .dtiles { grid-template-columns: repeat(2, 1fr); }
  .hrow { grid-template-columns: 92px 1fr 28px; }
  .note-form { flex-direction: column; }
}
dialog .note-form { padding: 0; flex-direction: row; }
dialog .note-form button { flex: none; }
@media (max-width: 560px) { dialog .note-form { flex-direction: column; } }

#causeOtherWrap[hidden] { display: none; }
#causeHint:empty { display: none; }
.hrow.wide-label { grid-template-columns: 190px 1fr 32px; }
.hseg.single { background: #6d28d9; border-radius: 0 4px 4px 0; }
@media (max-width: 560px) { .hrow.wide-label { grid-template-columns: 120px 1fr 28px; } }

/* ค้นหาทะเบียนมิเตอร์ */
.ca-row { display: flex; gap: 8px; }
.ca-row input { flex: 1; min-width: 0; margin-top: 0; }
.ca-row button { flex: none; white-space: nowrap; }
.meter-info { margin-top: -4px; padding: 10px 12px; border-radius: 12px; background: #f0f9ff; border: 1px solid #bae6fd; font-size: 13px; line-height: 1.55; color: #0c4a6e; }
.meter-info[hidden] { display: none; }
.meter-info b { color: #082f49; }
.meter-info .warn { color: #b45309; }
.meter-info .err { color: #b91c1c; }
.meter-info .pick { display: block; width: 100%; text-align: left; margin-top: 6px; min-height: 0; padding: 6px 10px; font-size: 13px; }
