/* PANN HR — mobile-first · ฟอนต์ Sarabun · ไม่มี build step */
:root {
  --brand: #1f5eff;
  --brand-dark: #1747c4;
  --brand-soft: #e8efff;
  --ink: #1b2233;
  --ink-soft: #5b6478;
  --line: #e3e7ef;
  --bg: #f5f7fb;
  --card: #ffffff;
  --ok: #138a52;
  --ok-soft: #e3f6ec;
  --warn: #b26a00;
  --warn-soft: #fff4de;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --tap: 48px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
small, .muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- เปลือกหน้า */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800; letter-spacing: -.5px;
}
.topbar .spacer { flex: 1; }
.emp-switch { max-width: 52vw; }
.emp-switch select {
  width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 8px; font: inherit; font-size: .9rem; background: var(--bg); color: var(--ink);
}
.emp-name { font-size: .9rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-menu { display: none; }
.main { max-width: 960px; margin: 0 auto; padding: 16px; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--ink-soft); padding: 4px 2px; min-height: var(--tap); position: relative;
}
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav svg { width: 22px; height: 22px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad);
  color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700;
}
.bottom-nav .badge { position: absolute; top: 0; right: calc(50% - 22px); }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .layout { display: grid; grid-template-columns: 220px 1fr; max-width: 1200px; margin: 0 auto; }
  .side-menu { display: block; padding: 16px 8px; position: sticky; top: 56px; align-self: start; }
  .side-menu a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink);
  }
  .side-menu a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side-menu svg { width: 20px; height: 20px; }
  .main { margin: 0; max-width: none; padding: 24px; }
}

/* ---------------------------------------------------------------- การ์ด ปุ่ม ฟอร์ม */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card.center { text-align: center; }
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f3c4c4; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.huge { min-height: 96px; font-size: 1.4rem; border-radius: 20px; }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: .95rem; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 1.4rem; }

.msg { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: .95rem; }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.info { background: var(--brand-soft); color: var(--brand-dark); }

.pill {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; background: var(--bg);
  border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------------------------------------------------------------- ตาราง รายการ แท็บ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.tabs button {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px;
  font: inherit; font-size: .92rem; cursor: pointer; color: var(--ink-soft); min-height: 40px;
}
.tabs button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }

/* ---------------------------------------------------------------- หน้า login */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; padding-bottom: 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.auth-logo .brand-mark { width: 56px; height: 56px; border-radius: 16px; font-size: 1.2rem; }
.auth-logo .name { font-size: 1.4rem; font-weight: 700; }

.skeleton { background: linear-gradient(90deg, #eef1f6, #f7f9fc, #eef1f6); background-size: 200% 100%;
  animation: sk 1.2s infinite linear; border-radius: 8px; min-height: 18px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 90vw;
  box-shadow: var(--shadow); font-size: .95rem;
}
.stat { font-size: 1.6rem; font-weight: 700; }

.more-sheet {
  position: fixed; right: 8px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 30; background: var(--card);
  border-radius: 14px; box-shadow: 0 8px 30px rgba(20, 30, 60, .18); padding: 6px; min-width: 200px;
}
.more-sheet a { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--ink); border-radius: 10px; position: relative; }
.more-sheet a.active { background: var(--brand-soft); color: var(--brand); }
.more-sheet svg { width: 20px; height: 20px; }
.more-sheet .badge { margin-left: auto; }
@media (min-width: 900px) { .more-sheet { display: none; } }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 110px; }
.chip b { display: block; font-size: 1.2rem; }
.req-card { border-left: 4px solid var(--line); }
.req-card.pending { border-left-color: var(--warn); }
.req-card.approved { border-left-color: var(--ok); }
.req-card.rejected, .req-card.cancelled { border-left-color: var(--bad); }
.cal td, .cal th { padding: 4px 6px; text-align: center; font-size: .82rem; }
.cal td:first-child, .cal th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); white-space: nowrap; }
