/* ===== Site Health — style ===== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e8;
  --text: #16181d;
  --text-2: #5b606b;
  --text-3: #8a8f99;
  --primary: #1f5fbf;
  --primary-soft: #e8f0fc;
  --side-bg: #111827;
  --side-text: #c9ced8;
  --side-active: #1f2a3d;

  --hik: #2a78d6;  /* ซีรีส์ 1 */
  --rj:  #eb6834;  /* ซีรีส์ 2 */

  --good: #0ca30c;      --good-ink: #0a6e0a;      --good-bg: #e7f6e7;
  --warning: #fab219;   --warning-ink: #7a5200;   --warning-bg: #fff4d9;
  --critical: #d03b3b;  --critical-ink: #a82828;  --critical-bg: #fcebeb;
  --info: #2a78d6;      --info-ink: #1c5cab;      --info-bg: #e8f1fc;
  --muted-ink: #5b606b; --muted-bg: #eef0f2;

  --radius: 10px;
  --bs-body-font-family: 'IBM Plex Sans Thai', 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-primary: var(--primary);
  --bs-primary-rgb: 31, 95, 191;
  --bs-link-color: var(--primary);
  --bs-link-color-rgb: 31, 95, 191;
}

body { background: var(--bg); color: var(--text); font-size: 0.93rem; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: #1a4fa0; --bs-btn-hover-border-color: #1a4fa0; --bs-btn-active-bg: #164389; }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); }
.btn { border-radius: 8px; }
.btn-icon { padding: .25rem .45rem; border: 0; color: var(--text-2); background: transparent; border-radius: 6px; }
.btn-icon:hover { background: var(--muted-bg); color: var(--text); }
.form-control, .form-select { border-radius: 8px; border-color: #d5d8dd; }
.form-label { font-weight: 500; font-size: .85rem; color: var(--text-2); margin-bottom: .3rem; }
.req { color: var(--critical); }
.tabular, .kpi-value { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; font-size: .82rem; }
.mono-wrap { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.pre { white-space: pre-line; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.brand small { display: block; color: var(--text-3); font-size: .72rem; }
.login-page .brand { color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2a78d6, #1baf7a); display: grid; place-items: center; color: #fff; font-size: 1.05rem; }
.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav-item i { font-size: 1.05rem; opacity: .85; }
.nav-item:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #5b9cf0; }
.nav-item .brand-dot { margin-left: auto; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 12px 6px; }
.sidebar-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid #222b3a; padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--side-text); flex: 1; min-width: 0; padding: 4px; border-radius: 8px; }
.user-chip:hover { background: var(--side-active); text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2c3a52; color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.user-meta { min-width: 0; }
.user-meta strong { display: block; color: #fff; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--text-3); font-size: .72rem; }
.btn-logout { background: none; border: 0; color: var(--side-text); padding: 6px 8px; border-radius: 8px; }
.btn-logout:hover { background: var(--side-active); color: #fff; }

.main { flex: 1; min-width: 0; }
.content { padding: 24px 28px 48px; max-width: 1480px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .btn-icon { font-size: 1.4rem; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .content { padding: 16px 16px 40px; }
}

/* ---------- Page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: .84rem; color: var(--text-2); margin-bottom: 4px; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgba(16,24,40,.04); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.card-head h2 { font-size: .98rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.table-card { overflow: hidden; }

/* ---------- Brand dot ---------- */
.brand-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.brand-dot.lg { width: 12px; height: 12px; margin-right: 0; }
.brand-dot.hik { background: var(--hik); }
.brand-dot.rj { background: var(--rj); }

/* ---------- Status badges (สี + ไอคอน + ข้อความ เสมอ) ---------- */
.status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.status i { font-size: .8rem; }
.st-good { background: var(--good-bg); color: var(--good-ink); }
.st-good i { color: var(--good); }
.st-warning { background: var(--warning-bg); color: var(--warning-ink); }
.st-warning i { color: #d99500; }
.st-critical { background: var(--critical-bg); color: var(--critical-ink); }
.st-critical i { color: var(--critical); }
.st-info { background: var(--info-bg); color: var(--info-ink); }
.st-muted { background: var(--muted-bg); color: var(--muted-ink); }
.c-critical { color: var(--critical); }
.c-warning { color: #d99500; }

.status-select { font-size: .8rem; font-weight: 600; border-radius: 999px; padding-top: .2rem; padding-bottom: .2rem; }
.status-select[data-v="Completed"] { background-color: var(--good-bg); color: var(--good-ink); border-color: #bfe5bf; }
.status-select[data-v="In Progress"] { background-color: var(--info-bg); color: var(--info-ink); border-color: #c4dbf6; }
.status-select[data-v="Pending"] { background-color: var(--warning-bg); color: var(--warning-ink); border-color: #f5dc9f; }
.status-select[data-v="No action"] { background-color: var(--muted-bg); color: var(--muted-ink); }

/* ---------- Filter bar ---------- */
.filter-bar { padding: 12px; }
.filter-main { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1 1 320px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-box input { padding-left: 36px; }
.quick-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-block; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 12px; font-size: .8rem; cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding-top: 12px; margin-top: 12px; border-top: 1px dashed var(--border); }
.filter-grid label { font-size: .78rem; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.filter-actions { display: flex; align-items: flex-end; }

/* ---------- Tables ---------- */
.data-table { font-size: .87rem; }
.data-table thead th { background: #f8f9fb; color: var(--text-2); font-weight: 600; font-size: .78rem; border-bottom: 1px solid var(--border); white-space: nowrap; padding-top: 10px; padding-bottom: 10px; }
.data-table td { border-color: #eef0f2; }
.data-table .sub { color: var(--text-3); font-size: .76rem; }
.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-link i { font-size: .7rem; opacity: .45; }
.sort-link.active { color: var(--primary); }
.sort-link.active i { opacity: 1; }
.clip { max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-2 { max-width: 240px; min-width: 170px; }
.clip-2 .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.count-pill { display: inline-block; min-width: 22px; text-align: center; background: var(--muted-bg); border-radius: 999px; font-size: .74rem; font-weight: 600; padding: 1px 7px; color: var(--text-2); }
.empty { text-align: center; padding: 48px 0 !important; color: var(--text-3); }
.empty i { font-size: 2rem; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); }

/* ---------- Forms ---------- */
.form-section { padding: 18px 20px 20px; }
.form-section h2 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.form-section.narrow { max-width: 560px; }
.step { width: 24px; height: 24px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 500; background: var(--surface); color: var(--text-2); user-select: none; }
.seg-btn:hover { border-color: #b8bdc6; }
.seg-btn i { opacity: .5; }
.btn-check:checked + .seg-btn { border-width: 1px; font-weight: 600; box-shadow: 0 0 0 2px currentColor inset; }
.btn-check:checked + .seg-btn i { opacity: 1; }
.btn-check:checked + .seg-btn.st-good { background: var(--good-bg); color: var(--good-ink); }
.btn-check:checked + .seg-btn.st-warning { background: var(--warning-bg); color: var(--warning-ink); }
.btn-check:checked + .seg-btn.st-critical { background: var(--critical-bg); color: var(--critical-ink); }
.btn-check:checked + .seg-btn.st-info { background: var(--info-bg); color: var(--info-ink); }
.btn-check:checked + .seg-btn.st-muted { background: var(--muted-bg); color: var(--text); }
.btn-check:focus-visible + .seg-btn { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg-btn.st-good, .seg-btn.st-warning, .seg-btn.st-critical, .seg-btn.st-info, .seg-btn.st-muted { background: var(--surface); color: var(--text-2); }
.templates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.templates .chip { font-size: .74rem; padding: 2px 10px; }
.device-head, .device-row { display: grid; grid-template-columns: 28px 2fr 1.2fr 1.4fr 36px; gap: 8px; align-items: center; }
.device-head { font-size: .76rem; color: var(--text-2); font-weight: 600; padding-bottom: 4px; }
.device-row { margin-bottom: 6px; }
.device-row .seq { color: var(--text-3); font-size: .8rem; text-align: center; }
@media (max-width: 767.98px) {
  .device-head { display: none; }
  .device-row { grid-template-columns: 24px 1fr 36px; }
  .device-row input:not(:first-of-type) { grid-column: 2; }
}
.lookup-hint { margin-top: 6px; font-size: .8rem; background: var(--info-bg); color: var(--info-ink); border-radius: 8px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lookup-hint button { font-size: .78rem; padding: 1px 10px; }

/* ---------- Detail ---------- */
.detail-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.detail-layout > .card { margin-bottom: 0; }
.detail-layout + .card, .detail-layout + section { margin-top: 18px; }
.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; padding: 4px 16px 16px; margin: 0; }
.detail-grid dt { color: var(--text-2); font-weight: 500; font-size: .84rem; }
.detail-grid dd { margin: 0; word-break: break-word; }
.detail-grid .sub { color: var(--text-3); font-size: .78rem; }

/* ---------- Dashboard ---------- */
.range-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-bar input { width: 150px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.kpi.link:hover { border-color: var(--primary); text-decoration: none; }
.kpi-label { font-size: .8rem; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.15; }
.kpi-value small { font-size: 1rem; color: var(--text-2); margin-left: 2px; }
.kpi-sub { font-size: .76rem; color: var(--text-3); }
.meter { display: block; height: 6px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; margin-top: 6px; }
.meter span { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.chart-grid > .card { margin-bottom: 0; }
.chart-grid .span-2 { grid-column: span 2; }
@media (max-width: 1199.98px) { .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .chart-grid { grid-template-columns: 1fr; } .chart-grid .span-2 { grid-column: auto; } }
.chart-box { position: relative; height: 240px; padding: 0 14px 14px; }
.chart-box.tall { height: 260px; }
.legend { display: flex; gap: 12px; font-size: .78rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.s1 { background: var(--hik); }
.sw.s2 { background: var(--rj); }

/* ---------- Login / error ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, #e3edfb, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 380px; padding: 28px; margin: 0; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--text-3); }

.toast { border-radius: 10px; }
.data-table > :not(caption) > * > :first-child { padding-left: 16px; }
.data-table > :not(caption) > * > :last-child { padding-right: 16px; }

/* ===================== PWA / มือถือ ===================== */
.install-btn { background: none; border: 1px dashed #334155; width: 100%; text-align: left; margin-top: 12px; }
.offline-bar { position: sticky; top: 0; z-index: 60; background: #3b2a00; color: #ffe8a3; font-size: .85rem; padding: 8px 16px; text-align: center; }
.draft-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.draft-bar.d-none { display: none !important; }
.install-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.install-steps h3 { font-size: .9rem; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.install-steps ol { padding-left: 1.2rem; margin: 0; font-size: .88rem; }
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
  width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 1.6rem; box-shadow: 0 6px 18px rgba(31, 95, 191, .4);
}
.fab:hover { color: #fff; text-decoration: none; background: #1a4fa0; }
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); }

@media (max-width: 767.98px) {
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 1.25rem; }
  .page-head > .d-flex { width: 100%; }
  .list-actions .btn-primary { display: none; } /* ใช้ปุ่ม + ลอยแทน */

  /* iPhone จะซูมหน้าจอถ้าตัวอักษรในช่องกรอกเล็กกว่า 16px */
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; }

  /* ตารางรายการ -> การ์ดทีละรายการ อ่านง่ายบนมือถือ */
  .data-table.stack thead { display: none; }
  .data-table.stack tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
  }
  .data-table.stack tbody td { display: block; border: 0; padding: 0 !important; max-width: none; min-width: 0; background: transparent; box-shadow: none; }
  .data-table.stack .c-site { order: 1; font-size: 1rem; }
  .data-table.stack .c-online { order: 2; justify-self: end; }
  .data-table.stack .c-date { order: 3; grid-column: 1 / -1; display: flex; gap: 6px; color: var(--text-2); font-size: .8rem; }
  .data-table.stack .c-date .sub { font-size: .8rem; }
  .data-table.stack .c-extra { order: 4; grid-column: 1 / -1; text-align: left !important; }
  .data-table.stack .c-note { order: 5; grid-column: 1 / -1; }
  .data-table.stack .c-status { order: 6; }
  .data-table.stack .c-status select { max-width: 190px; }
  .data-table.stack .c-actions { order: 7; align-self: center; }
  .data-table.stack .empty { grid-column: 1 / -1; }

  .form-section { padding: 16px; }
  .form-actions { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .form-actions .btn { flex: 1 1 auto; }
  .seg-btn { flex: 1 1 auto; justify-content: center; padding: 10px 12px; }
  .detail-grid { grid-template-columns: 110px 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .range-bar input { width: 130px; }
}

/* ===================== ประวัติการแก้ไข ===================== */
.change-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: .84rem; }
.change-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.cl-field { font-weight: 600; color: var(--text-2); min-width: 120px; }
.cl-from { background: #fdecec; color: #8f2424; border-radius: 4px; padding: 0 6px; text-decoration: line-through; text-decoration-color: rgba(143, 36, 36, .45); white-space: pre-line; }
.cl-to { background: #e7f6e7; color: #0a5e0a; border-radius: 4px; padding: 0 6px; font-weight: 500; white-space: pre-line; }
.cl-arrow { color: var(--text-3); font-size: .75rem; }
.timeline { list-style: none; margin: 0; padding: 4px 16px 14px; }
.timeline > li { display: flex; gap: 12px; position: relative; padding-bottom: 14px; }
.timeline > li:not(:last-child)::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.tl-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; color: #fff; background: var(--text-3); z-index: 1; }
.tl-create .tl-icon { background: var(--good); }
.tl-update .tl-icon, .tl-status .tl-icon { background: var(--info); }
.tl-delete .tl-icon { background: var(--critical); }
.tl-body { flex: 1; min-width: 0; padding-top: 3px; }
.tl-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: .88rem; }
.tl-time { color: var(--text-3); font-size: .8rem; margin-left: auto; }
.tl-detail { color: var(--text-2); font-size: .82rem; }
.log-table td { padding-top: 10px; padding-bottom: 10px; }
.log-table .sub { margin-left: 6px; }
@media (max-width: 767.98px) { .cl-field { min-width: 0; width: 100%; } .tl-time { margin-left: 0; width: 100%; } }

/* ===================== การตรวจติดตาม ===================== */
.nav-count { margin-left: auto; background: #e03131; color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: 0 7px; min-width: 22px; text-align: center; line-height: 1.5; }
.id-tag { font-family: ui-monospace, Consolas, monospace; font-size: .74rem; color: var(--text-3); }
.id-tag.lg { font-size: .8rem; background: var(--muted-bg); color: var(--text-2); border-radius: 6px; padding: 1px 7px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chk i { font-size: .8rem; }
.chk-today { color: var(--good-ink); } .chk-today i { color: var(--good); }
.chk-yday { color: var(--warning-ink); } .chk-yday i { color: #d99500; }
.chk-old { color: var(--critical-ink); } .chk-old i { color: var(--critical); }
.chk-none { color: var(--text-3); font-weight: 500; }
.c-good { color: var(--good); }
.btn-check-in { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #9fd7a5; color: var(--good-ink); background: var(--good-bg); font-weight: 600; border-radius: 8px; padding: .2rem .55rem; }
.btn-check-in:hover { background: var(--good); color: #fff; border-color: var(--good); }
.btn-check-in.big { padding: .375rem .85rem; font-size: .93rem; background: var(--good); color: #fff; border-color: var(--good); }
.btn-check-in.big:hover { background: #098a09; }
.row-checked { background: #f3fbf3; }
.kpi-alert { border-color: #f5c2c2; background: #fff8f8; }
.kpi-alert .kpi-value { color: var(--critical-ink); }

.chk-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--border); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.chk-stats > div { background: var(--surface); padding: 10px 16px; display: flex; flex-direction: column; }
.chk-stats .lbl { font-size: .76rem; color: var(--text-2); }
.chk-stats .val { font-size: 1.4rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.chk-stats .val.sm { font-size: .95rem; padding: 4px 0 2px; }
.chk-stats .val.ok { color: var(--good-ink); } .chk-stats .val.warn { color: var(--critical-ink); }
.chk-stats .sub { font-size: .74rem; color: var(--text-3); }
.chk-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; padding: 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .dow { text-align: center; font-size: .72rem; color: var(--text-3); padding-bottom: 2px; }
.cal-grid .day { position: relative; aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .8rem; color: var(--text); border: 1px solid transparent; text-decoration: none; }
.cal-grid .day:hover { border-color: var(--primary); text-decoration: none; }
.cal-grid .day.has { background: var(--good-bg); color: var(--good-ink); font-weight: 600; }
.cal-grid .day.miss { background: #fafafa; color: var(--text-3); }
.cal-grid .day.future { color: #c4c8ce; }
.cal-grid .day.today { border-color: var(--text-2); }
.cal-grid .day.sel { box-shadow: 0 0 0 2px var(--primary); }
.cal-grid .dc { font-size: .62rem; background: var(--good); color: #fff; border-radius: 999px; padding: 0 5px; line-height: 1.4; margin-top: 1px; }
.cal-foot { display: flex; gap: 12px; font-size: .74rem; color: var(--text-2); margin-top: 8px; align-items: center; }
.cal-foot .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.cal-foot .sw.has { background: var(--good-bg); border: 1px solid #9fd7a5; } .cal-foot .sw.miss { background: #fafafa; border: 1px solid var(--border); }
.chk-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.chk-custom { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.chk-custom input { width: 140px; }
.chk-result { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .85rem; color: var(--text-2); padding: 6px 0 8px; border-bottom: 1px dashed var(--border); margin-bottom: 4px; }
.chk-table td { font-size: .84rem; }
@media (max-width: 991.98px) { .chk-body { grid-template-columns: 1fr; } .cal { max-width: 360px; } .chk-stats { grid-template-columns: repeat(2, 1fr); } .chk-stats > div:first-child { grid-column: 1 / -1; } .chk-custom { margin-left: 0; } }

.monitor-tools { margin-bottom: 18px; }
.monitor-section .card-head { flex-wrap: wrap; }
.bulk-bar { display: flex; gap: 12px; align-items: center; }
.mon-list { border-top: 1px solid var(--border); }
.mon-item { display: grid; grid-template-columns: auto minmax(0, 1fr) 240px auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid #eef0f2; }
.mon-item:last-child { border-bottom: 0; }
.mon-item:not(:has(.mon-sel)) { grid-template-columns: minmax(0, 1fr) 240px auto; }
.mon-sel { width: 1.2rem; height: 1.2rem; margin: 0; }
.mon-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.mon-sub { color: var(--text-2); font-size: .82rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-note { color: var(--text-3); font-size: .78rem; margin-top: 2px; }
.mon-check .sub { color: var(--text-3); font-size: .74rem; }
.purge-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff8f8; border: 1px solid #f5d0d0; border-radius: var(--radius); padding: 8px 14px; margin-bottom: 12px; font-size: .88rem; }
@media (max-width: 767.98px) {
  .mon-item, .mon-item:not(:has(.mon-sel)) { grid-template-columns: auto minmax(0, 1fr); }
  .mon-item:not(:has(.mon-sel)) .mon-main { grid-column: 1 / -1; }
  .mon-check { grid-column: 2; }
  .mon-item:not(:has(.mon-sel)) .mon-check { grid-column: 1; }
  .mon-actions { grid-column: 2; justify-self: end; grid-row: auto; }
  .mon-item:not(:has(.mon-sel)) .mon-actions { grid-column: 2; grid-row: 2; }
  .mon-item .mon-sel { grid-row: span 2; align-self: start; margin-top: 4px; }
  .data-table.stack .c-check { order: 6; }
  .data-table.stack .c-status { order: 7; }
  .data-table.stack .c-actions { order: 8; }
  .modal-fullscreen-sm-down .seg-btn { padding: 12px; }
}

/* ===================== App Builder ===================== */
.app-badge { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: #fff; font-size: 1rem; flex-shrink: 0; }
.app-badge.lg { width: 42px; height: 42px; border-radius: 11px; font-size: 1.3rem; }
.min-w-0 { min-width: 0; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.app-card { padding: 16px; display: flex; flex-direction: column; margin: 0; }
.app-card.archived { opacity: .65; }
.app-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.app-card-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.app-card .sub { color: var(--text-3); font-size: .76rem; }
.app-stats { display: flex; gap: 14px; font-size: .82rem; color: var(--text-2); }
.app-new { align-items: center; justify-content: center; text-align: center; border: 2px dashed var(--border); color: var(--text-2); min-height: 180px; gap: 4px; }
.app-new i { font-size: 2rem; color: var(--primary); }
.app-new span { font-weight: 600; } .app-new small { color: var(--text-3); }
.app-new:hover { border-color: var(--primary); text-decoration: none; color: var(--primary); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.swatch input:checked + span { outline: 3px solid var(--text); outline-offset: 2px; }
.swatch input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.swatch.custom input[type=color] { position: static; opacity: 1; pointer-events: auto; width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 1.1rem; color: var(--text-2); }
.icon-pick input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.icon-pick input:focus-visible + span { outline: 2px solid var(--primary); }
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tpl-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-pick span { display: grid; grid-template-columns: 28px 1fr; gap: 0 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; height: 100%; }
.tpl-pick span i { grid-row: span 2; font-size: 1.3rem; }
.tpl-pick span small { color: var(--text-3); font-size: .76rem; }
.tpl-pick input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.note-box { background: #f2f4f7; border: 1px solid #e1e4e8; border-radius: 10px; padding: 9px 13px; font-size: .86rem; color: var(--text-2); }
.note-box i { color: var(--primary); }
.builder-tabs { margin-bottom: 16px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.builder-tabs .nav-link { white-space: nowrap; color: var(--text-2); }
.builder-tabs .nav-link.active { font-weight: 600; color: var(--text); }
.builder-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; position: sticky; top: 0; z-index: 15; }
.builder-section { padding: 12px 14px 14px; }
.bs-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.bs-head .sec-name { font-weight: 600; max-width: 360px; }
.sec-handle, .handle { cursor: grab; color: var(--text-3); font-size: 1.1rem; }
.field-list { display: flex; flex-direction: column; gap: 6px; min-height: 46px; border: 1px dashed transparent; border-radius: 10px; padding: 2px; }
.field-list:empty { border-color: var(--border); background: #fafbfc; }
.field-list:empty::after { content: 'ลากช่องมาวางที่นี่'; color: var(--text-3); font-size: .82rem; padding: 10px; text-align: center; }
.field-chip { display: grid; grid-template-columns: auto auto minmax(0, 1fr) 120px auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.field-chip:hover { border-color: #c7ccd4; }
.field-chip.hidden-field { opacity: .55; background: #fafafa; }
.field-chip .ftype { color: var(--primary); font-size: 1.05rem; }
.fc-label { font-weight: 600; font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.fc-meta { font-size: .76rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-actions { display: flex; align-items: center; }
.tag { font-size: .66rem; font-weight: 600; border-radius: 999px; padding: 0 7px; line-height: 1.6; }
.tag.sys { background: var(--muted-bg); color: var(--text-2); }
.tag.req { background: var(--critical-bg); color: var(--critical-ink); }
.tag.off { background: #fff4d9; color: var(--warning-ink); }
.drag-ghost { opacity: .4; background: var(--primary-soft); }
.sub-head, .sub-row { display: grid; grid-template-columns: 1.1fr 1.3fr 100px 1.3fr 36px; gap: 6px; align-items: center; }
.sub-head { font-size: .74rem; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.sub-row { margin-bottom: 6px; }
.builder-table td { vertical-align: middle; }
.builder-table .sub { color: var(--text-3); font-size: .74rem; }
.excel-list { display: flex; flex-direction: column; gap: 6px; }
.excel-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.xl-label .sub { color: var(--text-3); font-size: .74rem; }
.xl-subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
.xl-subs label { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.danger-zone { border-color: #f5c2c2; }
.repeater .rep-head, .repeater .rep-row { display: grid; gap: 8px; align-items: center; }
.repeater .rep-head { font-size: .76rem; color: var(--text-2); font-weight: 600; padding-bottom: 4px; }
.repeater .rep-row { margin-bottom: 6px; }
.repeater .seq { color: var(--text-3); font-size: .8rem; text-align: center; }
@media (max-width: 767.98px) {
  .field-chip { grid-template-columns: auto minmax(0, 1fr) auto; }
  .field-chip .ftype { display: none; }
  .field-chip .fc-width { grid-column: 2; }
  .field-chip .fc-actions { grid-row: span 2; grid-column: 3; grid-row-start: 1; }
  .sub-head { display: none; }
  .sub-row { grid-template-columns: 1fr 1fr; }
  .excel-row { grid-template-columns: auto auto 1fr; }
  .excel-row .xl-head, .excel-row .xl-subs { grid-column: 1 / -1; }
  .repeater .rep-head { display: none; }
  .repeater .rep-row { grid-template-columns: 24px 1fr 36px !important; }
  .repeater .rep-row input:not(:first-of-type) { grid-column: 2; }
}
.field-chip { grid-template-columns: auto auto minmax(0, 1fr) 120px 112px; }
.fc-actions { justify-content: flex-end; }
input[readonly].form-control { background: #f3f4f6; color: var(--text-2); }
@media (max-width: 767.98px) { .field-chip { grid-template-columns: auto minmax(0, 1fr) auto; } }

.note-target { margin-top: 10px; background: var(--info-bg); border-radius: 8px; padding: 8px 10px; font-size: .86rem; }
.note-target #noteCurrent { color: var(--text); }
.export-preview { display: flex; flex-wrap: wrap; gap: 6px 16px; background: var(--muted-bg); border-radius: 8px; padding: 8px 12px; margin-top: 10px; font-size: .86rem; }

/* ===== สถานะอุปกรณ์รายตัว (หน้าต่างบันทึกการตรวจ / หน้ารายละเอียด / ติดตามงาน) ===== */
.dv-box { border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem .75rem; background: #fafbfc; }
.dv-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; }
.dv-list { display: flex; flex-direction: column; gap: .4rem; }
.dv-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; align-items: center; gap: .3rem .55rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: .45rem .5rem; }
.dv-row.is-crit { border-left-color: var(--critical); }
.dv-row.is-warn { border-left-color: var(--warning); }
.dv-row.is-retire { opacity: .55; }
.dv-row.is-retire .dv-name { text-decoration: line-through; }
.dv-no { width: 22px; height: 22px; border-radius: 50%; background: var(--muted-bg); color: var(--text-2); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }
.dv-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.dv-meta { font-size: .76rem; color: var(--text-2); display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin-top: 2px; }
.dv-meta .status { font-size: .7rem; padding: 0 7px 0 5px; }
.dv-changed { color: var(--primary); font-weight: 600; }
.dv-prevnote { font-size: .76rem; color: var(--text-3); margin-top: 2px; }
.dv-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.dv-st { border: 0; background: transparent; padding: .28rem .6rem; font-size: .76rem; font-weight: 600; color: var(--text-3); display: inline-flex; align-items: center; gap: 4px; }
.dv-st + .dv-st { border-left: 1px solid var(--border); }
.dv-st i { font-size: .8rem; }
.dv-st:hover:not(:disabled) { background: var(--muted-bg); }
.dv-st.on.st-good { background: var(--good-bg); color: var(--good-ink); }
.dv-st.on.st-warning { background: var(--warning-bg); color: var(--warning-ink); }
.dv-st.on.st-critical { background: var(--critical-bg); color: var(--critical-ink); }
.dv-st:not(.on) i { color: inherit !important; }
.dv-st.on.st-good i { color: var(--good); } .dv-st.on.st-warning i { color: var(--warning); } .dv-st.on.st-critical i { color: var(--critical); }
.dv-more.on { background: var(--muted-bg); }
.dv-extra { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; }
.dv-extra .dv-note { flex: 1 1 240px; }
.dv-add-form { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: .35rem; }
.dv-summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .45rem; padding: .4rem .55rem; border-radius: 8px; background: var(--primary-soft); color: var(--info-ink); }
@media (max-width: 575.98px) {
  .dv-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .dv-seg { grid-column: 2 / 3; justify-self: start; }
  .dv-more { grid-row: 1; grid-column: 3; }
  .dv-st span { display: none; }
  .dv-st { padding: .32rem .7rem; }
  .dv-st.on span { display: inline; }
  .dv-add-form { grid-template-columns: 1fr 1fr; }
  .dv-add-form .btn { grid-column: 1 / -1; }
  .dv-summary { flex-direction: column; align-items: stretch; }
}

.dev-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; padding: 1px 8px; border-radius: 999px; background: var(--muted-bg); color: var(--text-2); white-space: nowrap; }
.dev-chip.crit { background: var(--critical-bg); color: var(--critical-ink); }
.dev-chip.warn { background: var(--warning-bg); color: var(--warning-ink); }
.dev-chip.ok { background: var(--good-bg); color: var(--good-ink); }
.dev-chip b { font-weight: 700; }
.dev-chip .dc-unk { color: var(--text-3); }

/* ชิปสถานะอุปกรณ์ในประวัติการตรวจ */
.chk-devs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chk-dev { font-size: .72rem; padding: 1px 7px; border-radius: 6px; background: var(--muted-bg); color: var(--text-2); white-space: normal; overflow-wrap: anywhere; }
.chk-dev.Critical { background: var(--critical-bg); color: var(--critical-ink); }
.chk-dev.Warning { background: var(--warning-bg); color: var(--warning-ink); }
.chk-dev.Normal { background: var(--good-bg); color: var(--good-ink); }
.chk-dev.chg { outline: 1.5px solid currentColor; font-weight: 600; }

/* การ์ดอุปกรณ์ในหน้ารายละเอียด */
.dev-table td { vertical-align: middle; }
.dev-table .dv-retired td { color: var(--text-3); }
.dev-chip.sm { font-size: .7rem; padding: 0 7px; margin-top: 3px; }

/* ===== ลบข้อมูลหลายรายการ (admin) ===== */
.purge-opts { display: flex; flex-direction: column; gap: .5rem; }
.purge-opt { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; cursor: pointer; }
.purge-opt:has(input:checked) { border-color: var(--critical); background: var(--critical-bg); }
.purge-opt:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.purge-opt .form-check-input { margin-top: .25rem; flex-shrink: 0; }
.purge-opt small { display: block; color: var(--text-2); }
.count-pill.danger { background: var(--critical-bg); color: var(--critical-ink); }

/* การ์ดที่เพิ่งตรวจในหน้า "ติดตามงานวันนี้" */
.mon-item.just-checked { animation: justChecked 2.5s ease-out; }
@keyframes justChecked { 0%, 30% { background: var(--good-bg); } 100% { background: transparent; } }
tr.just-checked > td { animation: justChecked 2.5s ease-out; }

/* ===== หน้า "ภาพรวม": คอลัมน์ขวา (Google Calendar + Task) ===== */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.dash-main { min-width: 0; }
.dash-main > .chart-grid { margin-top: 0; }
.dash-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; }
@media (max-width: 1279.98px) {
  .dash-layout { grid-template-columns: minmax(0, 1fr); }
  .dash-side { order: -1; position: static; }
}
.cal-empty { text-align: center; padding: 1rem 1.25rem 1.25rem; color: var(--text-2); font-size: .88rem; }
.cal-empty > i { font-size: 1.6rem; color: var(--primary); display: block; margin-bottom: .35rem; }
.cal-list { max-height: 520px; overflow-y: auto; padding: 0 .75rem .5rem; }
.cal-day { padding-top: .5rem; }
.cal-day.past { opacity: .6; }
.cal-day-head { display: flex; align-items: baseline; gap: .5rem; font-weight: 700; font-size: .82rem; color: var(--text-2); padding: .25rem 0; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.cal-day.today .cal-day-head span { color: var(--primary); }
.cal-day-head small { font-weight: 400; color: var(--text-3); }
.cal-ev { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.cal-ev:last-child { border-bottom: 0; }
.cal-time { font-size: .8rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.cal-time small { display: block; font-weight: 400; color: var(--text-3); }
.cal-title { font-weight: 600; font-size: .88rem; line-height: 1.35; overflow-wrap: anywhere; }
.cal-meta { font-size: .76rem; color: var(--text-2); overflow-wrap: anywhere; }
.cal-ev .status { text-decoration: none; display: inline-flex; }
.cal-ev .btn-sm { padding: .1rem .5rem; font-size: .76rem; }
.cal-foot { padding: .4rem .9rem .7rem; border-top: 1px solid var(--border); }
.task-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: 0 .9rem .6rem; }
.task-stats a { display: flex; flex-direction: column; align-items: center; padding: .45rem; border-radius: 8px; background: var(--muted-bg); color: var(--text); text-decoration: none; }
.task-stats a.hot { background: var(--info-bg); color: var(--info-ink); }
.task-stats .val { font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.task-stats .lbl { font-size: .74rem; color: var(--text-2); }
.task-mini { display: flex; flex-direction: column; }
.task-mini-item { display: flex; flex-direction: column; gap: 2px; padding: .55rem .9rem; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.task-mini-item:hover { background: var(--muted-bg); text-decoration: none; }
.task-mini-item .status { align-self: flex-start; font-size: .72rem; }
.nav-count.task { background: var(--primary); }

/* ===== หน้า Task ===== */
.task-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.task-tabs .chip { text-decoration: none; }
.task-tabs .chip.alert:not(.on) { border-color: var(--info); color: var(--info-ink); }
.task-list { display: flex; flex-direction: column; }
.task-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .75rem 1rem; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.task-item:first-child { border-top: 0; }
.task-item:hover { background: #fafbfc; text-decoration: none; }
.task-item.cancelled, .task-item.approved { opacity: .8; }
.task-when { display: flex; flex-direction: column; line-height: 1.25; }
.task-when strong { font-size: .86rem; }
.task-when small { color: var(--text-2); }
.task-title { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.task-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .78rem; color: var(--text-2); margin-top: 2px; }
.task-state { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
@media (max-width: 767.98px) {
  .task-item { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .task-when { flex-direction: row; gap: .4rem; align-items: baseline; }
  .task-state { flex-direction: row; justify-content: space-between; align-items: center; }
}
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
.task-col-main { min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.task-col-main > .card { margin: 0; }
.task-col-side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; }
.task-col-side > .card, .task-col-side > .alert { margin: 0; }
@media (max-width: 1099.98px) {
  .task-layout { grid-template-columns: minmax(0, 1fr); }
  .task-col-side { order: -1; position: static; }
}
.site-status-list { display: flex; flex-direction: column; }
.site-status { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .65rem 1rem; border-top: 1px solid var(--border); }
.site-status:first-child { border-top: 0; }
.ss-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .88rem; }
@media (max-width: 575.98px) { .site-status { grid-template-columns: minmax(0, 1fr) auto; } .ss-check { grid-column: 1; } }
.report { padding: .75rem 1rem; border-top: 1px solid var(--border); }
.report.latest { background: #fafcff; }
.report-head { margin-bottom: .25rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; margin-top: .5rem; }
.photo-grid a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--muted-bg); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.photo-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: .5rem; margin-top: .5rem; }
.photo-preview .ph { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--muted-bg); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.ph-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: .7rem; display: grid; place-items: center; }
.approve-box { border-left: 4px solid var(--good); }
.task-timeline { padding: .5rem 1rem 1rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
/* มีคอลัมน์ปฏิทินด้านขวา -> กราฟเหลือ 2 คอลัมน์จนกว่าจอจะกว้างมาก */
@media (min-width: 1280px) and (max-width: 1799.98px) {
  .dash-main > .chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.dash-main .chart-grid .card .table { min-width: 0; }
.dash-main .chart-grid .data-table td:first-child { overflow-wrap: anywhere; }

/* ===== เมนูซ้ายบนมือถือ: เลื่อนได้ และเห็นส่วนผู้ใช้/ออกจากระบบเสมอ =====
   100vh บนมือถือรวมพื้นที่ใต้แถบเครื่องมือของเบราว์เซอร์ -> ส่วนล่างของเมนูถูกบัง: ใช้ 100dvh แทน */
.sidebar { height: 100vh; height: 100dvh; }
.nav-list { min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sidebar-foot { flex-shrink: 0; }
@media (max-width: 991.98px) {
  .sidebar { width: min(280px, 86vw); padding-bottom: max(12px, env(safe-area-inset-bottom)); padding-top: max(18px, env(safe-area-inset-top)); }
  .sidebar-foot { padding-bottom: 4px; }
  .btn-logout { padding: 10px 12px; font-size: 1.15rem; }
  body.menu-open { overflow: hidden; }
}
@media (max-width: 991.98px) and (max-height: 520px) {
  /* จอเตี้ย (มือถือแนวนอน): ให้ทั้งเมนูเลื่อนได้ */
  .sidebar { overflow-y: auto; }
  .nav-list { flex: none; overflow: visible; }
}
.topbar-user { padding: 2px; }
.avatar.sm { width: 30px; height: 30px; font-size: .85rem; }

/* สถานะการอัปโหลดรูปรายงาน Task */
.photo-preview .ph-state { position: absolute; left: 4px; bottom: 4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; color: #fff; }
.photo-preview .ph.queued img, .photo-preview .ph.uploading img { opacity: .55; }
.photo-preview .ph.queued .ph-state::after, .photo-preview .ph.uploading .ph-state::after { content: ''; width: 16px; height: 16px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: phspin .8s linear infinite; }
.photo-preview .ph.uploading .ph-state, .photo-preview .ph.queued .ph-state { background: rgba(0, 0, 0, .45); }
.photo-preview .ph.done .ph-state { background: var(--good); }
.photo-preview .ph.done .ph-state::after { content: '✓'; font-weight: 700; }
.photo-preview .ph.error { outline: 2px solid var(--critical); cursor: pointer; }
.photo-preview .ph.error .ph-state { background: var(--critical); }
.photo-preview .ph.error .ph-state::after { content: '↻'; font-weight: 700; }
@keyframes phspin { to { transform: rotate(360deg); } }
.photo-preview { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: .4rem; }
.photo-preview .ph-del { width: 22px; height: 22px; top: 3px; right: 3px; }
.photo-preview .ph-state { width: 20px; height: 20px; left: 3px; bottom: 3px; }

/* ===== Task แบบโพสต์ (Facebook style) ===== */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.view-toggle a { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; font-size: .8rem; color: var(--text-2); text-decoration: none; }
.view-toggle a + a { border-left: 1px solid var(--border); }
.view-toggle a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.task-tabs { align-items: center; }
@media (max-width: 575.98px) { .view-toggle { margin-left: 0 !important; } .view-toggle span { display: none; } .view-toggle a { padding: 5px 12px; font-size: .95rem; } }
.feed { max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.feed > .card { margin: 0; }
.post { overflow: hidden; }
.post-head { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem .5rem; }
.post-head .avatar { width: 40px; height: 40px; font-size: 1rem; background: var(--primary); }
.post-head strong { display: block; line-height: 1.2; }
.post-head small { color: var(--text-2); font-size: .78rem; }
.min-w-0 { min-width: 0; }
.post-body { padding: 0 1rem .65rem; }
.post-title { display: block; font-weight: 700; font-size: 1.02rem; color: var(--text); text-decoration: none; margin-bottom: .15rem; }
.post-title:hover { color: var(--primary); }
.post-meta { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .8rem; color: var(--text-2); }
.post-text { margin: .5rem 0 0; font-size: .95rem; line-height: 1.55; }
.post-foot { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .6rem 1rem .75rem; border-top: 1px solid var(--border); font-size: .84rem; }
.post-photos { display: grid; gap: 3px; background: var(--surface); }
.post-photos a { position: relative; display: block; overflow: hidden; background: var(--muted-bg); }
.post-photos img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.post-photos a:hover img { transform: scale(1.02); }
.post-photos .more, .task-thumbs .more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-weight: 700; font-size: 1.6rem; }
.post-photos.n-1 a { max-height: 560px; }
.post-photos.n-1 img { max-height: 560px; }
.post-photos.n-2 { grid-template-columns: 1fr 1fr; }
.post-photos.n-2 a { aspect-ratio: 1; }
.post-photos.n-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 4 / 3; }
.post-photos.n-3 a:first-child { grid-row: span 2; }
.post-photos.n-4 { grid-template-columns: 1fr 1fr; }
.post-photos.n-4 a { aspect-ratio: 1; }
.post-photos.n-5 { grid-template-columns: repeat(6, 1fr); }
.post-photos.n-5 a:nth-child(-n+2) { grid-column: span 3; aspect-ratio: 1; }
.post-photos.n-5 a:nth-child(n+3) { grid-column: span 2; aspect-ratio: 1; }
/* รูปย่อในรายการแบบย่อ */
.task-item { position: relative; }
.task-thumbs { position: relative; z-index: 2; display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.task-thumbs a { position: relative; width: 52px; height: 52px; border-radius: 6px; overflow: hidden; background: var(--muted-bg); display: block; }
.task-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.task-thumbs .more { font-size: .9rem; }
/* ดูรูปเต็มจอ */
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .92); display: none; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 96vw; max-height: 86vh; max-height: 86dvh; object-fit: contain; user-select: none; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: .5rem; padding: max(10px, env(safe-area-inset-top)) 12px 10px; color: #fff; }
.lb-count { margin-right: auto; font-size: .9rem; opacity: .85; }
.lb-btn { background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; }
.lb-btn:hover { background: rgba(255, 255, 255, .25); color: #fff; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .12); border: 0; color: #fff; width: 46px; height: 46px; border-radius: 50%; font-size: 1.3rem; display: grid; place-items: center; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (max-width: 575.98px) { .lb-nav { width: 38px; height: 38px; background: rgba(0, 0, 0, .35); } .lb-prev { left: 4px; } .lb-next { right: 4px; } }
body.lb-lock { overflow: hidden; }
.task-item > .stretched-link { position: absolute; inset: 0; z-index: 1; }
.task-item > .stretched-link::after { display: none; }
@media (max-width: 575.98px) { .task-thumbs { flex-wrap: nowrap; } .task-thumbs a { width: 44px; height: 44px; flex-shrink: 0; } }

/* ---------- สลับมุมมอง Task (รายการ / ปฏิทิน) ---------- */
.page-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--muted-bg); border-radius: 10px; margin-bottom: 14px; }
.page-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 16px; border-radius: 8px; font-size: .88rem; color: var(--text-2); text-decoration: none; font-weight: 500; }
.page-switch a:hover { color: var(--text); }
.page-switch a.on { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

/* ---------- ปฏิทิน Task ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.todo { background: var(--warning); }
.dot.rej { background: var(--critical); }
.dot.sub { background: var(--info); }
.dot.done { background: var(--good); }
.dot.cancel { background: #b7bcc4; }
.dot.ghost { background: transparent; border: 1.5px dashed var(--text-3); }

.tcal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.tcal { padding: 0; overflow: hidden; }
.tcal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.tcal-nav { display: flex; align-items: center; gap: 4px; }
.tcal-nav h2 { font-size: 1.2rem; font-weight: 700; margin: 0 6px; min-width: 150px; text-align: center; }
.tcal-nav .btn-icon { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); padding: 0; color: var(--text-2); }
.tcal-nav .btn-icon:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.tcal-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.tcal-filter .chip { display: inline-flex; align-items: center; gap: 6px; }
.tcal-filter .chip b { font-weight: 600; color: var(--text); }

.tcal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.tcal-dow { padding: 8px 10px; font-size: .76rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; border-bottom: 1px solid var(--border); background: #fafbfc; }
.tcal-dow.we { color: var(--critical-ink); opacity: .75; }
.tcal-day { all: unset; box-sizing: border-box; position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 112px; padding: 6px 6px 8px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; background: var(--surface); transition: background .12s; min-width: 0; }
.tcal-day:nth-child(7n) { border-right: 0; }
.tcal-day:hover { background: #f7f9fc; }
.tcal-day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tcal-day.out { background: #fafbfc; }
.tcal-day.out .tcal-num { color: #b7bcc4; }
.tcal-day.sel { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.tcal-num { align-self: flex-start; display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 13px; font-size: .85rem; font-weight: 600; color: var(--text); }
.tcal-day.today .tcal-num { background: var(--primary); color: #fff; }
.tcal-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tchip { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .74rem; line-height: 1.35; padding: 2px 6px; border-radius: 5px;
  border-left: 3px solid var(--text-3); background: var(--muted-bg); color: var(--text); }
.tchip .tt { font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tchip.todo { border-color: var(--warning); background: var(--warning-bg); }
.tchip.rej { border-color: var(--critical); background: var(--critical-bg); }
.tchip.sub { border-color: var(--info); background: var(--info-bg); }
.tchip.done { border-color: var(--good); background: var(--good-bg); }
.tchip.done, .tchip.cancel { color: var(--text-2); }
.tchip.cancel { border-color: #b7bcc4; text-decoration: line-through; }
.tchip.ghost { background: transparent; border: 1px dashed #aab0ba; border-left-width: 1px; color: var(--text-2); }
.tmore { font-size: .72rem; color: var(--text-3); padding-left: 4px; font-weight: 500; }
.tcal-dots { display: none; }
.tcal-day.past:not(.today) .tchip.todo, .tcal-day.past:not(.today) .tchip.rej { box-shadow: inset 0 0 0 1px rgba(208,59,59,.35); } /* เลยกำหนดแล้วยังไม่เสร็จ */
.tchip.dim, .tday-item.dim, .tcal-dots .dim { opacity: .18; }
.tday-item.dim { display: none; }

.tcal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); }
.tcal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* รายการของวัน */
.tcal-side { position: sticky; top: 76px; scroll-margin-top: 70px; }
.tday { padding: 0; overflow: hidden; }
.tday-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.tday-head strong { font-size: 1rem; }
.tday-rel { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 1px 8px; margin-right: 8px; vertical-align: 2px; }
.tday-list { max-height: calc(100vh - 220px); overflow-y: auto; }
.tday-item { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; position: relative; }
.tday-item:last-child { border-bottom: 0; }
.tday-item::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--text-3); }
.tday-item.todo::before { background: var(--warning); }
.tday-item.rej::before { background: var(--critical); }
.tday-item.sub::before { background: var(--info); }
.tday-item.done::before { background: var(--good); }
.tday-item.cancel::before { background: #b7bcc4; }
.tday-item.ghost::before { background: none; border-left: 2px dashed #aab0ba; }
a.tday-item:hover { background: #f7f9fc; color: inherit; }
.tday-time { font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.3; }
.tday-time small { display: block; font-weight: 400; color: var(--text-3); }
.tday-body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tday-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.tday-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .78rem; color: var(--text-2); }
.tday-meta i { color: var(--text-3); }
.tday-note { font-size: .8rem; color: var(--text-2); background: var(--muted-bg); border-radius: 8px; padding: 6px 9px; white-space: pre-line; align-self: stretch; }
.tday-photos { display: flex; gap: 4px; }
.tday-photos img, .tday-photos span { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; background: var(--muted-bg); }
.tday-photos span { display: grid; place-items: center; font-size: .78rem; font-weight: 600; color: var(--text-2); }

@media (max-width: 1279.98px) { .tcal-layout { grid-template-columns: minmax(0, 1fr) 320px; } .tcal-day { min-height: 96px; } }
@media (max-width: 991.98px) {
  .tcal-layout { grid-template-columns: minmax(0, 1fr); }
  .tcal-side { position: static; }
  .tday-list { max-height: none; }
}
@media (max-width: 767.98px) {
  .tcal-head { padding: 12px 10px 8px; }
  .tcal-nav { width: 100%; justify-content: center; }
  .tcal-nav h2 { font-size: 1.08rem; min-width: 0; flex: 1; }
  .tcal-filter { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .tcal-filter::-webkit-scrollbar { display: none; }
  .tcal-filter .chip { white-space: nowrap; }
  .tcal-dow { padding: 6px 0; text-align: center; font-size: .72rem; }
  .tcal-day { min-height: 58px; padding: 4px 2px 6px; align-items: center; gap: 3px; }
  .tcal-num { align-self: center; font-size: .82rem; min-width: 28px; height: 28px; border-radius: 14px; }
  .tcal-chips { display: none; }
  .tcal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 100%; }
  .tcal-dots .dot { width: 6px; height: 6px; }
  .tcal-dots small { font-size: .62rem; color: var(--text-3); line-height: 6px; }
  .tcal-day.sel { box-shadow: none; background: transparent; }
  .tcal-day.sel .tcal-num { box-shadow: 0 0 0 2px var(--primary); }
  .tcal-day.sel.today .tcal-num { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
  .tcal-legend { padding: 8px 10px; gap: 4px 12px; font-size: .74rem; }
  .page-switch { display: flex; }
  .page-switch a { flex: 1; justify-content: center; }
}
.tcal-layout .card { margin-bottom: 0; }

/* ---------- เลือกหลายรายการในหน้ารายงาน ---------- */
.data-table .c-sel { width: 36px; padding-right: 0 !important; }
.data-table .c-sel .form-check-input { width: 1.1em; height: 1.1em; margin: 0; cursor: pointer; vertical-align: middle; }
.data-table tbody tr.row-selected > td { background: var(--primary-soft) !important; }
.sel-banner { padding: 8px 16px; font-size: .86rem; background: var(--primary-soft); color: var(--text); border-bottom: 1px solid #cfdcf3; text-align: center; }
.sel-banner .btn-link { vertical-align: baseline; font-size: inherit; }

.sel-bar { position: fixed; z-index: 1040; left: 50%; bottom: 20px; transform: translateX(calc(-50% + 120px)); display: flex; align-items: center; gap: 14px;
  background: #16181d; color: #fff; border-radius: 14px; padding: 8px 8px 8px 10px; box-shadow: 0 10px 30px rgba(16,24,40,.28); animation: selIn .18s ease-out; max-width: calc(100vw - 280px); }
@keyframes selIn { from { opacity: 0; transform: translate(calc(-50% + 120px), 12px); } }
.sel-info { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: .92rem; }
.sel-info strong { font-variant-numeric: tabular-nums; }
.sel-clear { color: #c9ced8; width: 32px; height: 32px; border-radius: 8px; }
.sel-clear:hover { background: rgba(255,255,255,.12); color: #fff; }
.sel-actions { display: flex; gap: 6px; }
.sel-actions .btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.sel-actions .btn-light { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.sel-actions .btn-light:hover { background: rgba(255,255,255,.2); color: #fff; }
.sel-actions .btn-light.text-danger { color: #ff9b9b !important; }
.sel-actions .btn-light.text-danger:hover { background: rgba(208,59,59,.35); color: #fff !important; }
body.has-sel .content { padding-bottom: 96px; }

.be-row { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) 36px; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.be-row:last-child { border-bottom: 0; }
.be-row .be-del { margin-top: 2px; }
.bd-list { list-style: none; padding: 0; margin: 0 0 12px; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow: auto; }
.bd-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: .88rem; }
.bd-list li:last-child { border-bottom: 0; }
.bd-list li small { color: var(--text-3); white-space: nowrap; }
.bd-list li.more { color: var(--text-2); justify-content: center; }
.bd-list:empty { display: none; }

@media (max-width: 991.98px) {
  .sel-bar { transform: translateX(-50%); max-width: calc(100vw - 24px); }
  @keyframes selIn { from { opacity: 0; transform: translate(-50%, 12px); } }
}
@media (max-width: 767.98px) {
  .data-table.stack tbody tr[data-row] { position: relative; padding-left: 48px; }
  .data-table.stack td.c-sel { position: absolute; left: 0; top: 0; bottom: 0; width: 46px; padding: 14px 0 0 16px !important; }
  .data-table.stack td.c-sel .form-check-input { width: 1.3em; height: 1.3em; }
  .data-table.stack tbody tr.row-selected { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
  .data-table.stack tbody tr.row-selected > td { background: transparent !important; }
  .sel-bar { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); transform: none; max-width: none; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; }
  @keyframes selIn { from { opacity: 0; transform: translateY(12px); } }
  .sel-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .sel-actions .btn { flex-direction: column; gap: 2px; font-size: .78rem; padding: 6px 4px; }
  .sel-actions .btn i { font-size: 1.15rem; }
  body.has-sel .fab { display: none; }
  body.has-sel .content { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .be-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .be-row .be-value { grid-column: 1 / 2; grid-row: 2; }
  .be-row .be-del { grid-column: 2; grid-row: 1; }
}

/* จุดสถานะอุปกรณ์หน้าแถวในตารางรายการอุปกรณ์ (ฟอร์มแก้ไข) */
.rep-row .seq { position: relative; }
.rep-row[data-st] .seq::after { content: ''; position: absolute; left: -2px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; }
.rep-row[data-st="Critical"] .seq::after { background: var(--critical); }
.rep-row[data-st="Warning"] .seq::after { background: var(--warning); }
.rep-row[data-st="Normal"] .seq::after { background: var(--good); }
.rep-row[data-st="none"] .seq::after { background: #b7bcc4; }
.rep-row[data-st="new"] .seq::after { background: transparent; border: 1.5px dashed var(--primary); }
.rep-row[data-st=""] .seq::after { display: none; }
.rep-row[data-st] .seq { padding-left: 10px; }

/* Task ของไซต์นี้ (หน้ารายละเอียดรายงาน) */
.site-task-list { display: flex; flex-direction: column; }
.site-task { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.site-task:hover { background: #f7f9fc; color: inherit; }
.site-task .st-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-task .st-meta { font-size: .8rem; color: var(--text-2); white-space: nowrap; }
@media (max-width: 767.98px) {
  .site-task { grid-template-columns: minmax(0, 1fr); }
  .site-task .st-title { white-space: normal; }
}

/* งานเลยกำหนด (หน้าปฏิทิน Task) */
.overdue-box { padding: 0; margin-bottom: 14px; border-color: #f3c9c9; overflow: hidden; }
.ov-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--critical-bg); color: var(--critical-ink); }
.ov-list { display: flex; gap: 10px; overflow-x: auto; padding: 10px 16px 12px; scrollbar-width: thin; }
.ov-item { flex: 0 0 260px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 8px 12px; border: 1px solid var(--border); border-left: 3px solid var(--warning); border-radius: 8px; color: inherit; text-decoration: none; background: var(--surface); }
.ov-item.rej { border-left-color: var(--critical); }
.ov-item:hover { border-color: var(--primary); color: inherit; }
.ov-days { grid-row: span 2; align-self: center; font-weight: 700; color: var(--critical-ink); font-size: .85rem; white-space: nowrap; }
.ov-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-meta { font-size: .76rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767.98px) {
  .ov-list { flex-direction: column; overflow: visible; padding: 8px 10px 10px; gap: 6px; }
  .ov-item { flex: none; }
  .tcal-day { min-height: 48px; }
}
.chk-tasks { border: 1px solid #cfdcf3; background: var(--primary-soft); border-radius: 10px; padding: 8px 10px; }
.chk-task { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: center; padding: 4px 0; color: inherit; text-decoration: none; font-size: .86rem; }
.chk-task + .chk-task { border-top: 1px solid #dbe5f6; }
.chk-task .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk-task .m { grid-column: 2; font-size: .76rem; color: var(--text-2); }
.chk-task:hover .t { color: var(--primary); }
.chk-task, .chk-task * { text-decoration: none !important; }

/* ---------- ปฏิทิน: กิจกรรมจาก Google Calendar (ทุกคนเห็น) ---------- */
:root { --ev: #6d4fd8; --ev-bg: #f1edfd; }
.dot.ghost { background: var(--ev); border: 0; }
.tchip.ghost { background: var(--ev-bg); border: 0; border-left: 3px solid var(--ev); color: var(--text); }
.tday-item.ghost::before { background: var(--ev); border-left: 0; }
.tcal-sync { padding: 0 16px 10px; }
.tcal-sync a { text-decoration: none; }
@media (max-width: 767.98px) { .tcal-sync { padding: 0 10px 8px; text-align: center; } }

/* ---------- แจ้งเตือน LINE ---------- */
.line-checks { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.line-checks li { display: flex; align-items: baseline; gap: 8px; }
.line-checks li.ok i { color: var(--good); }
.line-checks li.bad i { color: var(--critical); }
.line-checks li.warn i { color: var(--text-3); }
.line-chats { list-style: none; padding: 0; margin: 0; }
.line-chats li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.line-chats li:first-child { border-top: 0; }
.line-chats li.left { opacity: .55; }
.ln-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e7f8ec; color: #06c755; flex: none; }
.ln-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ln-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ln-name small { color: var(--text-2); }
.line-phone { background: #8fa8c8; border-radius: 14px; padding: 16px 12px; max-height: 520px; overflow: auto; }
.line-bubble { background: #fff; border-radius: 4px 16px 16px 16px; padding: 10px 12px; white-space: pre-wrap; font-size: .86rem; line-height: 1.5; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.08); overflow-wrap: anywhere; }
@media (min-width: 992px) { .line-preview-card { position: sticky; top: 76px; } }
.c-ev { color: var(--ev); }
/* เลือกหลายห้องแชต */
.line-chats li { padding: 10px 8px; border-radius: 10px; gap: 10px; }
.line-chats li.is-on { background: #eefaf2; }
.line-chats .ln-pick { width: 1.2em; height: 1.2em; margin: 0; flex: none; cursor: pointer; }
.line-chats label.ln-ico, .line-chats label.ln-name { cursor: pointer; margin: 0; }
.ln-ico.bc { background: #fff4e0; color: #d98200; }
.ln-rename { max-width: 320px; font-weight: 600; border-color: transparent; background: transparent; padding-left: 4px; }
.ln-rename:hover, .ln-rename:focus { border-color: var(--border); background: var(--surface); }
.ln-add summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
/* ผูกห้องด้วยข้อความ */
.ln-bind { border: 1px dashed #9fd9b4; background: #f3fbf6; border-radius: 12px; padding: 14px 16px; }
.ln-bind-step { font-size: .9rem; font-weight: 600; margin-bottom: 8px; }
.ln-bind-code { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ln-bind-code code { font-size: 1.5rem; font-weight: 700; letter-spacing: .06em; color: #06a347; background: #fff; border: 1px solid #c9ecd6; border-radius: 10px; padding: 6px 14px; }
.ln-bind-meta { font-size: .8rem; color: var(--text-2); margin-top: 8px; }
.ln-bind-wait { margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.ln-bind-wait .spinner-grow { width: .6rem; height: .6rem; color: #06c755; }

/* หน้าตรวจระบบ: คำแนะนำอยู่ใต้รายการ */
.sys-checks li { flex-wrap: wrap; }
.sys-checks .sys-hint { flex-basis: 100%; padding-left: 24px; margin-top: -2px; }
