/* ── Inter Supply HR — design v2 (จาก Claude Design "HR ดีไซน์ใหม่") ──
   โทน: พื้นนวล #f6f7f6 · การ์ดขาวขอบบาง · เขียว oklch(0.52 0.09 172)
   ฟอนต์: Noto Sans Thai + IBM Plex Sans (ตัวเลข tabular) */
:root {
  --bg: #f6f7f6;
  --card: #ffffff;
  --ink: #1a201d;
  --muted: #69726d;
  --faint: #8a938d;
  --line: #e6e9e7;
  --line-soft: #eef0ef;
  --line-row: #f2f4f3;
  --input-border: #d5dad7;
  --input-bg: #fbfcfb;
  --brand: oklch(0.52 0.09 172);
  --brand-hover: oklch(0.46 0.09 172);
  --brand-deep: oklch(0.28 0.05 168);
  --brand-ink: oklch(0.38 0.08 172);
  --brand-soft: oklch(0.96 0.02 172);
  --brand-chip: oklch(0.95 0.03 172);
  --brand-chip-ink: oklch(0.42 0.09 172);
  --danger: oklch(0.55 0.15 30);
  --warn: oklch(0.55 0.15 45);
  --warn-strong: oklch(0.62 0.14 45);
  --amber-bg: oklch(0.95 0.04 85);
  --amber-ink: oklch(0.45 0.11 70);
  --radius: 14px;
  --num-font: "IBM Plex Sans", "Noto Sans Thai", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans Thai", "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ── Login (แบ่งสองฝั่ง) ── */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; background: #fff; }
.login-brand {
  background: var(--brand-deep); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand .corp { font: 600 15px/1 "IBM Plex Sans", sans-serif; letter-spacing: .02em; }
.login-brand h1 { font-size: 40px; font-weight: 600; line-height: 1.25; letter-spacing: -.015em; margin: 0 0 16px; text-wrap: balance; }
.login-brand .desc { color: oklch(0.82 0.04 168); max-width: 340px; text-wrap: pretty; }
.login-brand .foot { display: flex; gap: 32px; color: oklch(0.78 0.04 168); font-size: 13px; }
.login-form-side { padding: 56px 52px; display: flex; flex-direction: column; justify-content: center; gap: 22px; max-width: 480px; width: 100%; margin: 0 auto; }
.login-form-side h2 { font-size: 22px; font-weight: 600; margin: 0; }
.login-form-side .sub { color: var(--muted); font-size: 14px; }
.login-hint { font-size: 13px; color: var(--faint); }

/* ── Layout: แถบข้าง + แถบบน (โครงเดียวกับ Humansoft) ── */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  width: 262px; flex-shrink: 0; background: var(--brand-deep); color: #cfe4d8;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-head .t1 { font-weight: 700; font-size: 16px; color: #fff; }
.sidebar-head .t2 { font-size: 11.5px; color: oklch(0.78 0.04 168); }
.sidebar-head select {
  margin-top: 10px; width: 100%; padding: 7px 9px; font-size: 12.5px; border-radius: 8px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); color: #fff;
}
.sidebar-head select option { color: var(--ink); }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav-section {
  font: 500 10.5px/1 "IBM Plex Sans", sans-serif; letter-spacing: .12em; text-transform: uppercase;
  color: oklch(0.68 0.04 168); padding: 14px 10px 6px;
}
.nav a, .nav-group-head, .nav-group-single {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px; border-radius: 8px; color: #d6e7dd; font-size: 13.5px;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav-group-head:hover, .nav-group-single:hover { background: rgba(255,255,255,.09); color: #fff; }
.nav a.active, .nav-group-single.active { background: #fff; color: var(--brand-ink); font-weight: 600; }
.nav-group-head.current { color: #fff; font-weight: 600; }
.nav-group-head .ico, .nav-group-single .ico { width: 18px; text-align: center; opacity: .9; font-size: 13px; }
.nav .grow, .nav-group-head .grow { flex: 1; min-width: 0; }
.nav-group-head .caret { font-size: 10px; opacity: .8; }
.nav-sub { padding: 2px 0 6px 8px; margin-left: 12px; border-left: 1px solid rgba(255,255,255,.14); }
.nav-sub a {
  display: block; padding: 7px 10px; font-size: 13px; color: #bcd6c7; border-radius: 7px;
  white-space: normal; line-height: 1.35;
}
.nav-sub a.active { background: #fff; color: var(--brand-ink); font-weight: 600; }
.nav-sub a.soon { color: oklch(0.62 0.03 168); }
.nav-sub a.soon:hover { background: rgba(255,255,255,.06); color: oklch(0.72 0.03 168); }
.nav-count {
  background: var(--warn-strong); color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 99px; padding: 0 7px; font-variant-numeric: tabular-nums;
}
.sidebar-foot-note {
  padding: 10px 16px 14px; font-size: 11px; color: oklch(0.66 0.04 168);
  border-top: 1px solid rgba(255,255,255,.1);
}

/* แถบบน */
.topbar {
  display: flex; align-items: center; gap: 14px; background: #fff;
  border-bottom: 1px solid var(--line); padding: 10px 24px;
  position: sticky; top: 0; z-index: 30; min-height: 62px;
}
.topbar-burger { display: none; background: none; border: none; font-size: 21px; cursor: pointer; color: var(--ink); }
.topbar-company .code { font-weight: 700; font-size: 14px; line-height: 1.2; }
.topbar-company .name { font-size: 12px; color: var(--muted); }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; padding: 4px; }
.topbar-user .who .n { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.topbar-user .who .r { font-size: 11.5px; color: var(--faint); }
.topbar-user .caret { font-size: 10px; color: var(--faint); }
.topbar-menu {
  position: absolute; top: 100%; right: 0; margin-top: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px oklch(0.2 0.02 168 / .16);
  min-width: 170px; padding: 6px; z-index: 40;
}
.topbar-menu a, .topbar-menu button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 7px;
  font-size: 13.5px; color: var(--ink); background: none; border: none; cursor: pointer; font-family: inherit;
}
.topbar-menu a:hover, .topbar-menu button:hover { background: var(--brand-soft); color: var(--brand-ink); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: oklch(0.92 0.03 172);
  color: var(--brand-ink); display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0;
}

/* min-width:0 จำเป็นกับ flex item — ไม่งั้นตารางกว้างดัน layout ล้นจอแทนที่จะ scroll ในกล่องตัวเอง */
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; max-width: 1320px; }
.page-head { margin-bottom: 12px; }
.page-head .crumb { font-size: 12.5px; color: var(--faint); }
.page-head .crumb .sep { margin: 0 2px; }
.page-title { font-size: 23px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 2px; color: var(--brand-ink); }
.page-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* สมุดผู้ติดต่อ */
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.dir-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 12px; align-items: center;
}
.dir-card .n { font-size: 14px; font-weight: 600; }
.dir-card .d { font-size: 12.5px; color: var(--muted); display: block; }

/* ── Components ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .v { font: 600 30px/1.1 var(--num-font); font-variant-numeric: tabular-nums; }
.stat .v .of { color: #c2c8c4; font-size: 20px; }
.stat .l { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.stat.warn .v { color: var(--warn); }

label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.f > span { display: block; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=email], input[type=month], select, textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--input-border); border-radius: 10px;
  background: var(--input-bg); font-size: 14.5px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid oklch(0.52 0.09 172 / .3); border-color: var(--brand); }
textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 14px; background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #fff; border-color: var(--input-border); color: var(--ink); font-weight: 500; }
.btn.secondary:hover { background: #f7f8f7; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--brand); border: none; padding: 4px 8px; }
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand-ink); }
.btn.sm { padding: 6px 14px; font-size: 13px; }
.btn.big { padding: 15px 26px; font-size: 16px; border-radius: 11px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
  background: #fafbfa; font: 500 11.5px/1.3 "IBM Plex Sans", "Noto Sans Thai", sans-serif;
  letter-spacing: .08em; text-transform: uppercase; color: var(--faint); white-space: nowrap;
}
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line-row); vertical-align: top; }
.tbl tbody tr:hover td { background: #fafbfa; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { border-bottom: none; border-top: 1px solid var(--line); background: #fafbfa; }
.tbl-scroll { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--brand-chip); color: var(--brand-chip-ink); }
.badge.red { background: oklch(0.95 0.03 30); color: var(--danger); }
.badge.amber { background: var(--amber-bg); color: var(--amber-ink); }
.badge.blue { background: oklch(0.94 0.03 240); color: oklch(0.48 0.12 250); }
.badge.gray { background: #eef0ef; color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.alert.err { background: oklch(0.95 0.03 30); color: var(--danger); }
.alert.ok { background: var(--brand-soft); color: var(--brand-ink); }
.alert.info { background: oklch(0.94 0.03 240); color: oklch(0.42 0.1 250); }

.modal-back {
  position: fixed; inset: 0; background: oklch(0.2 0.02 168 / .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 680px;
  box-shadow: 0 24px 70px oklch(0.2 0.02 168 / .25);
}
.modal h3 { margin-top: 0; font-size: 17px; }
.modal.narrow { max-width: 460px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: none; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ── แดชบอร์ด ── */
.dash-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; margin-bottom: 20px; }
.clock-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 32px; display: flex; flex-direction: column; gap: 20px; }
.clock-card .top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--faint); }
.clock-time { display: flex; align-items: baseline; gap: 14px; }
.clock-time .hm { font: 600 64px/1 var(--num-font); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.clock-time .ss { font: 500 24px/1 var(--num-font); color: #a3aba6; font-variant-numeric: tabular-nums; }
.clock-meta { font-size: 13.5px; color: var(--muted); }
.clock-meta b { color: var(--ink); font-variant-numeric: tabular-nums; }
.punch-chips { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line-soft); padding-top: 16px; flex-wrap: wrap; }
.punch-chips .lbl { font-size: 12.5px; color: var(--faint); }
.punch-chip { font-size: 12.5px; font-variant-numeric: tabular-nums; background: var(--line-row); border-radius: 6px; padding: 2px 8px; }

.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.list-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-card .head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.list-card .head b { font-size: 15px; font-weight: 600; }
.list-card .head a { font-size: 13px; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line-row); }
.list-item:last-child { border-bottom: none; }
.list-item .avatar { width: 32px; height: 32px; background: var(--line-row); color: var(--muted); font-size: 12px; }
.list-item .t { flex: 1; min-width: 0; }
.list-item .t .n { font-size: 14px; font-weight: 500; }
.list-item .t .d { font-size: 12.5px; color: var(--faint); }
.list-empty { padding: 20px; color: var(--faint); font-size: 13.5px; }

.pay-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.pay-card .rows { display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.pay-card .rows > div { display: flex; justify-content: space-between; }
.pay-card .rows span { color: var(--muted); }
.pay-card .rows b { font-variant-numeric: tabular-nums; font-weight: 600; }
.pay-card .rows b.neg { color: var(--danger); }
.pay-card .total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.pay-card .total span { font-size: 13px; color: var(--muted); }
.pay-card .total b { font: 600 24px/1 var(--num-font); font-variant-numeric: tabular-nums; }

/* ── ศูนย์รายงาน ── */
.report-layout { display: grid; grid-template-columns: 268px 1fr; gap: 18px; align-items: start; }
.report-nav {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 8px 14px; position: sticky; top: 18px; max-height: calc(100vh - 40px); overflow-y: auto;
}
.report-link {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 12px; border-radius: 8px; font-size: 13.5px; color: #3f4844; cursor: pointer;
}
.report-link:hover:not(:disabled) { background: #f4f6f5; color: var(--ink); }
.report-link.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.report-link:disabled { color: #b9c0bb; cursor: not-allowed; }
.report-body { min-width: 0; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.report-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  background: #fafbfa; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px;
}
.report-sum-item .l { font-size: 12.5px; color: var(--muted); }
.report-sum-item .v { font: 600 18px/1.2 var(--num-font); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ── สลิปเงินเดือน ── */
.slip { max-width: 720px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 40px; }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--ink); padding-bottom: 14px; margin-bottom: 20px; }
.slip-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.slip-head .co { font-size: 13px; color: var(--muted); }
.slip-head .period { text-align: right; font-size: 13px; color: var(--muted); }
.slip-head .period b { display: block; color: var(--ink); font-size: 15px; }
.slip-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; font-size: 13.5px; margin-bottom: 24px; }
.slip-info > div { display: flex; justify-content: space-between; gap: 12px; }
.slip-info .k { color: var(--faint); }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.slip-sec {
  font: 500 11.5px/1 "IBM Plex Sans", "Noto Sans Thai", sans-serif; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 10px;
}
.slip-lines { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.slip-lines > div { display: flex; justify-content: space-between; gap: 12px; }
.slip-lines .amt { font-variant-numeric: tabular-nums; }
.slip-lines .sum { border-top: 1px solid var(--ink); padding-top: 7px; font-weight: 600; }
.slip-net {
  margin-top: 24px; background: var(--brand-soft); border-radius: 12px; padding: 16px 22px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.slip-net .k { font-size: 14px; font-weight: 600; color: var(--brand-ink); }
.slip-net .v { font: 600 26px/1 var(--num-font); font-variant-numeric: tabular-nums; color: oklch(0.34 0.08 172); }
.slip-split { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12.5px; color: var(--faint); }

.mob-topbar { display: none; }

@media print {
  body { background: #fff; }
  .sidebar, .no-print, .mob-topbar { display: none !important; }
  .main { padding: 0; max-width: none; }
  .slip { border: none; padding: 0; }
}

@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .report-layout { grid-template-columns: 1fr; }
  .report-nav { position: static; max-height: 260px; }
}
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .sidebar { position: fixed; left: -272px; transition: left .2s; z-index: 40; height: 100vh; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px oklch(0.2 0.02 168 / .35); }
  .topbar-burger { display: block; }
  .topbar { padding: 10px 14px; }
  .topbar-user .who { display: none; }
  .main { padding: 16px 14px 32px; }
  .grid2, .grid3, .slip-cols, .slip-info { grid-template-columns: 1fr; }
  .clock-time .hm { font-size: 48px; }
}
