/* =========================================================
   Phuket CCTV — design system
   ========================================================= */

:root {
  --bg: #eef2f7;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #dff3f8 0%, transparent 60%);
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #e9eef5;
  --glass: rgb(255 255 255 / 0.82);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0891b2;
  --accent-2: #0e7490;
  --accent-soft: rgb(8 145 178 / 0.1);
  --accent-text: #ffffff;
  --brand-grad: linear-gradient(135deg, #0891b2 0%, #2563eb 100%);
  --live: #ef4444;
  --live-soft: rgb(239 68 68 / 0.12);
  --ok: #16a34a;
  --ok-soft: rgb(22 163 74 / 0.12);
  --warn: #d97706;
  --warn-soft: rgb(217 119 6 / 0.12);
  --violet: #7c3aed;
  --violet-soft: rgb(124 58 237 / 0.1);
  --offline: #94a3b8;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow: 0 8px 28px rgb(15 23 42 / 0.1), 0 1px 3px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 24px 60px rgb(15 23 42 / 0.18);
  --ring: 0 0 0 3px rgb(8 145 178 / 0.25);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", sans-serif;
  --font-display: "Prompt", var(--font);
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070d1a;
    --bg-grad: radial-gradient(1200px 600px at 100% -10%, #0c2a3a 0%, transparent 60%);
    --surface: #0f172a;
    --surface-2: #131d33;
    --surface-3: #1b2740;
    --glass: rgb(15 23 42 / 0.82);
    --text: #e2e8f0;
    --text-2: #cbd5e1;
    --muted: #8b9ab3;
    --border: #1e293b;
    --border-strong: #334155;
    --accent: #22d3ee;
    --accent-2: #67e8f9;
    --accent-soft: rgb(34 211 238 / 0.12);
    --accent-text: #032530;
    --brand-grad: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    --live: #f87171;
    --live-soft: rgb(248 113 113 / 0.15);
    --ok: #4ade80;
    --ok-soft: rgb(74 222 128 / 0.13);
    --warn: #fbbf24;
    --warn-soft: rgb(251 191 36 / 0.13);
    --violet: #a78bfa;
    --violet-soft: rgb(167 139 250 / 0.14);
    --offline: #64748b;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.6);
    --ring: 0 0 0 3px rgb(34 211 238 / 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #070d1a;
  --bg-grad: radial-gradient(1200px 600px at 100% -10%, #0c2a3a 0%, transparent 60%);
  --surface: #0f172a;
  --surface-2: #131d33;
  --surface-3: #1b2740;
  --glass: rgb(15 23 42 / 0.82);
  --text: #e2e8f0;
  --text-2: #cbd5e1;
  --muted: #8b9ab3;
  --border: #1e293b;
  --border-strong: #334155;
  --accent: #22d3ee;
  --accent-2: #67e8f9;
  --accent-soft: rgb(34 211 238 / 0.12);
  --accent-text: #032530;
  --brand-grad: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --live: #f87171;
  --live-soft: rgb(248 113 113 / 0.15);
  --ok: #4ade80;
  --ok-soft: rgb(74 222 128 / 0.13);
  --warn: #fbbf24;
  --warn-soft: rgb(251 191 36 / 0.13);
  --violet: #a78bfa;
  --violet-soft: rgb(167 139 250 / 0.14);
  --offline: #64748b;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.6);
  --ring: 0 0 0 3px rgb(34 211 238 / 0.3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.88em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::selection { background: var(--accent-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--live); }
.btn.danger:hover { background: var(--live-soft); border-color: var(--live); }
.btn.solid-danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn.danger:hover { background: var(--live-soft); color: var(--live); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; color: var(--muted); }
.field > .seg { justify-self: start; }
.table td > .i, .table td span > .i { vertical-align: -3px; width: 15px; height: 15px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > span, .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); font-size: 12px; }
.input, select.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 14px var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.input-group { display: flex; gap: 6px; }
.input-group > .input { flex: 1; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 500 13px var(--font);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.live { background: var(--live); color: #fff; letter-spacing: 0.06em; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 18px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 6px 16px rgb(8 145 178 / 0.35);
  flex: none;
}
.brand-mark .i { width: 20px; height: 20px; }
.brand-text { display: grid; line-height: 1.2; min-width: 0; }
.brand-text strong { font: 600 16px var(--font-display); white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.stats { display: flex; gap: 8px; }
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.stat-pill b { font-family: var(--font-display); font-weight: 600; color: var(--text); }
.stat-pill.live { color: var(--live); }
.stat-pill.off { color: var(--muted); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 4px;
  border-radius: 999px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 14px var(--font-display);
  text-transform: uppercase;
  flex: none;
}
.user-chip .who { display: grid; line-height: 1.15; }
.user-chip .who b { font-size: 13px; }
.user-chip .who small { font-size: 11px; color: var(--muted); }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- Dialog ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal.wide { width: min(1040px, calc(100vw - 32px)); }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop 0.18s ease-out; }
dialog.modal::backdrop { background: rgb(2 6 23 / 0.55); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.modal-icon.danger { background: var(--live-soft); color: var(--live); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.form-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--live-soft);
  color: var(--live);
  font-size: 13px;
}

/* ---------- Toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: grid; gap: 8px; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: pop 0.2s ease-out;
}
.toast .i { color: var(--ok); }
.toast.error .i { color: var(--live); }

/* ---------- Spinner / skeleton ---------- */
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgb(255 255 255 / 0.25);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* =========================================================
   Login
   ========================================================= */
.login-page { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100%; }
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  color: #e6f6fb;
  background:
    radial-gradient(700px 400px at 20% 10%, rgb(34 211 238 / 0.35), transparent 60%),
    radial-gradient(600px 500px at 90% 90%, rgb(59 130 246 / 0.35), transparent 60%),
    #071426;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.login-hero > * { position: relative; }
.login-hero .brand-text small { color: rgb(230 246 251 / 0.65); }
.hero-copy h1 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.2; margin-bottom: 14px; }
.hero-copy h1 span { background: linear-gradient(90deg, #67e8f9, #93c5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-copy p { max-width: 460px; color: rgb(230 246 251 / 0.75); margin: 0 0 26px; font-size: 16px; }
.hero-features { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.hero-features li { display: flex; align-items: center; gap: 12px; color: rgb(230 246 251 / 0.9); }
.hero-features .i { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgb(255 255 255 / 0.08); border: 1px solid rgb(255 255 255 / 0.12); color: #67e8f9; }
.hero-radar { position: absolute; right: -120px; top: 50%; width: 460px; height: 460px; transform: translateY(-50%); opacity: 0.55; pointer-events: none; }
.hero-foot { font-size: 13px; color: rgb(230 246 251 / 0.5); }

.login-side { display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .mobile-brand { display: none; margin-bottom: 28px; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card > p { color: var(--muted); margin: 0 0 28px; }
.login-card form { display: grid; gap: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-wrap .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; }
.login-note { margin-top: 26px; display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.login-note .i { color: var(--accent); margin-top: 2px; }

.login-legal { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.6; color: var(--muted); }
.login-legal a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.terms-page { max-width: 720px; font-size: 14px; line-height: 1.7; color: var(--text-2); }
.terms-page h2 { font-size: 20px; margin: 0 0 10px; color: var(--text); }
.terms-page section { margin-bottom: 24px; }
.terms-page ol { margin: 0 0 12px; padding-left: 22px; }
.terms-page li { margin-bottom: 6px; }
.terms-page p { margin: 0 0 10px; }

/* ข้อตกลงการใช้งาน (หน้าตั้งรหัสผ่าน) */
.terms-box { max-height: 220px; overflow-y: auto; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; line-height: 1.65; color: var(--text-2); }
.terms-box h3 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
.terms-box h3 + ol { margin-top: 0; }
.terms-box ol { margin: 0 0 12px; padding-left: 20px; }
.terms-box li { margin-bottom: 4px; }
.terms-box p { margin: 0 0 8px; }
.terms-box p:last-child { margin-bottom: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.55; color: var(--text-2); cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.check a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* =========================================================
   Viewer (map)
   ========================================================= */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.layout { position: relative; display: grid; grid-template-columns: 330px 1fr; min-height: 0; }

#sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 2;
}
.side-head { padding: 16px 16px 10px; display: grid; gap: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px 12px; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: 500 13px var(--font);
  cursor: pointer;
}
.chip span { color: var(--muted); margin-left: 4px; font-size: 12px; }
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip[aria-pressed="true"] span { color: inherit; opacity: 0.7; }

#camList { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.list-group { padding: 12px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.cam-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.cam-item:hover { background: var(--surface-2); border-color: var(--border); }
.cam-item:focus-visible { outline: none; box-shadow: var(--ring); }
.cam-item.is-live { background: var(--live-soft); }
.cam-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.cam-item.is-live .cam-ico { background: var(--live); color: #fff; }
.cam-item.is-off .cam-ico { background: var(--surface-3); color: var(--offline); }
.cam-item.is-off .cam-name { color: var(--muted); }
.cam-item.is-off .cam-sub { color: var(--warn); }
.cam-text { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.cam-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-item .chev { color: var(--muted); opacity: 0; transition: opacity 0.12s; }
.cam-item:hover .chev { opacity: 1; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.empty-state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .i { width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--surface-3); color: var(--muted); }
.empty-state b { color: var(--text); font-size: 15px; }

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--surface-3); z-index: 0; }
.map-tools { position: absolute; top: 14px; left: 14px; z-index: 500; display: flex; gap: 8px; }
.map-tools .seg { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: var(--shadow); }
.map-tools .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.map-tools .tool-btn { background: var(--glass); backdrop-filter: blur(12px); box-shadow: var(--shadow); height: 38px; }

/* Leaflet overrides */
.leaflet-container { font: inherit; background: var(--surface-3); }
.dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(0.92) contrast(0.88) saturate(0.55); }
.leaflet-tile-pane { transition: filter 0.3s; }
.leaflet-bar { border: 1px solid var(--border) !important; border-radius: 12px !important; overflow: hidden; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--glass) !important; color: var(--text) !important; border-color: var(--border) !important; width: 36px !important; height: 36px !important; line-height: 36px !important; }
.leaflet-bar a:hover { background: var(--surface-2) !important; }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--muted) !important; border-radius: 8px 0 0 0; font-size: 11px; }
.leaflet-control-attribution a { color: var(--muted) !important; }

/* Pins */
.pin-wrap { background: none; border: 0; }
.pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  border: 3px solid var(--surface);
  box-shadow: 0 4px 12px rgb(2 6 23 / 0.35);
  transition: transform 0.15s;
}
.pin .i { width: 15px; height: 15px; }
.pin:hover, .pin.hl { transform: scale(1.18); }
.pin.live { background: var(--live); }
.pin.off { background: var(--offline); box-shadow: 0 2px 6px rgb(2 6 23 / 0.25); opacity: 0.85; }
.pin.live::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--live);
  animation: ring 1.6s ease-out infinite;
}
@keyframes ring { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(1.4); opacity: 0; } }
.cluster-wrap { background: none; border: 0; }
.cluster {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  backdrop-filter: blur(4px);
}
.cluster span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  font: 600 13px var(--font-display);
  box-shadow: 0 3px 10px rgb(2 6 23 / 0.3);
}

/* Hover card */
.leaflet-tooltip.cam-tip {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  white-space: normal;
}
.leaflet-tooltip.cam-tip::before { display: none; }
.tip-card { width: 280px; }
.tip-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface-3); overflow: hidden; }
.tip-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tip-thumb .tip-error { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--muted); font-size: 12px; text-align: center; padding: 12px; }
.tip-thumb .tip-error b { color: var(--text); font-size: 13px; }
.tip-thumb .badge { position: absolute; left: 8px; top: 8px; background: rgb(2 6 23 / 0.6); color: #fff; backdrop-filter: blur(4px); }
.tip-body { padding: 10px 12px 12px; display: grid; gap: 2px; }
.tip-title { font: 600 14px var(--font-display); }
.tip-sub { font-size: 12px; color: var(--muted); }
.tip-hint { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--accent); font-weight: 500; }
.tip-hint .i { width: 14px; height: 14px; }

/* Live dock */
.dock {
  position: absolute;
  top: 14px;
  right: 14px;
  max-height: calc(100% - 28px);
  width: min(460px, calc(100% - 28px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  z-index: 600;
  overflow: hidden;
  animation: slide-in 0.22s ease-out;
}
.dock.wide { width: min(820px, calc(100% - 28px)); }
.dock.xwide { width: min(calc(var(--cols, 4) * 330px), calc(100% - 28px)); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }
.dock-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.dock-title { flex: 1; display: flex; align-items: center; gap: 8px; font: 600 15px var(--font-display); }
.dock-title .dot { color: var(--live); }
.dock-title small { font: 500 13px var(--font); color: var(--muted); }
.dock-head .seg button { padding: 0 9px; }
.tiles { flex: 1; overflow-y: auto; padding: 12px; display: grid; gap: 12px; align-content: start; }
.tiles.grid { grid-template-columns: 1fr 1fr; }
.tiles.grid.many { grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 8px; padding: 8px; }
.tiles.grid.many .tile-name { font-size: 12.5px; }

.tile { border-radius: 14px; overflow: hidden; background: #000; box-shadow: var(--shadow-sm); }
.tile-media { position: relative; aspect-ratio: 16 / 9; background: #000; }
.tile-media video { width: 100%; height: 100%; display: block; object-fit: contain; }
.tile-media:fullscreen { aspect-ratio: auto; }
.tile-top, .tile-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  color: #fff;
  pointer-events: none;
}
.tile-top { top: 0; background: linear-gradient(rgb(0 0 0 / 0.65), transparent); }
.tile-bottom { bottom: 0; background: linear-gradient(transparent, rgb(0 0 0 / 0.6)); justify-content: space-between; font-size: 12px; opacity: 0.9; }
.tile-name { flex: 1; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px rgb(0 0 0 / 0.5); }
.tile-clock { font-family: var(--mono); letter-spacing: 0.02em; }
.tile-actions { display: flex; gap: 2px; pointer-events: auto; }
.tile-actions button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.12);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.tile-actions button:hover { background: rgb(255 255 255 / 0.25); }
.tile-actions .i { width: 15px; height: 15px; }
.tile-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  color: #fff;
  background: rgb(2 6 23 / 0.7);
  font-size: 13px;
}
.tile-status .btn { height: 32px; background: rgb(255 255 255 / 0.12); border-color: rgb(255 255 255 / 0.25); color: #fff; }
.tile-status .err-ico { color: #fca5a5; width: 26px; height: 26px; }

/* =========================================================
   Admin
   ========================================================= */
.admin-main { overflow-y: auto; }
.admin-wrap { max-width: 1240px; margin: 0 auto; padding: 28px 20px 60px; display: grid; gap: 22px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .spacer { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { padding: 18px; display: flex; gap: 14px; align-items: center; }
.stat-card .stat-ico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; flex: none; }
.stat-card .stat-ico .i { width: 22px; height: 22px; }
.stat-card .stat-num { font: 600 26px/1.1 var(--font-display); }
.stat-card .stat-label { font-size: 13px; color: var(--muted); }
.ico-accent { background: var(--accent-soft); color: var(--accent); }
.ico-violet { background: var(--violet-soft); color: var(--violet); }
.ico-ok { background: var(--ok-soft); color: var(--ok); }
.ico-warn { background: var(--warn-soft); color: var(--warn); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font: 600 14.5px var(--font);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .badge { height: 20px; }

.panel { overflow: hidden; }
/* บันทึกการใช้งาน */
a.tab { text-decoration: none; }
.toolbar.audit-filters select.input { min-width: 120px; }
.audit-note { padding: 10px 14px; font-size: 13px; color: var(--warn); background: var(--warn-soft); border-bottom: 1px solid var(--border); }
.audit-detail { max-width: 360px; color: var(--text-2); font-size: 13px; word-break: break-word; }
.audit-fail td:first-child { box-shadow: inset 3px 0 0 var(--live); }
.nowrap { white-space: nowrap; }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select.input { width: auto; min-width: 160px; }
.toolbar .spacer { flex: 1; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { display: flex; gap: 2px; justify-content: flex-end; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-main .cam-ico { width: 38px; height: 38px; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }
.table-empty { padding: 48px 20px; }

/* Camera editor */
.cam-editor { display: grid; grid-template-columns: 1.05fr 1fr; gap: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 6px; font: 600 13px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.brand-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.brand-opt { position: relative; }
.brand-opt input { position: absolute; opacity: 0; }
.brand-opt span {
  display: grid;
  place-items: center;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.brand-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.brand-opt input:focus-visible + span { box-shadow: var(--ring); }
details.adv { grid-column: 1 / -1; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 14px; }
details.adv summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
details.adv[open] summary { margin-bottom: 12px; }
details.adv .form-grid { gap: 12px; }

.editor-side { display: grid; gap: 14px; align-content: start; }
.picker-map { height: 260px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.coords { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.preview-box {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.preview-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.preview-msg { display: grid; justify-items: center; gap: 8px; padding: 16px; text-align: center; font-size: 13px; color: var(--muted); }
.preview-msg.err { color: var(--live); }
.preview-msg .i { width: 28px; height: 28px; }
.preview-box .spinner { border-color: var(--border-strong); border-top-color: var(--accent); }
.preview-ok { position: absolute; left: 10px; top: 10px; }

.pw-gen { display: flex; gap: 6px; }
.pw-gen .pw-wrap { flex: 1; }
.role-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.role-opt { position: relative; }
.role-opt input { position: absolute; opacity: 0; }
.role-opt span {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
}
.role-opt b { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.role-opt small { color: var(--muted); font-size: 12px; }
.role-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.role-opt input:focus-visible + span { box-shadow: var(--ring); }
.role-opt input:disabled + span { opacity: 0.55; cursor: not-allowed; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
  .stats { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .cam-editor { grid-template-columns: 1fr; }
  .tiles.grid.many { grid-template-columns: 1fr 1fr; } /* จอไม่กว้างพอสำหรับ 4 คอลัมน์ */
}

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-card .mobile-brand { display: flex; }

  .topbar { height: 58px; padding: 0 12px; gap: 8px; }
  .brand-text small, .user-chip .who, .hide-sm { display: none; }
  .layout { grid-template-columns: 1fr; }
  #sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(340px, 88%);
    z-index: 900;
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  #sidebar.open { transform: none; }
  .dock { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 62%; }
  .dock.wide { width: auto; }
  .tiles.grid, .tiles.grid.many { grid-template-columns: 1fr; }
  .map-tools { left: 10px; top: 10px; }

  .admin-wrap { padding: 18px 12px 40px; gap: 16px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-num { font-size: 22px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table td { padding: 3px 0; border: 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  .table .actions { justify-content: flex-start; margin-top: 6px; }
  .form-grid { grid-template-columns: 1fr; }
  .role-pick { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
  #toggleList { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}


/* ===== UI refresh: หมุดสถานะ + cluster เตือน + sidebar (เพิ่ม 20261018-020844) ===== */
.cam-pin { position: relative; width: 34px; height: 44px; cursor: pointer; transition: transform .14s; }
.cam-pin:hover, .cam-pin.hl { transform: scale(1.14); z-index: 1000; }
.cam-pin .cp-body { position: absolute; left: 0; top: 0; width: 34px; height: 34px; background: var(--accent); border: 2px solid var(--surface); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 3px 7px rgb(2 6 23 / .45); display: grid; place-items: center; }
.cam-pin .cp-body .i { width: 16px; height: 16px; color: #fff; transform: rotate(45deg); }
.cam-pin.off .cp-body { background: var(--live); }
.cam-pin.off .cp-body .i { display: none; }
.cam-pin.off .cp-body::after { content: "!"; color: #fff; font: 800 16px/1 var(--font); transform: rotate(45deg); }
.cam-pin .cp-dot { position: absolute; right: -2px; top: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); z-index: 2; }
.cam-pin.off .cp-dot { background: var(--live); }
.cam-pin.live::after { content: ""; position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--accent); animation: ring 1.6s ease-out infinite; }

.cluster { position: relative; }
.cluster.alert { border-color: var(--live); box-shadow: 0 0 0 3px var(--live-soft); }
.cl-badge { position: absolute; top: -5px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--live); color: #fff; font: 700 11px/18px var(--font); font-style: normal; text-align: center; border: 2px solid var(--surface); }

.side-filter { justify-self: start; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--live); background: var(--live-soft); color: var(--live); font: 600 12px var(--font); cursor: pointer; }
.side-filter .dot { background: var(--live); }
.side-filter[aria-pressed="true"] { background: var(--live); color: #fff; }
.side-filter[aria-pressed="true"] .dot { background: #fff; }

.list-group { padding: 0; margin: 6px 0 2px; text-transform: none; letter-spacing: normal; }
.grp-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; background: none; border: 0; color: var(--muted); font: 600 12px var(--font); cursor: pointer; border-radius: 10px; }
.grp-btn:hover { background: var(--surface-2); color: var(--text-2); }
.grp-chev { width: 14px; height: 14px; flex: none; transform: rotate(90deg); transition: transform .15s; }
.list-group.collapsed .grp-chev { transform: rotate(0deg); }
.grp-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-count { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.grp-count .g-on { color: var(--ok); }
.grp-count .g-on::before { content: "\25cf "; }
.grp-count .g-off { color: var(--live); }
.grp-count .g-off::before { content: "\25cf "; }

.sd { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sd.on { background: var(--ok); }
.sd.off { background: var(--live); }
.sd.warn { background: var(--warn); }
.cam-item.is-off { background: var(--live-soft); box-shadow: inset 3px 0 0 var(--live); }
.cam-item.is-off .cam-name { color: var(--text); }
.cam-item.is-off .cam-sub { color: var(--live); }

/* =========================================================
   ชั้นข้อมูลฝน (สถานีวัดน้ำฝน ThaiWater)
   ========================================================= */
.map-tools .rain-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.rain-wrap { background: none; border: 0; }
.rain-pin { position: relative; cursor: default; filter: drop-shadow(0 5px 6px rgb(2 6 23 / 0.28)); transition: transform 0.15s; }
.rain-pin:hover { transform: scale(1.12); }
.rain-pin svg { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: visible; }
.rp-val {
  position: absolute;
  left: 0;
  right: 0;
  top: 45%;
  z-index: 1;
  transform: translateY(-50%);
  text-align: center;
  color: #fff;
  font: 700 12px/1 var(--font-display);
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgb(2 6 23 / 0.55);
  pointer-events: none;
}
.lv-none .rp-val { color: #475569; text-shadow: none; font-size: 11px; }
.lv-light .rp-val { font-size: 12px; }
.lv-moderate .rp-val { font-size: 13px; }
.lv-heavy .rp-val { font-size: 14px; }
.lv-extreme .rp-val { font-size: 15px; }

/* เม็ดฝนตกลงมา (ยิ่งฝนหนักยิ่งมีหลายเม็ด) */
.rp-drop { animation: rain-fall 1.5s ease-in infinite; }
@keyframes rain-fall {
  0% { transform: translateY(-4px); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translateY(6px); opacity: 0; }
}
/* ฝนหนักมาก: วงเรืองแสงรอบเมฆ ให้สะดุดตา */
.rain-pin.lv-extreme::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 45%;
  width: 92%;
  height: 92%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgb(192 38 211 / 0.45), transparent 70%);
  animation: rain-glow 2s ease-in-out infinite;
}
@keyframes rain-glow { 50% { transform: translate(-50%, -50%) scale(1.35); opacity: 0.35; } }

.leaflet-tooltip.rain-tip {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  white-space: normal;
}
.leaflet-tooltip.rain-tip::before { display: none; }
.rt-card { width: 230px; padding: 10px 12px 11px; display: grid; gap: 3px; }
.rt-title { font: 600 14px var(--font-display); }
.rt-sub { font-size: 12px; color: var(--muted); }
.rt-val { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 2px; font-size: 13px; color: var(--text-2); }
.rt-val b { font: 700 24px/1 var(--font-display); }
.rt-lv { margin-left: auto; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: #fff; }
.rt-lv.lv-none { background: var(--surface-3); color: var(--muted); }
.rt-lv.lv-light { background: #0ea5e9; }
.rt-lv.lv-moderate { background: #1d4ed8; }
.rt-lv.lv-heavy { background: #6d28d9; }
.rt-lv.lv-extreme { background: #a21caf; }

.rain-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 500;
  width: 240px;
  padding: 10px 12px 10px;
  border-radius: 16px;
  font-size: 12.5px;
}
.rl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.rl-head b { display: flex; align-items: center; gap: 6px; font: 600 13.5px var(--font-display); }
.rl-head b .i { width: 16px; height: 16px; color: var(--accent); }
.rl-head b small { font: 400 11.5px var(--font); color: var(--muted); }
.rl-head .icon-btn { width: 28px; height: 28px; }
.rl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rl-list li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; }
.rl-sw { position: relative; width: 34px; height: 30px; filter: drop-shadow(0 2px 3px rgb(2 6 23 / 0.25)); }
.rl-sw svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rl-label { display: grid; line-height: 1.25; color: var(--text); }
.rl-label small { color: var(--muted); font-size: 11px; }
.rl-n { min-width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rl-top { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--text-2); }
.rl-top:empty { display: none; }
.rl-foot { margin-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.4; }

@media (max-width: 860px) {
  .rain-legend { left: 10px; bottom: 10px; width: 168px; padding: 6px 8px 8px; border-radius: 14px; font-size: 11.5px; }
  .rl-head { margin-bottom: 2px; }
  .rl-head b { font-size: 12px; }
  .rl-head b small { display: none; }
  .rl-head .icon-btn { width: 24px; height: 24px; }
  .rl-list li { grid-template-columns: 26px 1fr auto; gap: 6px; }
  .rl-sw { width: 26px; height: 22px; }
  .rl-label small, .rl-top, .rl-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rp-drop, .rain-pin.lv-extreme::before { animation: none; }
}

/* แบ่งหน้าตารางกล้อง */
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 13px; }
.pager .input.sm { height: 34px; padding: 0 28px 0 10px; width: auto; }
.pager .icon-btn:disabled { opacity: 0.35; pointer-events: none; }
