/* ระบบรับเรื่องจากพนักงาน — สไตล์ร่วม (พนักงาน + HR) */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #5b6876;
  --line: #dde3e9;
  --brand: #1f5f8b;
  --brand-ink: #ffffff;
  --brand-soft: #e7f0f7;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;
  --ok: #1d6b3a;
  --ok-soft: #e7f5ec;
  --internal: #7a5b00;
  --internal-soft: #fff8db;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Sarabun', 'Noto Sans Thai', 'Leelawadee UI', 'Leelawadee', Tahoma, 'Loma', system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55; -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
:focus-visible { outline: 3px solid #f5a524; outline-offset: 2px; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* โครงหน้า */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: var(--brand-ink);
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; box-shadow: var(--shadow);
}
.topbar .title { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar button { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.45); }
.bell { position: relative; }
.bell .dot { position: absolute; top: -6px; right: -6px; background: #f04438; color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .35rem; }
main { max-width: 860px; margin: 0 auto; padding: 1rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin: 0 0 1rem; }
.nav a { text-decoration: none; padding: .45rem .8rem; border-radius: 999px; color: var(--ink); background: #fff; border: 1px solid var(--line); font-size: .95rem; }
.nav a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row > * { min-width: 0; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .85rem; }
.break { overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; }

/* ปุ่มและฟอร์ม */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 10px; padding: .6rem 1rem; border: 1px solid var(--line);
  background: #fff; color: var(--ink); min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.ghost { background: transparent; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.big { width: 100%; font-size: 1.05rem; padding: .85rem 1rem; }
label { display: block; font-weight: 600; margin: .75rem 0 .3rem; }
label .opt { font-weight: 400; color: var(--muted); font-size: .88rem; }
input[type=text], input[type=password], input[type=tel], input[type=email], input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; width: 100%; padding: .6rem .7rem; border-radius: 10px; border: 1px solid #b8c2cc; background: #fff; color: var(--ink); min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.field-error { color: var(--danger); font-size: .9rem; margin-top: .25rem; }
.hint { color: var(--muted); font-size: .88rem; margin-top: .2rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; margin: .6rem 0; }
.check input { width: 22px; height: 22px; margin-top: .15rem; flex: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .9rem .8rem; margin: .75rem 0; }
legend { font-weight: 600; padding: 0 .3rem; }
.counter { text-align: right; font-size: .8rem; color: var(--muted); }

/* ประเภทเรื่อง */
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.cat { text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: .8rem; min-height: 64px; }
.cat[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }

/* ขั้นตอน */
.steps { display: flex; gap: .35rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.steps li { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.steps li.done { background: var(--brand); }
.step-title { font-size: .9rem; color: var(--muted); margin-bottom: .5rem; }

/* สถานะ — มีทั้งสีและข้อความ */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ''; width: .5rem; height: .5rem; border-radius: 99px; background: currentColor; }
.st-RECEIVED { background: #eef2f6; color: #3d4b5c; }
.st-TRIAGING { background: #eceefe; color: #3538cd; }
.st-IN_PROGRESS { background: #e7f0f7; color: #1f5f8b; }
.st-WAITING_EMPLOYEE { background: var(--warn-soft); color: var(--warn); border-color: #f5c46b; }
.st-WAITING_INTERNAL { background: #f3eefe; color: #5b35b0; }
.st-RESOLVED { background: var(--ok-soft); color: var(--ok); }
.st-CLOSED { background: #f2f2f2; color: #545454; }
.st-REOPENED { background: #fff1e6; color: #b54708; }

/* รายการเคส */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.case-link { display: block; padding: .75rem .25rem; text-decoration: none; color: inherit; }
.case-link:hover { background: #fafbfc; }
.case-link .no { font-size: .85rem; color: var(--muted); }
.case-link .subj { font-weight: 600; overflow-wrap: anywhere; }
.pill { background: #f04438; color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 .45rem; }

.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .7rem; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }

/* บทสนทนา */
.thread { display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 92%; padding: .6rem .8rem; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.msg.me { align-self: flex-end; background: var(--brand-soft); border-color: #c6dbeb; }
.msg.sys { align-self: center; background: #f5f6f7; font-size: .9rem; color: var(--muted); text-align: center; }
.msg.req { border: 2px solid #f5c46b; background: var(--warn-soft); }
.msg .who { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.files { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.files button { min-height: 36px; padding: .3rem .6rem; font-size: .9rem; justify-content: flex-start; text-align: left; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--line); }
.timeline li { padding: 0 0 .7rem .9rem; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -8px; top: .45rem; width: 13px; height: 13px; border-radius: 99px; background: var(--brand); border: 2px solid #fff; }

/* ข้อความแจ้ง */
.alert { border-radius: 10px; padding: .75rem .9rem; margin: .5rem 0 1rem; border: 1px solid; }
.alert.err { background: var(--danger-soft); border-color: #f4b6b0; color: #7a1a12; }
.alert.ok { background: var(--ok-soft); border-color: #a8d5b7; color: #14532d; }
.alert.warn { background: var(--warn-soft); border-color: #f5c46b; color: #5c3800; }
.alert.info { background: var(--brand-soft); border-color: #c6dbeb; color: #12405f; }
.emergency { background: #fff; border-left: 5px solid var(--danger); }
.emergency ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.internal-box { background: var(--internal-soft); border: 2px dashed #d4a72c; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: #1d2733; color: #fff; padding: .7rem 1rem; border-radius: 10px; z-index: 50; max-width: calc(100vw - 2rem); box-shadow: var(--shadow); }
dialog { border: 0; border-radius: 14px; padding: 1.2rem; max-width: min(520px, calc(100vw - 2rem)); width: 100%; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }

.loading { padding: 2rem; text-align: center; color: var(--muted); }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }
.stars { display: flex; gap: .3rem; }
.stars button { font-size: 1.4rem; min-width: 44px; padding: .2rem; }
.stars button[aria-pressed="true"] { background: #fff4d6; border-color: #e3a008; }

.login-wrap { max-width: 420px; margin: 2rem auto; }
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-logo .mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 700; font-size: 1.4rem; }

@media (max-width: 520px) {
  main { padding: .75rem; }
  .card { padding: .85rem; }
  .msg { max-width: 100%; }
  .hide-sm { display: none; }
}
.end { justify-content: flex-end; margin-top: 1rem; }
.mt { margin-top: 1rem; }
.skip{position:absolute;left:-9999px;top:0;background:#fff;padding:.5rem 1rem;z-index:100}
.skip:focus{left:.5rem;top:.5rem}

/* ---------------- HR Workspace ---------------- */
main.wide { max-width: 1240px; }
.topbar .who { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem .9rem; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem .9rem; }
.grid4 > div > label:first-child, .grid3 > div > label:first-child { margin-top: .25rem; }
.stat { display: block; text-decoration: none; color: inherit; }
.stat.warn { border-color: #f5c46b; background: var(--warn-soft); }
.stat.bad { border-color: #f4b6b0; background: var(--danger-soft); color: #7a1a12; }
.tabs { display: flex; gap: .2rem; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 0 0 1rem; }
.tabs a { padding: .55rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .5rem; border-radius: 6px; font-size: .8rem; font-weight: 600; background: #eef2f6; color: #3d4b5c; margin: .1rem .2rem .1rem 0; white-space: nowrap; }
.pr-P1 { background: #fde8e8; color: #9b1c1c; } .pr-P2 { background: #fff1e6; color: #b54708; } .pr-P3 { background: #eef2f6; color: #3d4b5c; } .pr-P4 { background: #f2f2f2; color: #6b6b6b; }
.conf-RESTRICTED { background: #f3eefe; color: #5b35b0; } .conf-CONFIDENTIAL { background: #3d1a78; color: #fff; }
.sla-OK { background: var(--ok-soft); color: var(--ok); } .sla-DUE_SOON { background: var(--warn-soft); color: var(--warn); }
.sla-BREACHED { background: var(--danger-soft); color: var(--danger); } .sla-PAUSED, .sla-STOPPED { background: #f2f2f2; color: #545454; }
.tag.esc { background: #fde8e8; color: #9b1c1c; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: .5rem .45rem; }
.tbl td { border-bottom: 1px solid var(--line); padding: .55rem .45rem; vertical-align: top; }
.tbl .num { text-align: right; }
.tbl tr.late td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.tbl tr.inactive, section.inactive { opacity: .6; }
.kv { margin: .35rem 0; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; margin-top: 1rem; }
.layout2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .layout2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.msg.note { max-width: 100%; background: #fffdf2; border-color: #ecd98a; }
.plain { list-style: none; padding: 0; margin: .3rem 0 .6rem; }
.plain li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.plain li:last-child { border-bottom: 0; }
button.small-btn, .small-btn { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; }
.chip { display: inline-flex; align-items: center; gap: .2rem; background: var(--brand-soft); color: #12405f; border-radius: 999px; padding: .1rem .2rem .1rem .6rem; font-size: .85rem; margin: .15rem .2rem .15rem 0; }
.chip .x { min-height: 28px; min-width: 28px; padding: 0; border-radius: 99px; background: transparent; border: 0; font-size: 1rem; }
dialog.wide { max-width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; }
.picks .pick { width: 100%; justify-content: flex-start; text-align: left; flex-wrap: wrap; }
.qr { display: block; width: 200px; height: 200px; margin: .5rem auto; background: #fff; padding: .4rem; border-radius: 8px; }
.secret { display: block; background: #f5f6f7; padding: .5rem; border-radius: 6px; font-size: .95rem; letter-spacing: .05em; }
details summary { cursor: pointer; min-height: 32px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 3rem; gap: .5rem; align-items: center; padding: .2rem 0; }
.bars .bar { background: #eef2f6; border-radius: 4px; height: 14px; overflow: hidden; }
.bars .fill { display: block; height: 100%; background: var(--brand); }
.bars .bn { text-align: right; font-variant-numeric: tabular-nums; }
.fill.w0 { width: 1%; }
.timeline.hr li { font-size: .92rem; }
.filters .grid4 select, .filters .grid4 input { min-height: 40px; }
@media (max-width: 760px) {
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .6rem; padding: .3rem .5rem; }
  .tbl td { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .5rem; border: 0; padding: .25rem 0; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; }
  .tbl td[data-label=""]::before { content: none; }
  .tbl td[data-label=""] { display: block; }
  .tbl tr.late { border-left: 4px solid var(--danger); }
  .topbar .who { display: none; }
}
@media print {
  .topbar, .nav, .tabs, .no-print, .skip { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
.fill.w1 { width: 5%; }
.fill.w2 { width: 10%; }
.fill.w3 { width: 15%; }
.fill.w4 { width: 20%; }
.fill.w5 { width: 25%; }
.fill.w6 { width: 30%; }
.fill.w7 { width: 35%; }
.fill.w8 { width: 40%; }
.fill.w9 { width: 45%; }
.fill.w10 { width: 50%; }
.fill.w11 { width: 55%; }
.fill.w12 { width: 60%; }
.fill.w13 { width: 65%; }
.fill.w14 { width: 70%; }
.fill.w15 { width: 75%; }
.fill.w16 { width: 80%; }
.fill.w17 { width: 85%; }
.fill.w18 { width: 90%; }
.fill.w19 { width: 95%; }
.fill.w20 { width: 100%; }
