:root{
  --navy: #142a5c;
  --navy-dark: #0c1c40;
  --gold: #e6b93d;
  --gold-light: #fff6dc;
  --link-blue: #145bd6;
  --orange: #d97a12;
  --teal: #0d8a7c;
  --red: #dc2626;
  --red-dark: #b71c1c;
}

* { font-family: 'Kanit', sans-serif; }

html, body{ height: 100%; background: #eef1f6; }

body{
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.app-header{
  background: linear-gradient(180deg, var(--gold-light) 0%, #ffedb0 100%);
  border-bottom: 5px solid var(--gold);
  padding: 1rem 1rem 1.25rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.app-header.emergency-header{
  border-bottom-color: var(--red);
}
.app-header.emergency-header h1{ color: var(--red-dark); }
.app-header.emergency-header h1 i{ color: var(--red); }

.app-header .logo{
  width: clamp(52px, 14vw, 76px);
  height: clamp(52px, 14vw, 76px);
  object-fit: contain;
  margin-bottom: .4rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}

.app-header h1{
  color: var(--navy-dark);
  font-weight: 700;
  font-size: clamp(1rem, 3.4vw, 1.4rem);
  margin: 0;
}

.app-header p.subtitle{
  color: #6b5a1e;
  font-size: clamp(.7rem, 2.2vw, .88rem);
  margin: .15rem 0 0;
}

.back-bar{
  background: #fff;
  border-bottom: 1px solid #e3e6ee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0 .5rem;
}

.back-bar a{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: #123a7c;
  text-decoration: none;
  font-weight: 500;
  font-size: .88rem;
  padding: .6rem .5rem;
}

.back-bar a:hover{ color: var(--navy-dark); }
.back-bar .float-end-link{ margin-left: auto; }

main{
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
}

body.wide main{ max-width: 1200px; }

/* ---------- Landing (ปุ่ม) ---------- */
.action-btn{
  display: flex;
  align-items: center;
  gap: .75rem;
  background: #eef1fb;
  color: var(--link-blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.02rem;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 6px rgba(20,43,92,.08);
  transition: transform .15s ease, box-shadow .15s ease;
  border: none;
  width: 100%;
  text-align: left;
}

.action-btn:hover{
  color: var(--link-blue);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(20,43,92,.15);
}

.action-btn i{ font-size: 1.3rem; }

.action-btn.action-btn-admin{
  background: var(--gold-light);
  color: var(--orange);
}
.action-btn.action-btn-admin:hover{ color: var(--orange); }

.action-btn.action-btn-urgent{
  background: linear-gradient(145deg,#ef4444,#b71c1c);
  color: #fff;
  font-size: 1.15rem;
  padding: 1.25rem;
  box-shadow: 0 4px 14px rgba(220,38,38,.35);
  animation: urgentPulse 2.2s ease-in-out infinite;
}
.action-btn.action-btn-urgent:hover{ color: #fff; }
.action-btn.action-btn-urgent i{ font-size: 1.6rem; }

@keyframes urgentPulse{
  0%, 100% { box-shadow: 0 4px 14px rgba(220,38,38,.35); }
  50% { box-shadow: 0 4px 22px rgba(220,38,38,.65); }
}

/* ---------- Cards / Forms ---------- */
.hl-card{
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  padding: clamp(1rem, 4vw, 1.75rem);
  margin-bottom: 1.25rem;
}

.hl-card h2{
  color: var(--link-blue);
  font-weight: 700;
  font-size: clamp(1.05rem, 3vw, 1.25rem);
  margin-bottom: 1.1rem;
}

.hl-card h2 small.section-sub{
  display: block;
  font-size: .8rem;
  font-weight: 400;
  color: #6b7a99;
  margin-top: .2rem;
}

.form-label{ font-weight: 500; color: var(--navy-dark); }
.form-hint{
  font-size: .8rem;
  border-radius: 8px;
  padding: .4rem .6rem;
  margin-top: .35rem;
}
.form-hint.secret{ background: #e6f6ea; color: #1b7a3d; }
.form-hint.info{ background: #eaf2ff; color: #145bd6; }
.form-hint.warn{ background: #fdeaea; color: #b71c1c; }

/* ---------- Table ---------- */
.hl-table thead th{
  background: #eaf2ff;
  color: var(--link-blue);
  font-weight: 600;
  border: none;
}
.hl-table td, .hl-table th{ vertical-align: middle; }
.hl-table tbody tr:nth-child(even){ background: #f7f9fd; }

/* ---------- Footer ---------- */
footer{
  background: var(--navy-dark);
  color: #fff;
  text-align: center;
  padding: 1rem .75rem;
  font-size: clamp(.72rem, 2.4vw, .88rem);
  margin-top: auto;
}
footer .brand{ font-weight: 600; }
footer small{ display: block; color: #b9c3dd; margin-top: .2rem; }

/* ---------- Status badges ---------- */
.badge-status{ font-size: .78rem; font-weight: 500; padding: .4rem .7rem; border-radius: 20px; }

/* ---------- Login card ---------- */
.login-wrap{
  max-width: 380px;
  margin: 2rem auto;
}

/* ---------- Dashboard: stat cards ---------- */
.stat-grid{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .9rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 720px){
  .stat-grid{ grid-template-columns: repeat(2, 1fr); }
}
.stat-card{
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.stat-card i{
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card.total i{ background: #eaf2ff; color: var(--link-blue); }
.stat-card.pending i{ background: #fff3da; color: var(--orange); }
.stat-card.done i{ background: #e6f6ea; color: #1b7a3d; }
.stat-card.rate i{ background: #fdeaea; color: var(--red); }
.stat-card .stat-value{ font-size: 1.4rem; font-weight: 700; color: var(--navy-dark); line-height: 1.1; }
.stat-card .stat-label{ font-size: .78rem; color: #6b7a99; }

/* ---------- Days pending pill ---------- */
.pill-days{ font-size: .78rem; font-weight: 600; padding: .25rem .55rem; border-radius: 20px; background: #f1f3f9; color: #47546b; }
.pill-days.urgent{ background: #fde8e8; color: #c62828; }

/* ---------- Confidential notice ---------- */
.confidential-badge{
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #e6f6ea;
  color: #1b7a3d;
  font-size: .82rem;
  font-weight: 500;
  border-radius: 20px;
  padding: .4rem .8rem;
  margin-bottom: 1rem;
}

/* ---------- Case code highlight ---------- */
.case-code-box{
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--navy-dark);
  color: #fff;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .5px;
  border-radius: 12px;
  padding: .6rem 1.1rem;
}

/* =========================================================
   จอเฝ้าระวังเคส (Live Monitor) - Kanban board
   ========================================================= */
.monitor-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .6rem;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
  padding: .85rem 1.1rem;
  margin-bottom: 1rem;
}
.monitor-toolbar .live-dot{
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  margin-right: .4rem;
  animation: liveDotPulse 1.6s ease-in-out infinite;
}
@keyframes liveDotPulse{
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(1.3); }
}
.monitor-toolbar .last-updated{ font-size: .8rem; color: #6b7a99; }

.kanban-board{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .9rem;
  align-items: start;
}
@media (max-width: 900px){
  .kanban-board{ grid-template-columns: 1fr; }
}

.kanban-col{
  background: #f4f6fb;
  border-radius: 16px;
  padding: .8rem;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.kanban-col-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: .95rem;
  border-radius: 10px;
  padding: .55rem .8rem;
  margin-bottom: .2rem;
}
.kanban-col-head .count-pill{
  background: rgba(255,255,255,.35);
  border-radius: 20px;
  padding: .1rem .6rem;
  font-size: .82rem;
}

.kanban-col-critical .kanban-col-head{ background: linear-gradient(145deg,#ef4444,#b71c1c); color: #fff; }
.kanban-col-urgent   .kanban-col-head{ background: linear-gradient(145deg,#ff9e2c,#e6720b); color: #fff; }
.kanban-col-general  .kanban-col-head{ background: linear-gradient(145deg,#1e78d8,#144e97); color: #fff; }

.kanban-card{
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  padding: .8rem .9rem;
  border-left: 5px solid #c2c2c2;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kanban-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,.16);
  color: inherit;
}
.kanban-card.unclaimed{ border-left-color: var(--red); }
.kanban-col-urgent .kanban-card.unclaimed{ border-left-color: var(--orange); }
.kanban-col-general .kanban-card.unclaimed{ border-left-color: var(--link-blue); }

.kanban-card.unclaimed.new-case{
  animation: newCaseFlash 1.4s ease-in-out 3;
}
@keyframes newCaseFlash{
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
  50% { box-shadow: 0 0 0 4px rgba(220,38,38,.35); }
}

.kanban-card .case-code{ font-weight: 700; font-size: .85rem; color: var(--navy-dark); }
.kanban-card .case-type{ font-size: .92rem; font-weight: 600; margin: .2rem 0; }
.kanban-card .case-meta{ font-size: .78rem; color: #6b7a99; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.kanban-card .case-assigned{ font-size: .78rem; margin-top: .35rem; }
.kanban-card .case-assigned.none{ color: var(--red-dark); font-weight: 500; }
.kanban-card .case-assigned.has{ color: #1b7a3d; font-weight: 500; }

.kanban-empty{
  text-align: center;
  color: #8a96ad;
  font-size: .85rem;
  padding: 1rem .5rem;
}

/* Sound toggle button */
.btn-sound-toggle.muted i::before{ content: "\f6a9"; }
