/* KTI People — brand: Navy #26255F, Teal #2E5F6E. Fonts: LINE Seed Sans TH → Poppins → IBM Plex Sans Thai. */
:root {
  --navy: #26255F; --navy-dark: #1B1A47; --teal: #2E5F6E;
  --ink: #111827; --ink-2: #374151; --muted: #5B6472;
  --bg: #F5F6FA; --surface: #FFFFFF; --line: #E3E5EE; --line-2: #EEF0F5; --field: #D3D6E2;
  --navy-tint: #E9E9F3; --teal-tint: #E4EFF2; --teal-ink: #1F4650;
  --ok-bg: #E3F1EA; --ok: #1F6B4A; --bad-bg: #FDECEA; --bad: #B42318; --neutral-bg: #EEF0F5;
  --font: 'LINE Seed Sans TH', 'Poppins', 'IBM Plex Sans Thai', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--navy); } a:hover { color: var(--teal); }
h1 { margin: 0; font-size: 26px; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 16px; font-weight: 600; }
.shell { display: flex; min-height: 100vh; }
.side { flex: 0 0 248px; background: linear-gradient(180deg, var(--navy) 0%, var(--teal) 100%); padding: 22px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-top { display: flex; align-items: center; gap: 10px; }
.side-top .brand { flex: 1; min-width: 0; }
.side-menu { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.side .nav-toggle, .side .side-bell { display: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: #fff; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: #fff; color: var(--navy); display: flex; align-items: center; justify-content: center; font: 700 15px 'Poppins', sans-serif; }
.brand small { display: block; color: #C8CCE0; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
/* Group header: small, muted, letter-spaced, with a chevron — clearly a section label, not a link. */
.nav-grp > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 8px; cursor: pointer; color: #9FB3D1; font-size: 12.5px; font-weight: 700; user-select: none; }
.nav-grp > summary::-webkit-details-marker { display: none; }
.nav-grp > summary::before { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; flex: none; }
.nav-grp[open] > summary::before { transform: rotate(45deg); }
.nav-grp > summary:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-grp > summary:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0; color: #7E8FB3; }
.nav-grp[open] .nav-count { display: none; }
.nav-grp + .nav-grp { border-top: 1px solid rgba(255,255,255,.12); padding-top: 6px; }
/* Menu items: indented under their group, larger and brighter than the header. */
.nav-items { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 6px 14px; margin-left: 14px; border-left: 1px solid rgba(255,255,255,.16); }
.nav a { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 9px; color: #EEF0F8; text-decoration: none; font-size: 14.5px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.on { background: #fff; color: var(--navy); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.side { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.12); color: #fff; font-size: 13px; }
.side-foot form { margin: 8px 0 0; }
.side-foot button { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; min-height: 34px; padding: 0 12px; font: inherit; cursor: pointer; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.ph { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.ph .eyebrow { font-size: 14px; color: var(--muted); }
.ph .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.tight { padding: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row > * { flex: 1 1 380px; min-width: 0; }
.row > .wide { flex: 2 1 520px; }
/* Opt-in: a table card next to a form gets room for the table; the two stack when the screen is too narrow. */
.row > .card.table-card { flex: 2 1 600px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; align-items: start; }
/* Settings-style forms: cards wide enough that labels don't wrap word by word. */
.grid-wide { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); gap: 16px; align-items: start; }
.sticky-save { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: 0 -4px 14px rgba(17,24,39,.08); align-items: center; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 14px; color: var(--muted); }
.stat .v { font-size: 28px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--teal-tint); color: var(--teal-ink); } .b-navy { background: var(--navy-tint); color: var(--navy); }
.b-solid { background: var(--navy); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; font: 600 15px var(--font); cursor: pointer; text-decoration: none; border: 1px solid var(--field); background: #fff; color: var(--ink); }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn.p { background: var(--navy); border-color: var(--navy); color: #fff; } .btn.p:hover { background: var(--navy-dark); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { color: var(--navy); border-color: var(--line); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { padding: 10px 8px; font-weight: 500; border-bottom: 1px solid var(--line); text-align: left; color: var(--muted); font-size: 13px; white-space: nowrap; }
.t td { padding: 11px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t .n, .t th.n { text-align: right; font-variant-numeric: tabular-nums; }
.t tfoot td { font-weight: 700; background: #F7F8FB; }
.scroll { overflow-x: auto; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.field input, .field select, .field textarea, input.in, select.in { min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; font: 15px var(--font); color: var(--ink); background: #fff; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field .hint a { color: var(--teal); }
.req { color: var(--bad); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px 16px; }
.form-grid + .btn, .form-grid + button, .form-grid + .actions { margin-top: 18px; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: #E9EBF2; align-self: flex-start; }
.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.tabs a.on { background: #fff; color: var(--ink); }
.flash { padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); } .flash.err { background: var(--bad-bg); color: var(--bad); } .flash.info { background: var(--teal-tint); color: var(--teal-ink); }
.note { padding: 12px 14px; border-radius: 12px; background: var(--teal-tint); color: var(--teal-ink); font-size: 14px; }
.chk { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.chk.ok { background: var(--ok-bg); color: var(--ok); } .chk.bad { background: var(--bad-bg); color: var(--bad); } .chk.info { background: var(--teal-tint); color: var(--teal-ink); }
.list > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.muted { color: var(--muted); } .small { font-size: 13px; } .b { font-weight: 600; }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--navy-tint); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: #E9EBF2; overflow: hidden; } .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--teal)); }
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 12px; align-items: start; }
.kanban .col { background: #ECEEF4; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .d { min-height: 86px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.cal .d.off { background: #F3F4F8; } .cal .d.hol { background: var(--teal-tint); } .cal .d.out { opacity: .35; }
.cal .h { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.login { min-height: 100vh; display: flex; background: linear-gradient(135deg, var(--navy) 0%, var(--teal) 100%); padding: 24px 16px; }
.login .card { width: 100%; max-width: 420px; padding: 28px; margin: auto; display: flex; flex-direction: column; gap: 16px; }
.setup { border: 2px solid var(--teal-tint); }
.setup .bar { margin: 4px 0 2px; }
.setup-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.setup-steps li { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.setup-num { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; font-weight: 700; background: var(--neutral-bg); color: var(--muted); }
.setup-steps li.next .setup-num { background: var(--navy); color: #fff; }
.setup-steps li.done .setup-num { background: var(--ok-bg); color: var(--ok); }
.setup-steps li.done .setup-body .b { color: var(--muted); }
.setup-steps li.next { background: var(--navy-tint); margin: 0 -12px; padding: 12px; border-radius: 10px; border-top-color: transparent; }
.setup-body { flex: 1 1 200px; min-width: 0; }
.setup-act { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .setup-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 6px 12px; align-items: start; padding: 10px 0; }
  .setup-act { grid-column: 2; }
  .setup-steps li.done .setup-body .small { display: none; }
  .setup-steps li.done .setup-act { display: none; }
}
.next-step { border: 2px solid var(--navy-tint); background: linear-gradient(180deg, #fff, #FAFAFD); }
.next-step ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.next-step a { color: var(--teal); font-weight: 600; }
/* Thai (พ.ศ.) date input + calendar popup — see app.js thaiDates() */
.thdate { position: relative; display: flex; align-items: stretch; width: 100%; }
.actions .thdate, .thdate:has(> input.in[style*="width:auto"]) { width: auto; }
.thdate > input.in[style*="width:auto"] { width: 9.5em !important; }
.thdate > input[type=text] { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.thdate-btn { flex: none; width: 44px; border: 1px solid var(--field); border-left: 0; border-radius: 0 10px 10px 0; background: #fff; color: var(--navy); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.thdate-btn:hover { background: var(--navy-tint); }
.thcal { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 324px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(17,24,39,.18); padding: 10px; font-size: 14px; font-weight: 400; color: var(--ink); }
.thcal-head { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.thcal-head select[data-m] { flex: 1.5; } .thcal-head select[data-y] { flex: 1; }
.thcal-head select { min-width: 0; min-height: 34px; border: 1px solid var(--field); border-radius: 8px; padding: 0 6px; font: 14px var(--font); background: #fff; }
.thcal-head button, .thcal-foot button { min-height: 34px; min-width: 34px; border: 1px solid var(--field); border-radius: 8px; background: #fff; cursor: pointer; font: 600 14px var(--font); color: var(--navy); }
.thcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.thcal-grid .dow { font-size: 12px; color: var(--muted); padding: 4px 0; }
.thcal-grid button { min-height: 36px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font: 14px var(--font); color: var(--ink); }
.thcal-grid button:hover:not([disabled]) { background: var(--navy-tint); }
.thcal-grid button.today { outline: 1px solid var(--teal); }
.thcal-grid button.sel { background: var(--navy); color: #fff; font-weight: 700; }
.thcal-grid button[disabled] { color: #C3C7D3; cursor: not-allowed; }
.thcal-foot { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
/* Phones: the calendar becomes a bottom sheet so it never pushes the page sideways. */
@media (max-width: 600px) {
  .thcal { position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto; width: auto; max-width: none; padding: 14px; border-radius: 16px; }
  .thcal-grid button { min-height: 42px; }
}
.empty-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px; text-align: center; }
.empty-cta .btn { margin-top: 6px; }
.row-edit > summary { list-style: none; } .row-edit > summary::-webkit-details-marker { display: none; }
/* Opened row editor = small dialog; clicking the dimmed backdrop (part of <summary>) closes it. No JS needed. */
.row-edit[open] > summary::before { content: ''; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 40; cursor: default; }
.row-edit[open] > form { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 41; width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: 0 12px 32px rgba(17,24,39,.18); display: flex; flex-direction: column; gap: 12px; }
.only-paternity { display: none; }
form:has(select[name="type"] option[value="paternity"]:checked) .only-paternity { display: block; }
.more-bal > summary { cursor: pointer; color: var(--teal); font-weight: 600; font-size: 14px; }
.role-help > summary { cursor: pointer; color: var(--teal); font-weight: 600; font-size: 14px; margin: 4px 0 8px; }
.form-sec { grid-column: 1 / -1; margin-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--navy); font-size: 14px; }
.org { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.org .lvl { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; position: relative; }
.org .node { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; min-width: 180px; text-align: center; }
.org .node.vac { border-style: dashed; border-color: #8A8FA3; background: #FAFAFC; }
.payslip { background: #fff; max-width: 794px; padding: 48px 52px; border: 1px solid var(--line); }
/* Payslip on a phone: stack the header, two-column info, one-column earnings/deductions. */
@media (max-width: 600px) {
  .payslip { padding: 18px 16px; }
  .payslip > header { flex-direction: column; gap: 10px !important; }
  .payslip > header > div:last-child { text-align: left !important; }
  .payslip > section[style*="grid-template-columns"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px 14px !important; }
  .payslip > section[style*="repeat(2"] { grid-template-columns: 1fr !important; gap: 16px !important; }
  .payslip > section[style*="justify-content:space-between"] span:last-child { font-size: 20px !important; }
  .payslip > footer { flex-direction: column; gap: 10px !important; }
  .payslip > footer span { text-align: left !important; min-width: 0 !important; }
}
@media print {
  .side, .no-print, .ph .actions { display: none !important; }
  .main { padding: 0; } body { background: #fff; } .card { border: 0; padding: 0; }
}
/* Narrow screens (phones, tablets, split windows): sidebar becomes a top bar; the menu opens with the เมนู button. */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { flex: none; position: sticky; top: 0; z-index: 20; height: auto; max-height: 100vh; padding: 10px 14px; gap: 0; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .side .nav-toggle { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 9px; border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; font: 600 14px var(--font); cursor: pointer; }
  .nav-toggle[aria-expanded="true"] { background: #fff; color: var(--navy); }
  .side .side-bell { display: inline-flex; }
  .js .side-menu { display: none; }
  .js .side.open .side-menu { display: flex; padding-top: 12px; }
  .nav a { min-height: 44px; font-size: 15px; }
}
@media (max-width: 760px) {
  .main { padding: 18px 16px 40px; gap: 16px; }
  h1 { font-size: 22px; }
  /* KPI tiles two per row on phones instead of one tall card each. */
  .grid:has(> .stat), .grid:has(> .card.stat), .grid:has(> .card > .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid .card { padding: 14px; }
  .stat .v { font-size: 20px !important; overflow-wrap: anywhere; }
  .stat .k { font-size: 13px; }
}
form.inline { display: inline; margin: 0; }
select.in, input.in { max-width: 100%; }
