/* Part A program screens (slides A1–A17): light glass UI over a full-screen map */
body.a-app {
  --a-teal: #0f8f88;
  --a-teal-dark: #0b6f6a;
  --a-teal-soft: #e3f5f2;
  --a-ink: #10302e;
  --a-muted: #5d7472;
  --a-line: #dcebe8;
  --a-card: rgba(255, 255, 255, 0.94);
  --a-shadow: 0 6px 24px rgba(16, 60, 56, 0.12);
  --a-good: #22c55e;
  --a-mod: #f59e0b;
  --a-high: #ef4444;
  --a-header-h: 84px;
  margin: 0;
  background: #e9f6f3;
  color: var(--a-ink);
  font-family: 'IBM Plex Sans Thai', 'Kanit', sans-serif;
}
body.a-app.a-full { height: 100vh; overflow: hidden; }

/* ---------- A1 header ---------- */
.a-header { height: var(--a-header-h); display: flex; align-items: center; gap: 1.25rem; padding: 0 1.25rem; background: #fff; box-shadow: 0 2px 12px rgba(16, 60, 56, 0.08); position: relative; z-index: 20; }
.a-brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--a-ink); flex-shrink: 0; }
.a-brand b { display: block; font-family: 'Kanit', sans-serif; font-size: 1.55rem; line-height: 1; color: #134e4a; letter-spacing: 0.5px; }
.a-brand small { display: block; font-size: 0.62rem; font-weight: 700; line-height: 1.2; color: #134e4a; margin-top: 2px; }
.a-menu { display: flex; gap: 0.35rem; flex: 1; justify-content: center; min-width: 0; }
.a-menu a { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.1rem; border-radius: 999px; text-decoration: none; color: var(--a-ink); font-family: 'Kanit', sans-serif; font-size: 1rem; white-space: nowrap; }
.a-menu a:hover { background: var(--a-teal-soft); }
.a-menu a.active { background: var(--a-teal-dark); color: #fff; box-shadow: 0 4px 12px rgba(11, 111, 106, 0.35); }
.a-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.a-update-pill { display: flex; align-items: center; gap: 0.45rem; border: 0; border-radius: 999px; padding: 0.55rem 1rem; background: linear-gradient(90deg, #0f8f88, #14b8a6); color: #fff; font: 600 0.85rem 'IBM Plex Sans Thai', sans-serif; cursor: pointer; white-space: nowrap; }
.a-datetime { display: flex; align-items: center; gap: 0.5rem; border: 0; border-left: 1px solid var(--a-line); background: none; padding: 0 0.6rem 0 0.9rem; color: var(--a-ink); cursor: pointer; text-align: left; }
.a-datetime small { display: block; font-size: 0.78rem; }
.a-datetime b { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 1.15rem; }
.a-icon-btn { position: relative; border: 0; background: none; color: var(--a-ink); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.a-icon-btn:hover { background: var(--a-teal-soft); }
.a-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--a-high); }
@media (max-width: 1280px) { .a-menu a span, .a-update-pill { font-size: 0.8rem; } .a-brand small { display: none; } }
@media (max-width: 1080px) { .a-menu a span { display: none; } .a-update-pill { display: none; } }

/* ---------- full-screen map stage ---------- */
.a-stage { position: relative; height: calc(100vh - var(--a-header-h)); }
.a-map { position: absolute !important; inset: 0; }
.a-card { background: var(--a-card); border-radius: 18px; box-shadow: var(--a-shadow); backdrop-filter: blur(6px); }
.a-float { position: absolute; z-index: 5; }

/* left floating column */
.a-left { top: 18px; left: 18px; width: 380px; max-height: calc(100% - 110px); overflow: auto; display: flex; flex-direction: column; gap: 12px; padding-bottom: 4px; }
.a-panel { padding: 0.9rem 1rem; }
.a-panel > summary { list-style: none; display: flex; align-items: center; gap: 0.6rem; cursor: pointer; font-family: 'Kanit', sans-serif; font-size: 1.15rem; font-weight: 600; }
.a-panel > summary::-webkit-details-marker { display: none; }
.a-panel > summary .a-chev { margin-left: auto; transition: transform 0.2s; }
.a-panel[open] > summary .a-chev { transform: rotate(180deg); }
.a-search { display: flex; align-items: center; gap: 0.5rem; background: #fff; border: 1px solid var(--a-line); border-radius: 999px; padding: 0.5rem 0.9rem; margin: 0.75rem 0 0.6rem; }
.a-search input { border: 0; outline: 0; flex: 1; font: inherit; background: none; color: var(--a-ink); }
.a-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.a-chip { border: 1px solid var(--a-line); background: #fff; color: var(--a-ink); border-radius: 999px; padding: 0.3rem 0.8rem; font: 500 0.82rem 'IBM Plex Sans Thai', sans-serif; cursor: pointer; display: inline-flex; align-items: center; gap: 0.35rem; }
.a-chip.active { background: var(--a-teal-dark); border-color: var(--a-teal-dark); color: #fff; }
.a-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.a-sensor { border: 1px solid var(--a-line); border-radius: 14px; padding: 0.65rem 0.8rem; margin-top: 0.55rem; background: #fff; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.5rem; font-size: 0.82rem; }
.a-sensor.selected { border-color: var(--a-teal); box-shadow: 0 0 0 2px rgba(15, 143, 136, 0.25); background: #f3fbfa; }
.a-sensor strong { font-size: 0.98rem; }
.a-sensor .a-meta { color: var(--a-muted); }
.a-sensor .a-status { width: 11px; height: 11px; border-radius: 50%; justify-self: end; align-self: center; }
.a-sensor .a-tools { grid-row: 2 / span 2; grid-column: 2; display: flex; gap: 0.3rem; align-self: end; }
.a-mini-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--a-line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--a-ink); }
.a-badge { display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px; background: var(--a-teal-soft); color: var(--a-teal-dark); font: 600 0.85rem 'IBM Plex Mono', monospace; }
.a-aermod { border: 2px solid #9fdcd3; }
.a-status-list { background: #f1faf8; border-radius: 12px; padding: 0.55rem 0.8rem; margin: 0.6rem 0; font-size: 0.85rem; line-height: 1.8; }
.a-status-list li, .a-bullets li { list-style: none; position: relative; padding-left: 1rem; }
.a-status-list li::before, .a-bullets li::before { content: ''; position: absolute; left: 0; top: 0.65em; width: 7px; height: 7px; border-radius: 50%; background: var(--a-good); }
.a-sub { border-top: 1px solid var(--a-line); }
.a-sub > summary { list-style: none; display: flex; align-items: center; gap: 0.6rem; padding: 0.7rem 0.2rem; cursor: pointer; font-weight: 600; }
.a-sub > summary::-webkit-details-marker { display: none; }
.a-sub > summary .a-chev { margin-left: auto; transform: rotate(-90deg); transition: transform 0.2s; }
.a-sub[open] > summary .a-chev { transform: rotate(0); }
.a-sub-body { background: #f1faf8; border-radius: 12px; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; font-size: 0.85rem; line-height: 1.7; }
.a-bullets { margin: 0; padding: 0; }

/* top layer chips (segmented) */
.a-layerbar { top: 18px; left: 416px; display: flex; gap: 0.4rem; padding: 0.35rem; border-radius: 999px; }
.a-layerbar button { border: 0; background: none; border-radius: 999px; padding: 0.5rem 1.1rem; font: 500 0.95rem 'Kanit', sans-serif; color: var(--a-ink); display: flex; align-items: center; gap: 0.45rem; cursor: pointer; }
.a-layerbar button.active { background: var(--a-teal-dark); color: #fff; }

/* right round buttons */
.a-right { top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; }
.a-round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--a-shadow); display: grid; place-items: center; cursor: pointer; color: var(--a-ink); }
.a-round.active { background: var(--a-teal-dark); color: #fff; }
.a-round-group { background: #fff; border-radius: 26px; box-shadow: var(--a-shadow); display: flex; flex-direction: column; }
.a-round-group .a-round { box-shadow: none; background: none; }

/* bottom timeline */
.a-timeline { bottom: 18px; left: 50%; transform: translateX(-50%); width: min(820px, calc(100% - 820px)); min-width: 560px; padding: 0.8rem 1.4rem 0.7rem; }
.a-tl-top { display: flex; justify-content: center; align-items: center; gap: 1rem; position: relative; }
.a-tl-date { display: flex; align-items: center; gap: 0.6rem; border: 1px solid var(--a-line); border-radius: 999px; padding: 0.25rem 0.5rem; font: 600 1.05rem 'IBM Plex Mono', monospace; }
.a-tl-date button { border: 0; background: none; cursor: pointer; font-size: 1.1rem; color: var(--a-ink); padding: 0 0.4rem; }
.a-forecast-pill { position: absolute; right: 0; background: var(--a-teal-dark); color: #fff; border-radius: 999px; padding: 0.25rem 0.8rem; font-size: 0.82rem; font-weight: 600; }
.a-forecast-pill[hidden] { display: none; }
.a-tl-mid { display: flex; align-items: center; gap: 0.8rem; margin: 0.45rem 0; }
.a-play { width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--a-teal-dark); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 14px rgba(11, 111, 106, 0.35); flex-shrink: 0; }
.a-step { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--a-line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--a-ink); flex-shrink: 0; }
.a-range { flex: 1; accent-color: var(--a-teal-dark); }
.a-tl-bottom { display: flex; justify-content: center; align-items: center; gap: 0.6rem; font-size: 0.85rem; flex-wrap: wrap; }
.a-tl-bottom button.a-link { border: 0; background: none; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; font: inherit; color: var(--a-ink); }
.a-select { border: 0; border-radius: 999px; background: var(--a-teal-soft); color: var(--a-teal-dark); padding: 0.3rem 0.8rem; font: 600 0.82rem 'IBM Plex Sans Thai', sans-serif; cursor: pointer; }

/* legend */
.a-legend { right: 18px; bottom: 18px; width: 360px; padding: 0.8rem 1rem; }
.a-legend-head { display: flex; align-items: center; gap: 0.5rem; font-family: 'Kanit', sans-serif; font-weight: 600; }
.a-legend-head .a-select { margin-left: auto; }
.a-ramp { height: 16px; border-radius: 8px; margin: 0.55rem 0 0.25rem; background: linear-gradient(90deg, #7c3aed, #3b82f6, #06b6d4, #22c55e, #facc15, #f97316, #ef4444); }
.a-ramp-rain { background: linear-gradient(90deg, #22d3ee, #3b82f6, #22c55e, #facc15, #f97316, #ef4444, #d946ef); }
.a-ramp-labels { display: flex; justify-content: space-between; font: 0.8rem 'IBM Plex Mono', monospace; }
.a-info-pop { right: 18px; bottom: 150px; width: 420px; padding: 1rem 1.2rem; font-size: 0.9rem; line-height: 1.6; }
.a-info-pop[hidden] { display: none; }
.a-info-pop h4 { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; font-family: 'Kanit', sans-serif; font-size: 1.1rem; }
.a-close { margin-left: auto; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--a-ink); }
.a-scale { left: 18px; bottom: 18px; }
.a-map .maplibregl-ctrl-scale { background: #fff; border-radius: 999px; padding: 0.2rem 0.9rem; border: 0; box-shadow: var(--a-shadow); }
.a-unit-note { font-size: 0.72rem; color: var(--a-muted); margin-top: 0.3rem; }

/* station markers */
.a-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45); cursor: pointer; }
.a-marker.source { width: 40px; height: 40px; background: #0f766e; display: grid; place-items: center; border-width: 3px; }
.a-marker.sel { outline: 3px solid rgba(15, 143, 136, 0.6); outline-offset: 2px; }

/* ---------- A7 weather top cards ---------- */
.a-wx-cards { top: 18px; left: 416px; right: 86px; display: flex; gap: 12px; }
.a-wx-cards .a-card { padding: 0.8rem 1.1rem; flex: 1; min-width: 0; }
.a-wx-cards h4 { margin: 0 0 0.4rem; font-family: 'Kanit', sans-serif; font-size: 1.05rem; }
.a-bars { display: flex; align-items: flex-end; gap: 6px; height: 54px; }
.a-bars div { flex: 1; text-align: center; font-size: 0.72rem; }
.a-bars span { display: block; background: linear-gradient(180deg, #2dd4bf, #0f8f88); border-radius: 4px 4px 0 0; margin-top: 2px; }
.a-radio-list label { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 10px; cursor: pointer; }
.a-radio-list label:has(input:checked) { background: var(--a-teal-soft); outline: 1px solid #9fdcd3; }
.a-radio-list input { margin-left: auto; accent-color: var(--a-teal-dark); }
.a-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a-tile { background: #fff; border: 1px solid var(--a-line); border-radius: 12px; padding: 0.5rem 0.7rem; font-size: 0.8rem; }
.a-tile b { display: block; font-size: 1.3rem; font-family: 'Kanit', sans-serif; }
.a-h { font-family: 'Kanit', sans-serif; font-weight: 600; font-size: 1rem; margin: 0.9rem 0 0.4rem; }

/* ---------- A8 sensors: 3 columns ---------- */
.a-cols { display: grid; grid-template-columns: 300px minmax(0, 1fr) 520px; gap: 0; height: calc(100vh - var(--a-header-h)); }
.a-col-left { background: #fff; padding: 1rem 1.2rem; overflow: auto; border-right: 1px solid var(--a-line); }
.a-col-left label { display: flex; align-items: center; gap: 0.6rem; padding: 0.35rem 0; cursor: pointer; font-size: 0.92rem; }
.a-col-left input { accent-color: var(--a-teal-dark); width: 18px; height: 18px; }
.a-col-mid { position: relative; }
.a-col-right { background: #fff; padding: 1rem 1.2rem; overflow: auto; border-left: 1px solid var(--a-line); }
.a-tabs { display: flex; background: #eef6f5; border-radius: 12px; padding: 4px; margin: 0.7rem 0; }
.a-tabs button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 0.55rem; font: 500 0.95rem 'Kanit', sans-serif; cursor: pointer; color: var(--a-ink); }
.a-tabs button.active { background: var(--a-teal-dark); color: #fff; }
.a-big { font: 600 2.6rem 'Kanit', sans-serif; line-height: 1.1; }
.a-level { display: inline-block; border-radius: 999px; padding: 0.2rem 0.9rem; font-weight: 600; }
.a-level.good { background: #dcfce7; color: #15803d; } .a-level.mod { background: #fef3c7; color: #b45309; } .a-level.high { background: #fee2e2; color: #b91c1c; }
.a-stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 0.7rem; }
.a-stat3 div { border-radius: 12px; padding: 0.6rem 0.8rem; font-size: 0.85rem; }
.a-stat3 b { display: block; font: 600 1.5rem 'Kanit', sans-serif; }
.a-box { border: 1px solid var(--a-line); border-radius: 14px; padding: 0.8rem 1rem; margin-top: 0.7rem; }
.a-map-search { top: 16px; left: 16px; width: min(460px, calc(100% - 220px)); margin: 0; box-shadow: var(--a-shadow); }
.a-col-mid .a-right { flex-direction: row; top: 14px; }
.a-col-mid .a-timeline { width: calc(100% - 40px); min-width: 0; }

/* ---------- reports layout ---------- */
.a-report { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; padding: 16px; min-height: calc(100vh - var(--a-header-h)); box-sizing: border-box; }
.a-filters { padding: 1.1rem 1.2rem; align-self: start; position: sticky; top: 16px; }
.a-filters h2 { display: flex; align-items: center; gap: 0.6rem; font: 600 1.35rem 'Kanit', sans-serif; margin: 0 0 1rem; }
.a-filters h3 { display: flex; align-items: center; gap: 0.5rem; font: 600 1rem 'Kanit', sans-serif; margin: 1.1rem 0 0.45rem; }
.a-filters select, .a-filters input[type=date] { width: 100%; border: 1px solid var(--a-line); border-radius: 10px; padding: 0.5rem 0.7rem; font: inherit; background: #fff; color: var(--a-ink); box-sizing: border-box; }
.a-filters label { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0; cursor: pointer; }
.a-filters input[type=checkbox] { accent-color: var(--a-teal-dark); width: 18px; height: 18px; }
.a-rtabs { display: flex; gap: 0.3rem; padding: 0.35rem; margin-bottom: 14px; }
.a-rtabs a { flex: 1; text-align: center; padding: 0.6rem; border-radius: 999px; text-decoration: none; color: var(--a-ink); font: 500 1rem 'Kanit', sans-serif; }
.a-rtabs a.active { background: var(--a-teal-dark); color: #fff; }
.a-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.a-kpi { padding: 0.9rem 1.1rem; display: flex; gap: 0.9rem; align-items: flex-start; }
.a-kpi .a-kpi-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.a-kpi small { display: block; font-weight: 600; font-size: 0.92rem; }
.a-kpi b { display: block; font: 600 2rem 'Kanit', sans-serif; line-height: 1.2; }
.a-kpi span { font-size: 0.85rem; color: var(--a-muted); }
.a-kpi.red { background: #fff1f1; } .a-kpi.red b { color: #dc2626; } .a-kpi.red .a-kpi-ic { background: #fee2e2; color: #dc2626; }
.a-kpi.amber { background: #fff8eb; } .a-kpi.amber b { color: #d97706; } .a-kpi.amber .a-kpi-ic { background: #fef3c7; color: #d97706; }
.a-kpi.green { background: #f0fdf4; } .a-kpi.green b { color: #16a34a; } .a-kpi.green .a-kpi-ic { background: #dcfce7; color: #16a34a; }
.a-kpi.teal .a-kpi-ic { background: var(--a-teal-soft); color: var(--a-teal-dark); }
.a-block { padding: 1rem 1.2rem; margin-bottom: 14px; }
.a-block h3 { display: flex; align-items: center; gap: 0.5rem; font: 600 1.1rem 'Kanit', sans-serif; margin: 0 0 0.6rem; }
.a-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.a-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.a-table th { background: #0f6f5c; color: #fff; padding: 0.5rem; font-weight: 600; text-align: center; }
.a-table th:first-child { border-top-left-radius: 8px; } .a-table th:last-child { border-top-right-radius: 8px; }
.a-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--a-line); text-align: center; }
.a-table.gray th { background: #6b7c7a; }
.a-red { color: #dc2626; font-weight: 700; }
.a-pill-red { background: #fee2e2; color: #b91c1c; border-radius: 6px; padding: 0.1rem 0.5rem; font-weight: 600; }
.a-windrow { display: flex; gap: 2px; align-items: center; overflow: hidden; font-size: 0.75rem; margin-top: 0.4rem; }
.a-windrow svg { flex: 1; min-width: 6px; }
.a-trust { padding: 0.55rem 1rem; font-size: 0.8rem; display: flex; gap: 1rem; flex-wrap: wrap; color: var(--a-muted); }
.a-seg { display: inline-flex; background: #eef6f5; border-radius: 999px; padding: 3px; }
.a-seg button { border: 0; background: none; border-radius: 999px; padding: 0.3rem 0.9rem; cursor: pointer; font: 500 0.85rem 'IBM Plex Sans Thai', sans-serif; color: var(--a-ink); }
.a-seg button.active { background: var(--a-teal-dark); color: #fff; }
.a-pager { display: flex; justify-content: center; gap: 0.3rem; margin-top: 0.6rem; }
.a-pager button { min-width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--a-line); background: #fff; cursor: pointer; }
.a-pager button.active { background: var(--a-teal-dark); color: #fff; border-color: var(--a-teal-dark); }

/* dialogs keep the program light look */
body.a-app .app-dialog { color-scheme: light; }
