/* ตารางไฟจราจรรายพื้นที่ (includes/area-table.php) · ทรง Blueprint / Sai-River (sai-skin.css: ขอบ 0px, เส้นประเทคนิค, ฟอนต์ Kanit/Oswald) */
.at-sec {
  --at-ok: #0f6b4a; --at-ok-bg: rgba(15, 115, 80, .10);
  --at-warn: #8a5300; --at-warn-bg: rgba(180, 115, 0, .12);
  --at-bad: #b41824; --at-bad-bg: rgba(193, 18, 31, .09);
  --at-na: var(--s-dim, #685f52);
}
html[data-theme="dark"] .at-sec {
  --at-ok: #7be0a0; --at-ok-bg: rgba(121, 196, 125, .14);
  --at-warn: #f7c36a; --at-warn-bg: rgba(242, 180, 90, .15);
  --at-bad: #ff8575; --at-bad-bg: rgba(255, 107, 87, .15);
}
.at-sec [data-level="ok"]   { --c: var(--at-ok);   --c-bg: var(--at-ok-bg); }
.at-sec [data-level="warn"] { --c: var(--at-warn); --c-bg: var(--at-warn-bg); }
.at-sec [data-level="bad"]  { --c: var(--at-bad);  --c-bg: var(--at-bad-bg); }
.at-sec [data-level="na"]   { --c: var(--at-na);   --c-bg: transparent; }

.at-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.at-dot { display: inline-block; width: .68em; height: .68em; border-radius: 50%; background: var(--c, var(--at-na)); flex: none; }
.at-dot[data-level="warn"] { border-radius: 1px; transform: rotate(45deg) scale(.86); }
.at-dot[data-level="bad"]  { border-radius: 1px; }

/* กล่องสรุปภาพรวมแบบ Blueprint grid ด้านบนตาราง */
.at-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
  font: 500 .95rem/1.45 var(--f-head);
  color: var(--s-ink);
}
.at-sum-box {
  padding: 10px 14px;
  border: 1px solid var(--s-line);
  border-left: 3px solid var(--c, var(--s-acc));
  border-radius: 0;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
html[data-theme="dark"] .at-sum-box { background: rgba(16, 18, 56, .68); }
.at-sum-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  font: 600 .88rem/1.25 var(--f-head);
  color: var(--c, var(--s-ink));
}
.at-sum-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.at-sum-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--c) 32%, transparent);
  border-radius: 0;
  background: var(--c-bg);
  color: var(--s-ink);
  font: 500 .82rem/1.3 var(--f-head);
}
.at-sum-notes { list-style: none; margin: 6px 0 0; padding: 0; }
.at-sum-note { margin: 3px 0 0; font: 400 .82rem/1.4 var(--f-head); color: var(--s-muted); }
.at-sum-empty { margin: 0; padding: 10px 14px; border: 1px solid var(--s-line); background: var(--s-surface2); color: var(--s-muted); }

/* กล่อง Blueprint ครอบตาราง (ใช้เส้นขอบเดียว ไม่ซ้อนกรอบ) */
.at-card {
  padding: 0;
  border-top: 3px solid var(--s-acc);
  border-radius: 0;
}
.at-card > .bp-head {
  padding: 12px 16px 10px;
  margin: 0;
  border-bottom: 1px dashed var(--s-line);
}
.at-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 16px;
  background: var(--s-surface2);
  border-bottom: 1px solid var(--s-line);
}
.at-hint { margin: 0; font: 400 .84rem/1.4 var(--f-head); color: var(--s-muted); }
.at-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 0; font: 500 .82rem/1.2 var(--f-head); color: var(--s-ink2); }
.at-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--c); }

.at-wrap {
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}
.at-wrap:focus-visible { outline: 2px solid var(--s-acc); outline-offset: -2px; }

.at-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: .9rem;
  color: var(--s-ink);
}
.at-col-place { width: 22%; }

.at-table th, .at-table td {
  padding: 10px 6px;
  border-bottom: 1px dashed var(--s-line2);
  text-align: center;
  vertical-align: middle;
}
.at-table .at-place {
  text-align: left;
  padding: 10px 14px;
  border-right: 1px dashed var(--s-line);
}
.at-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--s-surface2);
  font: 600 .83rem/1.25 var(--f-head);
  color: var(--s-ink);
  border-bottom: 1px solid var(--s-line);
  white-space: nowrap;
}
.at-table thead .at-place { z-index: 2; background: var(--s-surface2); }

/* แถบจังหวัด */
.at-prov > * {
  border-top: 1px solid var(--s-line);
  border-bottom: 1px solid var(--s-line);
}
.at-prov .at-place {
  font: 600 .9rem/1.35 var(--f-head);
  color: var(--s-ink);
}
.at-prov-cnt {
  display: block;
  margin-top: 3px;
  font: 500 .74rem/1.1 var(--f-head);
  letter-spacing: .02em;
  color: var(--s-dim);
  font-variant-numeric: tabular-nums;
}

/* แถวอำเภอ */
/* แถบสีทั้งแถว + เส้นบน: เห็นชัดว่าอำเภอใหม่เริ่มตรงไหน ตำบลข้างใต้เป็นพื้นขาว (ผู้ใช้ 27 พ.ย. 2569) */
.at-amp th, .at-amp td {
  border-top: 1px solid var(--s-line);
  border-bottom: 1px solid var(--s-line);
}
.at-prov, .at-amp { --at-group-ink: var(--at-na); --at-group-tint: 7%; }
.at-prov { --at-group-tint: 13%; }
.at-sec .at-table :is(.at-prov, .at-amp) > * {
  background-color: color-mix(in srgb, var(--at-group-ink) var(--at-group-tint), var(--s-surface));
}
.at-amp .at-place { box-shadow: inset 3px 0 var(--at-group-ink); }
.at-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  padding: 4px 6px;
  margin: -4px -6px;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.at-amp-left { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.at-amp-name { font: 600 .92rem/1.25 var(--f-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-amp-cnt {
  flex: none;
  white-space: nowrap;
  padding: 2px 6px;
  border: 1px solid var(--s-line);
  border-radius: 0;
  background: var(--s-surface2);
  font: 500 .72rem/1.1 var(--f-head);
  color: var(--s-dim);
  font-variant-numeric: tabular-nums;
}
.at-chev { width: 7px; height: 7px; border-right: 2px solid var(--s-acc); border-bottom: 2px solid var(--s-acc); transform: rotate(-45deg); flex: none; }
.at-toggle[aria-expanded="true"] .at-chev { transform: rotate(45deg); }
.at-toggle:hover, .at-pick:hover { background: var(--s-acc-soft); }
.at-toggle:focus-visible, .at-pick:focus-visible { outline: 2px solid var(--s-acc); outline-offset: 1px; }

/* ป้ายสถานะทรง Blueprint เดียวกับ .qa-badge */
.at-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 0;
  border: 1px solid color-mix(in srgb, var(--c) 36%, transparent);
  background: var(--c-bg);
  color: var(--c);
  font: 600 .8rem/1.2 var(--f-head);
  white-space: nowrap;
}
.at-split { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%; }
.at-table :is(.at-prov, .at-amp) td[data-key] .at-badge {
  box-sizing: border-box;
  max-width: 100%;
  padding-inline: 5px;
  white-space: normal;
}
.at-table td[data-key="fish"] .at-badge { max-width: 100%; box-sizing: border-box; white-space: normal; overflow-wrap: break-word; }
.at-badge--sm { padding: 2px 6px; font-size: .74rem; }

/* แถวตำบล (กางออกเมื่อแตะอำเภอ) */
.at-tam { cursor: pointer; }
.at-tam th, .at-tam td { background: var(--s-surface2); border-bottom: 1px dashed var(--s-line2); }
.at-tam .at-place { padding-left: 30px; }
.at-pick {
  display: inline-flex;
  align-items: center;
  padding: 4px 6px;
  margin: -4px -6px;
  border: 0;
  border-radius: 0;
  background: none;
  font: 500 .88rem/1.3 var(--f-head);
  color: var(--s-acc2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.at-tam:hover th, .at-tam:hover td { background: var(--s-acc-soft); }
.at-tam.is-picked th { box-shadow: inset 3px 0 0 var(--s-acc); }

/* ท้ายการ์ดตาราง */
.at-foot {
  padding: 10px 16px;
  border-top: 1px dashed var(--s-line);
  background: var(--s-surface2);
}
.at-src { margin: 0; font: 400 .78rem/1.45 var(--f-head); color: var(--s-dim); }

.at-back {
  position: fixed; right: 16px; bottom: 74px; z-index: 60;
  padding: 9px 14px; border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
  background: var(--s-acc); color: var(--s-on-acc);
  font: 600 .9rem var(--f-head); text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.at-back:hover { background: var(--s-acc2); color: var(--s-on-acc); }
.at-back:focus-visible { outline: 2px solid var(--s-ink); outline-offset: 2px; }
.at-back[hidden] { display: none; }

@media (max-width: 900px) {
  .at-table { min-width: 740px; table-layout: auto; font-size: .86rem; }
  .at-col-place, .at-col-act { width: auto; }
  .at-table .at-place { position: sticky; left: 0; z-index: 1; min-width: 168px; background: var(--s-surface); }
  .at-table thead .at-place { z-index: 2; background: var(--s-surface2); }
  .at-tam .at-place { padding-left: 22px; background: var(--s-surface2); }
}
@media (max-width: 640px) {
  .at-summary { grid-template-columns: 1fr; }
  .at-card > .bp-head, .at-toolbar, .at-foot { padding-left: 12px; padding-right: 12px; }
  .at-table .at-place { min-width: 148px; padding-left: 12px; padding-right: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .at-chev { transition: transform .15s ease; }
  .at-tam th, .at-tam td { transition: background-color .15s ease; }
}

/* ช่องลำน้ำด้านหน้าตาราง (ผู้ใช้ 29 พ.ย. 2569): เส้นแม่น้ำกกต่อเนื่องจากต้นน้ำลงท้ายน้ำ จุดและช่วงกิโลเมตรข้างแต่ละตำบล
   เส้นวาดเป็นพื้นหลังของทุกเซลล์ในคอลัมน์นี้ จึงต่อกันไม่ขาดแม้อำเภอถูกพับ */
/* สีเดียวกับแม่น้ำกกในแผนที่ (map/3d.js ชั้น kok #00b3c7 ขอบขาว · ผู้ใช้ 29 พ.ย. 2569) · ตัวเลขใช้เฉดเข้มกว่าให้อ่านออกบนพื้นสว่าง */
.at-sec { --at-river: #00b3c7; --at-river-edge: #ffffff; --at-river-ink: #007584; --at-river-w: 92px; }
html[data-theme="dark"] .at-sec { --at-river-ink: #5ff3ff; }
.at-col-river { width: var(--at-river-w); }
/* .at-sec prefix: beats the row hover/background shorthands, which would otherwise wipe the river line */
.at-sec .at-table .at-river {
  padding: 0 6px 0 26px;
  text-align: left;
  border-bottom: 0;
  background-image: linear-gradient(90deg, transparent 9px, var(--at-river-edge) 9px, var(--at-river-edge) 11px, var(--at-river) 11px, var(--at-river) 17px, var(--at-river-edge) 17px, var(--at-river-edge) 19px, transparent 19px);
  background-repeat: no-repeat;
}
.at-sec .at-table thead .at-river-h { padding: 8px 6px 8px 26px; white-space: normal; background-color: var(--s-surface2); background-position: 0 60%; background-size: 100% 40%; }
.at-river-h span { display: block; font: 600 .8rem/1.2 var(--f-head); color: var(--at-river-ink); }
.at-river-h small { display: block; font: 400 .68rem/1.25 var(--f-head); color: var(--s-dim); }
.at-river--pt { position: relative; }
.at-river--pt::before { content: ""; position: absolute; left: 9px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--s-surface); border: 2px solid var(--at-river); box-sizing: border-box; }
.at-km { display: block; font: 600 .74rem/1.2 var(--f-head); color: var(--at-river-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.at-mouth td { padding: 6px 10px 10px; border-bottom: 0; text-align: left; font: 500 .78rem/1.3 var(--f-head); color: var(--s-dim); background: transparent; }
.at-sec .at-table .at-river--end { height: 34px; background-size: 100% calc(100% - 12px); }
.at-river--end::after { content: ""; display: block; position: relative; left: -21px; top: 11px; width: 0; height: 0; border: 8px solid transparent; border-top: 11px solid var(--at-river); }
.kr-matrix .at-tam[inert] .at-river--pt::before { opacity: 0; }
@media (max-width: 900px) {
  .at-sec { --at-river-w: 74px; }
  .at-sec .at-table .at-river { position: sticky; left: 0; z-index: 1; background-color: var(--s-surface); padding-left: 24px; }
  .at-sec .at-table .at-river--pt { background-color: var(--s-surface2); }
  .at-sec .at-table thead .at-river-h { z-index: 3; padding-left: 24px; }
  .at-table .at-place { left: var(--at-river-w); }
  .at-km { font-size: .7rem; }
  .at-km-u { display: none; }   /* phones: numbers only, the column header already says กม. */
}

