/* ระบบเตือนภัยพิบัติบนทางหลวง — ต้นแบบ */
:root {
  --blue: #0b3d6b; --blue2: #11528f; --accent: #0ea5e9;
  --bg: #eef2f6; --panel: #ffffff; --line: #d8e0e8;
  --text: #0f2233; --muted: #5b6b7a;
  --danger: #dc2626; --ok: #16a34a;
  --shadow: 0 1px 3px rgba(16,40,64,.10);
  font-family: "Sarabun", "Noto Sans Thai", system-ui, "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid; grid-template-rows: auto auto 1fr auto; min-height: 100vh;
  background: var(--bg); color: var(--text); font-size: 14px;
}

/* ---------- header ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
  background: linear-gradient(90deg, var(--blue), var(--blue2)); color: #fff;
  padding: 10px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 9px; background: #fff; color: var(--blue);
  font-weight: 800; display: grid; place-items: center; font-size: 16px; flex: none;
}
.title { font-size: 17px; font-weight: 700; line-height: 1.2; }
.subtitle { font-size: 12px; opacity: .85; margin-top: 2px; }
.demo {
  background: #f59e0b; color: #3a2a00; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; margin-left: 6px; vertical-align: middle;
}
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scn-group { display: flex; background: rgba(255,255,255,.12); border-radius: 9px; padding: 3px; }
.scn {
  border: 0; background: transparent; color: #eaf2fb; padding: 6px 11px; border-radius: 7px;
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.scn:hover { background: rgba(255,255,255,.12); }
.scn.active { background: #fff; color: var(--blue); font-weight: 700; }
.ctl, .speed select {
  border: 0; background: rgba(255,255,255,.15); color: #fff; padding: 7px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.ctl:hover { background: rgba(255,255,255,.28); }
.speed { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.clock { font-variant-numeric: tabular-nums; font-size: 12px; opacity: .92; min-width: 170px; text-align: right; }

/* ---------- counts ---------- */
.counts { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 8px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.count-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.fresh { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.fresh b { color: var(--text); font-variant-numeric: tabular-nums; }
.fresh .fsep { opacity: .5; }
.fdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.fdot.live { background: #16a34a; animation: pulse 1.6s infinite; }
.fdot.paused { background: #94a3b8; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: .35; } 100% { opacity: 1; } }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line);
  border-left: 4px solid var(--c); background: #fff;
}
.pill b { font-size: 15px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 330px 1fr 380px; gap: 10px; padding: 10px; min-height: 0; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.col-map { padding: 0; }
#map { width: 100%; height: 100%; min-height: 360px; border-radius: 12px; }
.col-h { font-size: 13px; font-weight: 700; color: var(--blue); margin: 0; padding: 11px 13px 7px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.badge { background: var(--danger); color: #fff; border-radius: 20px; font-size: 12px; padding: 1px 9px; }
.scroll { overflow-y: auto; padding: 10px; }
.col-right .scroll.feed { flex: 1; min-height: 120px; }
.col-right .detail { flex: 1 1 auto; min-height: 200px; }
.empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; line-height: 1.6; }

/* ---------- alert cards ---------- */
.alert-card { border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 9px;
  padding: 9px 11px; margin-bottom: 8px; cursor: pointer; background: #fff; transition: .12s; }
.alert-card:hover { background: #f6f9fc; }
.alert-card.sel { outline: 2px solid var(--accent); }
.ac-top { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.closed { background: #111; color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 5px; margin-left: auto; }
.ac-name { font-size: 12.5px; color: var(--text); margin: 2px 0; }
.ac-sum { font-size: 11.5px; color: var(--muted); }
.ac-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 5px; }

/* ---------- detail ---------- */
.d-head { display: flex; justify-content: space-between; gap: 10px; border-left: 5px solid var(--c);
  padding: 4px 0 8px 10px; }
.d-route { font-size: 17px; font-weight: 800; } .d-route span { font-weight: 600; color: var(--muted); font-size: 14px; }
.d-name { font-size: 13px; margin-top: 2px; } .d-dist { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.d-badge { color: #fff; font-weight: 700; padding: 5px 11px; border-radius: 8px; height: fit-content; white-space: nowrap; }
.d-road { font-size: 13px; margin: 9px 0; padding: 7px 10px; border-radius: 8px; }
.rc-open { background: #ecfdf3; color: #14532d; }
.rc-closed { background: #fef2f2; color: #7f1d1d; }
.cctv { width: 100%; max-width: 340px; border-radius: 9px; display: block; margin: 6px 0; }
.d-sec { font-size: 12px; font-weight: 700; color: var(--blue); margin: 10px 0 4px; display: flex; align-items: center; justify-content: space-between; }
.spark { width: 120px; height: 30px; }
.reasons { list-style: none; margin: 4px 0; padding: 0; }
.reasons li { font-size: 12.5px; border-left: 4px solid var(--c); padding: 5px 9px; background: #f7f9fb;
  border-radius: 0 6px 6px 0; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.reasons li.ok { border-color: var(--ok); color: #14532d; }
.rl { font-size: 11px; color: var(--muted); }
.d-rec { font-size: 12.5px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  padding: 7px 10px; border-radius: 8px; margin: 8px 0; }
.d-time { font-size: 11.5px; color: var(--muted); margin: 6px 0; }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 13px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit; font-weight: 600; }
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.hint { font-size: 11px; color: var(--muted); margin-top: 8px; font-style: italic; }

/* ---------- feed ---------- */
.feed-item { border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 7px; }
.fpub { background: #fffdf5; border-color: #fde68a; }
.fint { background: #f7f9fb; }
.fi-top { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.chan { font-weight: 700; color: #fff; padding: 1px 8px; border-radius: 20px; font-size: 10.5px; }
.c-internal { background: #475569; } .c-public { background: #0284c7; } .c-cbs { background: var(--danger); }
.fi-aud { } .fi-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.fi-text { font-size: 12.5px; white-space: pre-wrap; line-height: 1.5; }

/* ---------- footer ---------- */
.foot { font-size: 11.5px; color: var(--muted); text-align: center; padding: 8px 18px; background: var(--panel); border-top: 1px solid var(--line); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  #map { height: 52vh; }
  .col { max-height: 70vh; }
  .clock { display: none; }
}
