/* ระบบแจ้งตรวจสอบข้อมูลประวัติสุขภาพ — สไตล์ชีตกลาง (ตามแบบที่อนุมัติ) */

:root {
  --ink:        #16211E;
  --ink-2:      #2B3A36;
  --muted:      #6B7B77;
  --muted-2:    #8A9A96;
  --body:       #4A5B57;
  --bg:         #EBF0EF;
  --surface:    #FFFFFF;
  --surface-2:  #F7FAF9;
  --line:       #E3EAE8;
  --line-2:     #F0F4F3;
  --field:      #DCE5E3;

  --brand-900:  #0B4A45;
  --brand-700:  #0E6E64;
  --brand-600:  #0A5A52;
  --brand-300:  #9FD8D0;
  --brand-200:  #CFE2DE;
  --brand-100:  #D6EFE9;
  --mint:       #12C2A8;

  --danger:     #C0392B;
  --danger-bg:  #FDF0EE;
  --danger-line:#F6D8D3;
  --warn:       #B8620A;
  --ok:         #186B41;

  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 18px;
  --shadow:    0 8px 18px -10px rgba(11,74,69,.35);

  --display: 'Anuphan', system-ui, sans-serif;
  --sans: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-900); text-decoration: underline; }
input, select, textarea, button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #C7D3D0; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

:focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- แถบบนสุด ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--brand-900); color: #fff;
  padding: 0 24px; height: 64px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.topbar .mark {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--mint); color: #04302C;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 15px; flex: none;
}
.topbar .titles { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar .titles b { font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.topbar .titles span { font-size: 11.5px; color: #8FC7C0; }
.topbar nav { display: flex; gap: 4px; margin-left: auto; background: rgba(255,255,255,.08); padding: 4px; border-radius: 12px; }
.topbar nav a {
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 500;
  color: #BFE6E0; text-decoration: none; white-space: nowrap;
}
.topbar nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.topbar nav a.active { background: #fff; color: var(--brand-900); }
.topbar .who { margin-left: 16px; font-size: 12.5px; color: #9FD8D0; text-align: right; line-height: 1.35; }
.topbar .who b { display: block; color: #fff; font-weight: 500; }

/* ---------- โครงหน้า ---------- */
.page { padding: 24px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-family: var(--display); font-size: 23px; font-weight: 600; margin: 0; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card.pad { padding: 20px; }
.card h3 { font-family: var(--display); font-size: 16px; font-weight: 600; margin: 0 0 14px; }
.card .hint { font-size: 11.5px; color: var(--muted-2); margin: -10px 0 14px; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); gap: 20px; align-items: start; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 18px; }

/* ---------- ปุ่ม ---------- */
.btn {
  border: none; cursor: pointer; background: var(--brand-700); color: #fff;
  padding: 13px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  transition: background .15s;
}
.btn:hover { background: var(--brand-600); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { padding: 16px; border-radius: 15px; font-size: 15.5px; }
.btn.ghost { background: var(--surface); border: 1.5px solid var(--brand-200); color: var(--brand-700); }
.btn.ghost:hover { background: #F0F7F5; }
.btn.plain { background: transparent; border: none; color: var(--muted); font-weight: 500; }
.btn.danger { background: var(--danger); }
.btn.icon { width: 34px; height: 34px; padding: 0; border: 1px solid var(--field); background: #fff; color: #3A4B47; border-radius: var(--radius-sm); font-size: 15px; }

.chip {
  cursor: pointer; border: 1px solid var(--field); background: var(--surface);
  color: var(--body); padding: 8px 15px; border-radius: 20px; font-size: 13px; font-weight: 500;
}
.chip.on { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- ฟอร์ม ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--danger); }
.field .note { font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
.field .err { font-size: 12px; color: var(--danger); }
input[type=text], input[type=tel], input[type=date], input[type=password], input[type=number], select, textarea {
  border: 1.5px solid var(--field); border-radius: 12px; padding: 13px 14px;
  font-size: 15px; background: #fff; outline: none; width: 100%; color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-700); }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--danger); }
.choice {
  text-align: left; cursor: pointer; border: 1.5px solid var(--field); background: #fff;
  border-radius: 13px; padding: 13px 14px; font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2); display: flex; gap: 10px; align-items: center; width: 100%;
}
.choice .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #CFDCD9; flex: none; }
.choice.on { border-color: var(--brand-700); background: #F2F9F7; }
.choice.on .dot { background: var(--brand-700); border-color: var(--brand-700); box-shadow: inset 0 0 0 3px #fff; }

/* ---------- ตาราง ---------- */
.tbl-head, .tbl-row { display: grid; gap: 12px; align-items: center; }
.tbl-head { padding: 12px 18px; background: #F5F8F7; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .03em; }
.tbl-row { padding: 14px 18px; border-top: 1px solid var(--line-2); cursor: pointer; }
.tbl-row:hover { background: #F3F8F7; }
.tbl-row.on { background: #EDF6F4; }
.tbl-row .strong { font-size: 13.5px; font-weight: 500; }
.tbl-row .sub { font-size: 12px; color: #7C8C88; margin-top: 2px; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.empty { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13.5px; }

/* ---------- ป้ายสถานะ ---------- */
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; display: inline-block; }
.badge.received     { background: #E7F0FF; color: #1B4F9C; }
.badge.investigating{ background: #FFF3DC; color: #8A5A00; }
.badge.replied      { background: #E3F6EE; color: #186B41; }
.badge.closed       { background: #ECEFEE; color: #4B5A56; }
.badge.rejected     { background: #FDF0EE; color: #8E2C1E; }
.badge.urgent       { background: #FDF0EE; color: #C0392B; }

.sla { font-size: 12.5px; font-weight: 600; }
.sla.ok { color: #3A4B47; }
.sla.warn { color: var(--warn); }
.sla.overdue { color: var(--danger); }
.sla.done { color: var(--muted-2); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 6px; color: var(--brand-900); }
.kpi .delta { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.kpi .value.warn { color: var(--warn); }
.kpi .value.danger { color: var(--danger); }
.kpi .value.ok { color: var(--ok); }

/* ---------- ไทม์ไลน์ ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: none; }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; margin-top: 3px; background: var(--brand-700); border: 2.5px solid var(--brand-100); }
.tl-dot.pending { background: #D7E1DE; border-color: #EDF2F1; }
.tl-line { width: 2px; flex: 1; background: var(--line-2); min-height: 14px; }
.tl-body { padding-bottom: 18px; }
.tl-body .t { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.tl-body .m { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.tl-body .x { font-size: 13px; color: var(--body); margin-top: 5px; line-height: 1.6; }

/* ---------- แถบสัดส่วน ---------- */
.bar { height: 8px; background: #EEF3F2; border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand-700); border-radius: 5px; }
.rank-row { margin-bottom: 11px; }
.rank-row .top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 5px; }
.rank-row .top b { color: var(--brand-900); flex: none; }

/* ---------- ประกาศ / แจ้งเตือน ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--brand-900); color: #fff; padding: 13px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: 0 12px 30px -12px rgba(0,0,0,.5); z-index: 100;
  animation: fadeUp .25s ease both; max-width: min(90vw, 520px);
}
.toast.err { background: var(--danger); }
.alert { border-radius: 12px; padding: 13px 15px; font-size: 13.5px; line-height: 1.6; }
.alert.err { background: var(--danger-bg); border: 1px solid var(--danger-line); color: #8E2C1E; }
.alert.info { background: #EAF4F2; border: 1px solid var(--brand-200); color: #16544C; }
.alert.ok { background: #E3F6EE; border: 1px solid #BFE3D4; color: var(--ok); }

.skeleton { background: linear-gradient(90deg,#EDF2F1,#F6F9F8,#EDF2F1); border-radius: 8px; height: 14px; animation: sk 1.2s infinite; }
@keyframes sk { 0% { background-position: 0 0; } 100% { background-position: 200px 0; } }

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 22px; padding: 32px; box-shadow: 0 30px 70px -40px rgba(11,74,69,.55); }
.login-card h1 { font-family: var(--display); font-size: 22px; font-weight: 600; margin: 14px 0 4px; }
.login-card .sub { font-size: 13px; color: var(--muted); margin-bottom: 22px; line-height: 1.6; }

/* ---------- ฝั่งประชาชน (มือถือเป็นหลัก) ---------- */
.citizen { max-width: 520px; margin: 0 auto; padding: 0 20px 48px; }
.citizen .hero {
  border-radius: 20px; background: linear-gradient(160deg, var(--brand-700), var(--brand-900));
  color: #fff; padding: 24px; margin: 18px 0;
}
.citizen .hero .eyebrow { font-size: 12px; color: var(--brand-300); margin-bottom: 6px; }
.citizen .hero h1 { font-family: var(--display); font-size: 22px; font-weight: 600; line-height: 1.35; margin: 0; }
.citizen .hero p { font-size: 13.5px; color: #BFE6E0; margin: 8px 0 0; line-height: 1.6; }
.citizen .section-label { margin-top: 26px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.citizen .list-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.citizen .list-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); flex: none; }
.citizen .fineprint { margin-top: 22px; font-size: 11.5px; color: var(--muted-2); line-height: 1.65; }
.citizen .screen-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 16px; }
.citizen .screen-head h2 { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 0; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps i { flex: 1; height: 5px; border-radius: 3px; background: #DCE5E3; }
.steps i.on { background: var(--brand-700); }
.step-label { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.summary-box { background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.summary-box .r { display: flex; justify-content: space-between; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line-2); }
.summary-box .r:last-child { border-bottom: none; }
.summary-box .r span { font-size: 13px; color: var(--muted); flex: none; }
.summary-box .r b { font-size: 13.5px; font-weight: 500; text-align: right; line-height: 1.5; }
.consent { display: flex; gap: 10px; align-items: flex-start; padding: 12px 2px; cursor: pointer; }
.consent input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--brand-700); flex: none; }
.consent span { font-size: 12.5px; line-height: 1.6; color: var(--body); }
.done-mark { width: 74px; height: 74px; border-radius: 50%; background: #E3F6EE; color: var(--brand-700); font-size: 32px; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.ticket-box { margin: 22px 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; text-align: center; }
.ticket-box .no { font-family: var(--display); font-size: 28px; font-weight: 700; letter-spacing: .04em; color: var(--brand-900); margin-top: 4px; }
.dropzone { border: 1.5px dashed #CFDCD9; border-radius: 13px; padding: 16px; text-align: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.dropzone:hover { border-color: var(--brand-700); color: var(--brand-700); }
.filelist { font-size: 12.5px; color: var(--body); margin-top: 8px; }

/* ---------- แผนที่อำเภอ ---------- */
.map-wrap { position: relative; margin-top: 12px; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.map-wrap path { cursor: pointer; transition: opacity .15s; }
.map-wrap path:hover { opacity: .8; }
.map-label { position: absolute; transform: translate(-50%,-50%); text-align: center; line-height: 1.15; pointer-events: none; }
.map-label .n { font-size: 10px; font-weight: 500; }
.map-label .c { font-family: var(--display); font-weight: 700; }
.legend { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 11.5px; color: var(--muted); }
.legend i { width: 34px; height: 11px; border-radius: 3px; display: block; }

/* ---------- แผนภูมิแท่ง ---------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 132px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend .pair { display: flex; gap: 3px; align-items: flex-end; width: 100%; height: 100%; justify-content: center; }
.trend .pair i { width: 11px; border-radius: 3px 3px 0 0; display: block; }
.trend .pair i.a { background: var(--brand-700); }
.trend .pair i.b { background: #9BD9CE; }
.trend .lb { font-size: 10.5px; color: #7C8C88; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 900px) {
  .page { padding: 18px 14px 48px; }
  .grid-2 { grid-template-columns: minmax(0,1fr); }
  .topbar { padding: 0 14px; gap: 12px; height: auto; min-height: 60px; flex-wrap: wrap; padding-bottom: 8px; }
  .topbar nav { margin-left: 0; width: 100%; overflow-x: auto; }
  .topbar .who { margin-left: auto; }
  .tbl-head { display: none; }
  .tbl-row { grid-template-columns: minmax(0,1fr) auto !important; }
}

/* ---------- ตัวอย่างการ์ด LINE Flex Message ---------- */
.line-stage {
  background: #8CABC4; border-radius: 20px; padding: 22px 18px;
  display: flex; justify-content: center;
}
.line-row { display: flex; gap: 8px; align-items: flex-end; max-width: 320px; width: 100%; }
.line-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #06C755; color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none;
}
.flex-card {
  background: #fff; border-radius: 14px; overflow: hidden; width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: 13px;
}
.flex-card .fx-header { background: var(--brand-900); color: #fff; padding: 18px 18px 16px; }
.flex-card .fx-eyebrow { display: flex; justify-content: space-between; gap: 10px; font-size: 10.5px; color: #8FC7C0; font-weight: 600; }
.flex-card .fx-eyebrow span:last-child { font-weight: 400; text-align: right; }
.flex-card .fx-title { font-family: var(--display); font-size: 17px; font-weight: 700; line-height: 1.35; margin-top: 8px; }
.flex-card .fx-no { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; }
.flex-card .fx-no span { font-size: 11px; color: #8FC7C0; }
.flex-card .fx-no b { font-size: 15px; color: var(--mint); letter-spacing: .02em; }
.flex-card .fx-body { padding: 16px 18px 4px; }
.flex-card .fx-lead { font-size: 12.5px; color: var(--body); line-height: 1.6; margin-top: 10px; }
.flex-steps { display: flex; gap: 4px; margin-top: 14px; }
.flex-steps i { flex: 1; height: 6px; border-radius: 3px; background: #DFE8E6; }
.flex-steps i.on { background: var(--brand-700); }
.flex-steplabels { display: flex; gap: 4px; margin-top: 6px; }
.flex-steplabels span { flex: 1; text-align: center; font-size: 9.5px; color: var(--muted-2); }
.flex-steplabels span.on { color: var(--brand-700); }
.flex-steplabels span.now { font-weight: 700; }
.flex-card hr { border: none; border-top: 1px solid var(--line); margin: 16px 0 0; }
.flex-kv { display: flex; justify-content: space-between; gap: 14px; margin-top: 11px; }
.flex-kv span { font-size: 12px; color: var(--muted-2); flex: none; }
.flex-kv b { font-size: 12px; font-weight: 400; color: var(--ink); text-align: right; line-height: 1.5; }
.flex-kv b.hi { font-weight: 700; color: var(--brand-900); }
.flex-note { margin-top: 14px; background: #F4F8F7; border-radius: 10px; padding: 12px 13px; }
.flex-note .k { font-size: 10px; color: var(--muted-2); }
.flex-note .v { font-size: 12.5px; color: var(--body); line-height: 1.65; margin-top: 4px; }
.flex-card .fx-footer { padding: 16px 18px 18px; }
.flex-btn { background: var(--brand-700); color: #fff; border-radius: 8px; text-align: center; padding: 10px; font-size: 13px; font-weight: 600; }
.flex-card .fx-fine { font-size: 10px; color: var(--muted-2); text-align: center; margin-top: 9px; line-height: 1.5; }
.json-box {
  background: #0B1A18; color: #9FD8D0; border-radius: 12px; padding: 14px;
  font-family: ui-monospace, monospace; font-size: 11.5px; line-height: 1.55;
  max-height: 340px; overflow: auto; white-space: pre; margin: 0;
}

/* ---------- หน้าจัดการคำร้องบนมือถือ (/ticket) ---------- */
.workcard { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
.wc-head {
  background: linear-gradient(160deg, var(--brand-700), var(--brand-900));
  color: #fff; border-radius: 18px; padding: 20px; margin: 18px 0 14px;
}
.wc-head .wc-no { font-family: var(--display); font-size: 20px; font-weight: 700; }
.wc-head .wc-sub { font-size: 12.5px; color: #BFE6E0; margin-top: 4px; }
.wc-head .badge { background: rgba(255,255,255,.16) !important; color: #fff !important; }
.wc-head .sla { color: #BFE6E0 !important; }
.wc-head .sla.overdue { color: #FFC9BE !important; }
.wc-head .sla.warn { color: #FFE0B2 !important; }
.wc-due {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.18);
  font-size: 13px;
}
.wc-due span { color: #9FD8D0; }
.wc-due b { font-weight: 600; }

.wc-card { padding: 18px; margin-bottom: 14px; }
.wc-title { font-family: var(--display); font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.wc-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px;
}
.wc-row:last-of-type { border-bottom: none; }
.wc-row > span { color: var(--muted); flex: none; }
.wc-row > b { font-weight: 500; text-align: right; line-height: 1.5; }
.wc-detail { margin-top: 12px; background: var(--surface-2); border-radius: 12px; padding: 14px; }
.wc-detail .k { font-size: 11.5px; color: var(--muted-2); }
.wc-detail .v { font-size: 13.5px; color: var(--body); line-height: 1.7; margin-top: 4px; }
.wc-templates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.wc-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.wc-hint { font-size: 11.5px; color: var(--muted-2); line-height: 1.6; margin-top: 12px; }
