:root {
  color-scheme: light;
  --ink: #18202c;
  --muted: #667085;
  --line: #e5e7eb;
  --surface: #ffffff;
  --background: #f4f6f8;
  --red: #9f2436;
  --red-dark: #761827;
  --amber: #b86207;
  --green: #18794e;
  --blue: #2457a6;
  --shadow: 0 12px 32px rgba(18, 28, 45, 0.08);
}

* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans Thai", sans-serif; background: var(--background); color: var(--ink); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.drill-ribbon {
  position: sticky; top: 0; z-index: 20; padding: 8px 16px; text-align: center;
  color: #fff; background: repeating-linear-gradient(135deg, #8b1e2d, #8b1e2d 18px, #671521 18px, #671521 36px);
  font-size: 13px; font-weight: 800; letter-spacing: .08em;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px max(24px, calc((100vw - 1180px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 19px; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.connection-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-weight: 800; background: #eef1f4; }
.connection-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.connection-pill.is-online { color: #12653f; background: #e1f2e9; }
.connection-pill.is-online::before { background: var(--green); }
.connection-pill.is-offline { color: #8b1e2d; background: #fdeaec; }
.connection-pill.is-offline::before { background: var(--red); }
.shell { width: min(1180px, calc(100% - 32px)); margin: 28px auto 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.card h2 { margin: 5px 0 12px; font-size: 22px; }
.card p { color: var(--muted); line-height: 1.6; }
.login-card { max-width: 560px; margin: 8vh auto; padding: 36px; text-align: center; }
.eyebrow { color: var(--red); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.grid { display: grid; gap: 20px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
.compact { margin-top: 20px; box-shadow: none; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.button { border: 0; border-radius: 12px; min-height: 44px; padding: 10px 16px; font-weight: 750; transition: transform .15s ease, background .15s ease; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.primary { color: #fff; background: var(--red); }
.primary:hover { background: var(--red-dark); }
.secondary { color: #fff; background: var(--blue); }
.warning { color: #fff; background: var(--amber); }
.success { color: #fff; background: var(--green); }
.danger-outline { color: var(--red); background: #fff; border: 2px solid var(--red); }
.ghost { color: var(--ink); background: #eef1f4; }
.wide { display: flex; width: 100%; align-items: center; justify-content: center; text-decoration: none; margin-top: 16px; }

label { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #ccd1d8; border-radius: 11px; padding: 11px 12px; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(36, 87, 166, .16); border-color: var(--blue); }
textarea { resize: vertical; }
.note { margin: 12px 0 0; font-size: 12px; }
.inline-form { display: flex; gap: 10px; margin-top: 12px; }
.inline-form input { flex: 1; }

.incident-panel { display: flex; justify-content: space-between; gap: 24px; align-items: center; border-radius: 18px; padding: 24px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow); }
.incident-panel.active { color: #fff; background: linear-gradient(135deg, #9f2436, #651522); border-color: transparent; }
.incident-panel.resolved { background: #e8f5ee; border-color: #b7dfca; }
.incident-panel h2 { margin: 7px 0 4px; }
.incident-panel p { margin: 0; line-height: 1.5; }
.incident-panel.active p, .incident-panel.active small { color: #fff; }
.incident-guidance { margin: 12px 0 8px; padding-left: 22px; line-height: 1.55; font-size: 14px; }
.incident-guidance li + li { margin-top: 3px; }
.incident-actions { display: flex; flex-wrap: wrap; gap: 10px; min-width: 280px; justify-content: flex-end; }
.pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #eef1f4; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.active .pill { background: rgba(255,255,255,.18); }

.checklist { padding: 0; margin: 16px 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.checklist li.ok { color: var(--green); font-weight: 700; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: #c9ced5; box-shadow: 0 0 0 4px #f1f3f5; }
.ok .status-dot { background: var(--green); box-shadow: 0 0 0 4px #e1f2e9; }
.score { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: #f0f3f6; font-size: 15px; font-weight: 850; }
.sync-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.feedback-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.backup-list { margin: 12px 0; padding-left: 22px; line-height: 1.65; color: var(--muted); }
.timeline-list, .readiness-list, .action-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 9px; }
.timeline-list li, .readiness-list li, .action-list li { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.timeline-list li { display: grid; gap: 4px; }
.timeline-list li span, .action-list li span { color: var(--muted); font-size: 12px; }
.readiness-list li { display: flex; justify-content: space-between; gap: 12px; }
.empty-state { color: var(--muted); text-align: center; padding: 16px; }

.commander { margin-top: 20px; border: 2px solid #c9a23a; background: linear-gradient(180deg, #fffdf7, #fff); }
.commander-pill { color: #684d00; background: #f8e9ad; }
.commander-fields { grid-template-columns: 1fr 1fr; }
.hold-wrap { margin-top: 18px; text-align: center; }
.hold-wrap p { margin: 6px 0; font-size: 12px; }
.hold-button { position: relative; overflow: hidden; width: 100%; min-height: 58px; color: #fff; background: var(--red); user-select: none; touch-action: none; }
.hold-button span { position: relative; z-index: 2; }
.hold-button i { position: absolute; inset: 0; width: 0; background: var(--red-dark); transition: width 3s linear; }
.hold-button.holding i { width: 100%; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metrics div { padding: 16px; border-radius: 14px; background: #f3f5f7; text-align: center; }
.metrics strong { display: block; font-size: 26px; }
.metrics span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.metrics-three { grid-template-columns: repeat(3, 1fr); }
.operations-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
.operations-grid h3 { margin: 0; font-size: 15px; }
.admin-two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.command-preview { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 11px 13px; border-radius: 11px; background: #f5f7fa; font-size: 13px; }
.alert-pill { color: #fff; background: var(--red); }
.action-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.action-list li div { display: grid; gap: 4px; }
.export-link { display: inline-flex; align-items: center; justify-content: center; width: max-content; min-height: 36px; padding: 7px 12px; text-decoration: none; }
.audit-list { max-height: 620px; overflow: auto; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: 420px; padding: 14px 18px; border-radius: 12px; color: #fff; background: #18202c; box-shadow: var(--shadow); }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 14px 16px; }
  .account { flex-direction: column; align-items: flex-end; }
  .shell { width: min(100% - 20px, 680px); margin-top: 12px; }
  .two-columns, .commander-fields, .feedback-fields, .operations-grid, .admin-two-columns { grid-template-columns: 1fr; }
  .incident-panel { align-items: flex-start; flex-direction: column; }
  .incident-actions { width: 100%; min-width: 0; justify-content: stretch; }
  .incident-actions .button { flex: 1; }
  .metrics, .metrics-three { grid-template-columns: 1fr 1fr; }
  .card { padding: 18px; border-radius: 15px; }
  .brand h1 { font-size: 16px; }
  .brand p { display: none; }
}

/* ── v0.3.0 : ตัวสลับมุมมอง และการจัดการผู้ประกาศ ── */
.view-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.view-tab { border: 0; background: #fff; color: var(--muted); padding: 7px 14px; font-size: 13px; font-weight: 700; }
.view-tab.is-active { background: var(--red); color: #fff; }
.roster-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.roster-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.roster-list .you { color: var(--blue); font-weight: 800; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input { flex: 1 1 200px; }
@media (max-width: 720px) { .two-columns { grid-template-columns: 1fr; } .view-switch { display: none; } }

.update-banner { position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: #1f2937; color: #fff; padding: 12px 18px; font-size: 14px; }
.update-banner .button { min-height: 36px; padding: 6px 14px; }

.report-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.report-list li { border: 1px solid #f3bcc3; background: #fdeaec; border-radius: 12px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.report-list .info { font-size: 14px; }
.report-list .meta { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.report-list .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.report-list li.is-reviewing { border-color: #d5b45d; background: #fff7dc; }
.confirm-row { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; font-weight: 700; }
.confirm-row input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; }
.danger-note { color: #8b1e2d; font-weight: 700; }
.setup-details { margin-top: 12px; }
#bootstrap-output { width: 100%; margin-top: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.modal-dialog { width: min(520px, calc(100% - 28px)); border: 0; border-radius: 18px; padding: 24px; color: var(--ink); box-shadow: 0 24px 80px rgba(18, 28, 45, .3); }
.modal-dialog::backdrop { background: rgba(18, 28, 45, .62); }
.modal-dialog h2 { margin: 6px 0 2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
