:root {
  --brand: #6d28d9;
  --brand-dark: #2e1065;
  --brand-mid: #4c1d95;
  --brand-soft: #ede9fe;
  --brand-softer: #f5f3ff;
  --ink: #1f1b2e;
  --muted: #6b6880;
  --line: #e7e4f0;
  --bg: #f7f6fb;
  --card: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .05);
  font-family: "Noto Sans Thai", "Sarabun", "Thonburi", "Leelawadee UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--brand-dark), var(--brand-mid));
  color: #ede9fe; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: #a78bfa; color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand span { font-size: .75rem; opacity: .75; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a, .nav .soon {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #ddd6fe; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: #fff; color: var(--brand-dark); }
.nav .soon { opacity: .5; cursor: default; justify-content: space-between; }
.nav .soon em { font-style: normal; font-size: .7rem; background: rgba(255,255,255,.15); padding: 1px 6px; border-radius: 6px; }
.nav-section { margin: 16px 12px 6px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; opacity: .6; }
.nav-icon { width: 20px; text-align: center; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 28px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; max-width: 460px; }
.search input { width: 100%; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-link { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; }
.user-link:hover { background: var(--brand-softer); }
.user-link:hover strong { color: var(--brand); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.avatar.xs { width: 28px; height: 28px; font-size: .72rem; }
.avatar.lg { width: 88px; height: 88px; font-size: 1.8rem; }
.avatar.xl { width: 180px; height: 180px; font-size: 3.4rem; }
/* Large avatars sit on the lavender profile header: solid brand colour + white ring so the circle is visible. */
.avatar.lg, .avatar.xl {
  background: linear-gradient(135deg, var(--brand), #a78bfa); color: #fff;
  border: 4px solid #fff; box-shadow: 0 6px 18px rgba(76, 29, 149, .22);
}
img.avatar.photo { object-fit: cover; background: #fff; }
/* Evaluation pages (owner request 2026-11-14): big photos, coworkers know each other by face; tap to see it whole. */
.avatar.eval { width: 96px; height: 96px; font-size: 1.9rem; }
.avatar.eval-xl { width: 160px; height: 160px; font-size: 3rem; }
.face-link { display: block; border-radius: 50%; flex: none; }
.eval-person { display: flex; align-items: center; gap: 14px; }
.eval-who { min-width: 0; }
.eval-nick { font-size: 1.15rem; }
.eval-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; margin-bottom: 14px; }
.eval-nick-lg { font-size: 1.35rem; font-weight: 700; }
/* {% person %}: [photo] [code] [name (nickname)], the same in every list (owner request 2026-11-03). */
.person { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; max-width: 100%; }
.person-code { white-space: nowrap; }
.person-name { min-width: 0; }
.person-list { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 4px; }
.avatar-block { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.avatar-link { position: relative; display: block; border-radius: 50%; text-decoration: none; }
.avatar-overlay {
  position: absolute; inset: 4px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: rgba(46, 16, 101, .62); color: #fff; font-size: .74rem; font-weight: 600; line-height: 1.3;
  opacity: 0; transition: opacity .15s;
}
.avatar-link:hover .avatar-overlay, .avatar-link:focus-visible .avatar-overlay { opacity: 1; }
.avatar-caption {
  font-size: .78rem; font-weight: 600; color: var(--brand); background: #fff; border: 1px solid #ddd6fe;
  padding: 3px 10px; border-radius: 999px; text-decoration: none; white-space: nowrap;
}
.avatar-caption:hover { border-color: var(--brand); }
.photo-edit { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 0 18px; }
.photo-edit .small { text-align: center; }
.content { padding: 24px 28px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title .icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; color: var(--brand-dark); }
.stat.highlight { background: var(--brand-softer); border-color: #ddd6fe; }
a.card.stat { display: block; color: inherit; }
a.card.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat .value.ok-value { color: var(--ok); }
.stat .value.bad-value { color: var(--bad); }

.kv { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }

.profile-head {
  display: flex; align-items: center; gap: 20px; padding: 22px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--brand-soft), var(--brand-softer)); margin-bottom: 16px; flex-wrap: wrap;
}
.profile-head .meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.profile-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--brand-softer); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #faf9ff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* Badges & buttons */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.grey { background: #eceaf2; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: #c4b5fd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #5b21b6; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.link-btn { background: none; border: 0; color: #ddd6fe; font: inherit; cursor: pointer; padding: 0; }

/* Forms */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
input, select, textarea {
  font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c4b5fd; border-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: grid; gap: 5px; }
.field label { font-size: .85rem; font-weight: 600; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; }
.note-text { width: 100%; resize: vertical; }
.th-sort { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort:hover { color: var(--brand); }
.field .err { color: var(--bad); font-size: .82rem; }
.field .help { color: var(--muted); font-size: .82rem; }
.field[hidden] { display: none; }
/* Probation page: decision forms open under the row */
details.probation-actions summary { list-style: none; display: inline-flex; }
details.probation-actions summary::-webkit-details-marker { display: none; }
details.probation-actions[open] { display: grid; gap: 8px; min-width: 320px; }
.row-actions:has(details[open]) { align-items: flex-start; }
/* หัวหน้างาน: one row per supervisor with the team */
.team-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.team-row .btn { white-space: nowrap; flex-shrink: 0; }
.team-branch { margin-top: 12px; }
.team-branch-title { margin: 16px 0 0; font-size: 1rem; color: var(--brand-mid); }
label.check-row[hidden] { display: none; }
.text-bad { color: var(--bad); }
.pay-summary { margin-bottom: 18px; }
.pay-summary .value { font-size: 1.4rem; }
details.pay-add { margin-top: 14px; }
details.pay-add > summary { list-style: none; display: inline-flex; }
details.pay-add > summary::-webkit-details-marker { display: none; }
details.pay-add .when-open, details.pay-add[open] .when-closed { display: none; }
details.pay-add[open] .when-open { display: inline; }
details.pay-add[open] > summary { margin-bottom: 4px; }
/* Wide tables: headers on one line, the table scrolls sideways inside .table-wrap */
.wide-table th, .wide-table td { white-space: nowrap; }
/* Leave type form: live summary */
.leave-summary { border-color: var(--brand-soft); background: var(--brand-softer); }
.leave-summary .summary-text { font-size: 1.02rem; line-height: 1.7; margin: 6px 0 12px; }
/* Searchable employee picker (static/hr/employee-picker.js) */
.picker { position: relative; }
.picker-input { width: 100%; }
.picker-input.picker-invalid { border-color: var(--bad); outline-color: var(--bad-soft); }
.picker-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; }
.picker-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; max-height: 280px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.picker-list li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-list li.active, .picker-list li:hover { background: var(--brand-soft); }
.picker-list li.picker-empty { color: var(--muted); cursor: default; background: none; }
.filters .picker { min-width: 240px; }
/* Checkboxes sit in front of their text on the same line (owner request 2026-10-20), never
   stretched to the full field width like text inputs. */
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; padding: 0; margin: 0; flex: none; accent-color: var(--brand); cursor: pointer;
}
.field input[type="checkbox"], .field input[type="radio"] { width: 18px; }
label.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; line-height: 1.4; }
.field:has(> label.check-row) { align-self: center; padding: 6px 0; }
.field-title { font-size: .85rem; font-weight: 600; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.link-code { font-size: 2rem; font-weight: 700; letter-spacing: .3em; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
ol.steps { padding-left: 20px; display: grid; gap: 8px; }
.pick-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; color: inherit; text-decoration: none; }
.pick-row:hover { border-color: var(--brand); }
.pick-row.done { opacity: .6; }
tr:has(+ tr.flag-row) td { border-bottom: 0; }
tr.flag-row td { padding-top: 0; }
tr.flag-row .notice { margin: 0; }
.check-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 10px; }
.check-filters label { display: flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; }
.check-filters select { width: auto; min-width: 150px; }
.check-list label.check-row { font-weight: 400; font-size: .92rem; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--brand-softer); border: 1px solid #ddd6fe; }
.notice.warn { background: var(--warn-soft); border-color: #fde68a; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.timeline .when { color: var(--muted); font-size: .85rem; }

/* Landing */
.landing { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.landing .card { width: min(420px, 92vw); text-align: center; padding: 36px; }

/* Phone / tablet: the menu hides behind a hamburger (owner request 2026-10-30). A hidden
   checkbox (#nav-open) holds open/closed, so it needs no inline script (CSP). */
.nav-open, .nav-backdrop, .nav-close, .hamburger, .topbar-brand { display: none; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: min(290px, 84vw); height: 100vh; height: 100dvh;
    transform: translateX(-102%); transition: transform .22s ease, visibility .22s; visibility: hidden;
  }
  .nav-open:checked ~ .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav-open:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 5, 40, .45); }
  .brand { justify-content: flex-start; }
  .nav-close {
    display: grid; place-items: center; margin-left: auto; width: 36px; height: 36px; border-radius: 10px;
    color: #fff; font-size: 1.1rem; cursor: pointer;
  }
  .nav-close:hover { background: rgba(255,255,255,.12); }
  .hamburger {
    display: grid; align-content: center; gap: 4px; width: 40px; height: 40px; padding: 0 10px; flex: none;
    border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  }
  .hamburger span { display: block; height: 2px; border-radius: 2px; background: var(--ink, #1f1530); }
  .topbar { gap: 10px; }
  .topbar-brand { display: block; flex: none; }
  .topbar-brand .brand-mark { width: 34px; height: 34px; font-size: .85rem; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .user .user-name { display: none; }
  .search input { padding: 8px 10px; }
}
@media (max-width: 640px) {
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { text-align: left; }
}
.center-mark { margin: 0 auto 14px; }
.grid > .card + .card { margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--brand); }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
/* Payroll pages: cards stacked one per row, full width; tabs wrap instead of scrolling. */
.card-stack .card + .card { margin-top: 18px; }
.card-stack .tabs { flex-wrap: wrap; }
/* Records hub tiles */
a.record-tile { display: block; color: inherit; }
a.record-tile:hover { text-decoration: none; border-color: var(--brand); }
a.record-tile .tile-num { font-size: 2rem; font-weight: 700; margin: 6px 0; }
.flash { margin-bottom: 14px; }
tr.inactive td { opacity: .55; }
.nav .count { font-style: normal; margin-left: auto; background: #f43f5e; color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 999px; }
.schedule-table td, .schedule-table th { padding: 6px; text-align: center; }
.schedule-table td:first-child, .schedule-table th:first-child { text-align: left; white-space: nowrap; }
.schedule-table select { width: 100%; min-width: 108px; padding: 5px 6px; font-size: .85rem; }
.schedule-table td.weekend { background: #faf8ff; }
.schedule-table .cell-note { display: block; font-size: .72rem; color: var(--muted); }
.schedule-table td.draft select { border-style: dashed; }
/* one colour per shift (rostering.views.SHIFT_TONES), day off in grey-green */
.shift-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.shift-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid transparent; }
.schedule-table .cell-note.shift-chip { display: inline-block; }
.schedule-table .cell-move { display: block; margin-top: 2px; font-size: .7rem; white-space: nowrap; }
.schedule-table select[class*="shift-tone-"] { font-weight: 600; }
.shift-tone-0 { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.shift-tone-1 { background: #fde68a; color: #854d0e; border-color: #f59e0b; }
.shift-tone-2 { background: #fce7f3; color: #9d174d; border-color: #f9a8d4; }
.shift-tone-3 { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.shift-tone-4 { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.shift-tone-5 { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.shift-tone-6 { background: #cffafe; color: #155e75; border-color: #67e8f9; }
.shift-tone-7 { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.shift-tone-off { background: #e5e7eb; color: #4b5563; border-color: #d1d5db; }
.net-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.net-banner strong { font-size: 1.6rem; }
@media print {
  .sidebar, .topbar, .no-print, .flash, .bottom-nav, .tab-bar, .day-switch, .fold-toggle, .kv-more { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
.link-code { font-size: 1.6rem; letter-spacing: .2em; }
/* public invite pages (no sidebar) */
body.public { background: var(--bg, #f6f5fb); }
.public-main { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.public-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; color: #1f2937; padding: 0; }
.public-brand span { display: block; color: #6b7280; font-size: .9rem; }
.steps li { margin: 12px 0; }
.steps .btn { margin-top: 8px; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0 16px; }
label.check input[type="checkbox"] { margin-top: 3px; }
.invite-url { font-family: ui-monospace, monospace; word-break: break-all; }
.nav li.sub a { padding-left: 34px; font-size: .92rem; }
.invite-row { border-top: 1px solid #eee; padding: 10px 0; display: grid; gap: 4px; }
.invite-row:first-of-type { border-top: 0; }
.chat-preview { white-space: normal; max-width: 520px; background: #e8f9ee; border-color: #b7ebc6; }
.templates li { margin-bottom: 10px; }
td.narrow input { width: 60px; }
form.inline { display: inline; }
.confirm-form textarea, .feedback-form textarea { width: 100%; margin-top: 6px; }
.feedback-form { margin-top: 6px; }
.feedback-text { white-space: normal; line-height: 1.6; }
.run-branch { margin: 18px 0 8px; }
.bio-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.preview-img { max-width: 240px; margin-top: 8px; border-radius: 8px; }
.join-card { text-align: left; }
.join-card .lead { font-size: 1.05rem; }
.btn.big { display: block; text-align: center; font-size: 1.15rem; padding: 16px 20px; margin: 16px 0; background: #06c755; border-color: #06c755; }
.steps-simple li { margin: 6px 0; }
.step-card { display: flex; gap: 14px; align-items: flex-start; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; margin: 12px 0; }
.step-no { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #6d28d9; color: #fff; display: grid; place-items: center; font-weight: 700; }
.btn.armed { background: #b45309; border-color: #b45309; color: #fff; }
.confirm-note { margin-top: 8px; }
.import-form { display: grid; gap: 6px; min-width: 260px; margin-top: 8px; }
.import-form label { display: grid; gap: 2px; font-size: .9rem; }
/* Terminal-admin page: small stacked forms inside a row's "จัดการ…" panel */
.stack { display: grid; gap: 6px; padding: 10px 0; min-width: 220px; border-top: 1px solid var(--line); }
.stack label { display: grid; gap: 2px; font-size: .85rem; }
.card.narrow { max-width: 560px; }
.card-title .push-right { margin-left: auto; }
.kv-heading { margin: 16px 0 8px; font-size: .95rem; }

/* Schedule: bulk assign over a date range */
.bulk-card summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.bulk-form { margin-top: 14px; }
.bulk-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 14px 18px; align-items: start; }
.bulk-grid .field:first-child, .bulk-grid .field:nth-child(5), .bulk-grid .field:nth-child(6) { grid-column: span 2; }
@media (max-width: 980px) { .bulk-grid { grid-template-columns: 1fr 1fr; } .bulk-grid .field { grid-column: 1 / -1; } }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
/* Employee profile: cards in the same row share one height (owner request 2026-10-29). */
.profile-cards { align-items: stretch; }
.profile-cards > .card { display: flex; flex-direction: column; }
.profile-cards > .card > .form-actions, .profile-cards .card-foot { margin-top: auto; padding-top: 12px; }
.notify-table td:first-child { min-width: 220px; }
.notify-table input[type=checkbox] { width: 20px; height: 20px; }
th.center, td.center { text-align: center; }
.link-cell { min-width: 240px; }
.link-cell form + form, .link-cell a + form { margin-top: 6px; }
.link-form { display: grid; gap: 6px; }
.form-grid .field { align-self: start; }
.reply-thumb { display: block; max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); margin-top: 6px; }
.scan-table td { vertical-align: middle; padding-top: 12px; padding-bottom: 12px; }
.scan-table td.when { white-space: nowrap; width: 1%; padding-right: 20px; }
.scan-table td > .muted { display: block; margin-top: 2px; }
.scan-table .code { white-space: nowrap; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.device-row:first-of-type { border-top: 0; padding-top: 2px; }
.device-row .muted { margin-top: 3px; }
details.grade-adjust summary { list-style: none; display: inline-flex; }
details.grade-adjust summary::-webkit-details-marker { display: none; }
details.grade-adjust[open] form { display: grid; gap: 6px; min-width: 200px; margin-top: 6px; }
/* Evidence files of an advance (owner request 2026-11-12): links under the reason, "📎 แนบไฟล์" on a
   request that waits, and the files kept on the edit page with a "เอาออก" tick each. */
.advance-files { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; }
/* บันทึกว่าจ่ายแล้ว with an optional หลักฐานการจ่าย (payroll run page) */
.pay-form { display: grid; gap: 6px; width: 190px; margin-bottom: 0; }
.pay-form input { width: 100%; }
.pay-form input[type=file] { padding: 6px 8px; font-size: .82rem; }
td.pay-proof { min-width: 130px; }
td.slip-flags { min-width: 180px; }
td.slip-flags .badge { white-space: normal; margin-bottom: 4px; }  /* long notes wrap, the buttons stay in view */
details.attach-more summary { list-style: none; display: inline-flex; }
details.attach-more summary::-webkit-details-marker { display: none; }
details.attach-more[open] form { display: grid; gap: 6px; min-width: 240px; margin-top: 6px; white-space: normal; }
.kept-files { display: grid; gap: 4px; }
.kept-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.kept-file label.check-row { font-weight: 400; }
.stat .value.small-value { font-size: 1.05rem; padding-top: 6px; }
.narrow-input { max-width: 160px; }
.eval-item { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rating { display: flex; gap: 8px; flex-wrap: wrap; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating span { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; background: var(--card); }
.rating input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.rating input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* KPI evaluations (2026-10-31): system numbers beside a topic, coworker pairs, HR review */
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 12px; border-radius: 10px; background: var(--brand-softer); border: 1px solid #ddd6fe; }
.facts-title { font-weight: 700; font-size: .85rem; margin-right: 4px; }
.fact { padding: 2px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .85rem; }
.facts .small { flex-basis: 100%; }
.inline-filter { display: flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; }
.inline-filter select { width: auto; min-width: 160px; }
.pair-picks { display: grid; gap: 8px; max-width: 420px; }  /* one under the other on every row, whatever the name length */
.pair-picks select { width: 100%; min-width: 280px; }
.pair-table td, .review-table td { vertical-align: top; }
.review-table .flag { margin-top: 4px; font-size: .82rem; color: var(--warn); font-weight: 600; }
.eval-list { margin-top: 6px; }
.eval-list summary { cursor: pointer; color: var(--brand); }
.eval-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); }
.eval-row.excluded > div:first-child { opacity: .55; }
.confirm-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.confirm-form .narrow-input { max-width: 90px; }
.confirm-form input[type="text"] { flex: 1; min-width: 140px; }
.inline-form { display: inline; }
.tabs + .grid { margin-top: 0; }
.pct-input { width: 150px; max-width: 100%; }
.branch-kpi select { min-width: 240px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.report-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.report-filters label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; }
.report-filters select, .report-filters input { width: auto; min-width: 150px; }
.nowrap { white-space: nowrap; }
.as-notice ul { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.as-notice + .card { margin-top: 16px; }
/* KPI Dashboard overview (2026-10-31) */
.trend { font-size: .78rem; font-weight: 600; }
.trend.up { color: #15803d; }
.trend.down { color: #b91c1c; }
.grade-dist { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.todo-list li:last-child { border-bottom: 0; }
.top-branch + .top-branch { margin-top: 10px; }
.top-branch ol { margin: 4px 0 0; padding-left: 20px; }
.overview-grid { margin-top: 16px; }
.todo-list .btn { white-space: nowrap; flex: none; }

/* ดูเฉพาะสาขา: the branch picker under the logo (2026-10-31) */
.branch-view { display: grid; gap: 4px; margin: -8px 8px 16px; }
.branch-view label { font-size: .75rem; color: #ddd6fe; font-weight: 600; }
.branch-view select { width: 100%; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 8px 10px; font-size: .9rem; }
.branch-view select option { color: var(--ink, #1f1b2e); }
.branch-view.on select { background: #fff; color: var(--brand-dark); font-weight: 700; border-color: #fff; }
.branch-view-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.move-cell { white-space: nowrap; }
/* แบบประเมิน topics: the whole หัวข้อ / คำอธิบาย shows; grows with the text where the browser can */
.cell-text { width: 100%; min-width: 260px; resize: vertical; field-sizing: content; min-height: 3.2em; line-height: 1.45; }
.cell-text.title-text { min-width: 180px; }
.move-btn { padding: 4px 8px; min-width: 0; }
.move-btn + .move-btn { margin-left: 4px; }
table[data-reorder] tbody tr:first-child [data-move="up"], table[data-reorder] tbody tr:last-child [data-move="down"] { visibility: hidden; }

/* ตัวอย่างข้อความ LINE (messaging/flex_html.py): LINE chat look, classes only (strict CSP) */
.example-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.example-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  color: inherit; text-decoration: none; }
.example-tile:hover { border-color: var(--brand); }
.example-tile > span:last-child { color: var(--brand); margin-top: auto; }
.example-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .example-layout { grid-template-columns: 1fr; } }
.phone { background: #1f1b2e; border-radius: 28px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.phone > .small { color: #c4bfd6; padding-bottom: 4px; }
.phone-top { color: #fff; font-weight: 700; text-align: center; padding: 6px 0 2px; }
.phone-chat { background: #8cabd9; border-radius: 18px; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; min-height: 260px; }
.phone-chat.preview-inline { max-width: 380px; margin-top: 8px; }
ol.flow { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0; counter-reset: flow; }
ol.flow li { counter-increment: flow; position: relative; padding: 10px 12px 10px 44px; background: var(--brand-softer); border-radius: 10px; }
ol.flow li::before { content: counter(flow); position: absolute; left: 12px; top: 9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
ol.flow li + li { margin-top: 18px; }
ol.flow li + li::after { content: "↓"; position: absolute; left: 18px; top: -18px; color: var(--brand); line-height: 18px; }
.lf-bubble { background: #fff; border-radius: 14px; overflow: hidden; width: 100%; max-width: 300px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.lf-carousel { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.lf-carousel .lf-bubble { flex: 0 0 82%; }
.lf-header, .lf-body, .lf-footer { padding: 14px 16px; }
.lf-header + .lf-body { padding-top: 12px; }
.lf-footer { padding-top: 4px; }
.lf-box { display: flex; min-width: 0; }
.lf-col { flex-direction: column; }
.lf-row { flex-direction: row; align-items: flex-start; gap: 8px; }
.lf-gap-sm { gap: 6px; } .lf-gap-md { gap: 10px; }
.lf-pad { padding: 8px; } .lf-round { border-radius: 8px; }
.lf-tap { cursor: help; }
.lf-text { font-size: 14px; color: #1f1b2e; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.lf-size-xxs { font-size: 11px; } .lf-size-xs { font-size: 12px; } .lf-size-sm { font-size: 13px; }
.lf-size-md { font-size: 15px; } .lf-size-lg { font-size: 18px; } .lf-size-xl { font-size: 21px; }
.lf-bold { font-weight: 700; }
.lf-align-end { text-align: right; } .lf-align-center { text-align: center; }
.lf-margin-sm { margin-top: 4px; } .lf-margin-md { margin-top: 10px; } .lf-margin-lg { margin-top: 14px; } .lf-margin-xl { margin-top: 18px; }
.lf-flex-0 { flex: 0 0 auto; } .lf-flex-1 { flex: 1 1 0; } .lf-flex-2 { flex: 2 1 0; } .lf-flex-3 { flex: 3 1 0; } .lf-flex-4 { flex: 4 1 0; }
.lf-flex-5 { flex: 5 1 0; } .lf-flex-6 { flex: 6 1 0; } .lf-flex-7 { flex: 7 1 0; } .lf-flex-8 { flex: 8 1 0; } .lf-flex-9 { flex: 9 1 0; }
.lf-c-ink { color: #1f1b2e; } .lf-c-muted { color: #8c8c8c; } .lf-c-brand { color: #6d28d9; } .lf-c-ok { color: #15803d; }
.lf-c-warn { color: #b45309; } .lf-c-bad { color: #b91c1c; } .lf-c-grey { color: #555; }
.lf-bg-head { background: #f3effe; } .lf-bg-soft { background: #ede9fe; } .lf-bg-tile { background: #f7f5fc; } .lf-bg-brand { background: #6d28d9; }
.lf-sep { border: 0; border-top: 1px solid #ece9f5; margin: 10px 0 0; width: 100%; }
.lf-button { border-radius: 8px; padding: 9px 10px; text-align: center; font-size: 14px; font-weight: 600; cursor: help; }
.lf-button-primary { background: #6d28d9; color: #fff; }
.lf-button-secondary { background: #ede9fe; color: #1f1b2e; }
.lf-footer .lf-button + .lf-button { margin-top: 6px; }
.lf-chat { background: #fff; border-radius: 14px; padding: 10px 12px; max-width: 300px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.lf-image { color: #555; }
.lf-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.lf-chip { background: #fff; border: 1px solid #c9c3e6; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: help; }

/* Table cards on phones (static/hr/table-cards.js, owner request 2026-11-06): one card per row, every
   value under its column name, the row's buttons on their own line at the bottom, nothing past the
   right edge. Desktop and tablets keep the table. */
@media (max-width: 640px) {
  .table-wrap:has(> table.cards) { overflow-x: visible; }
  table.cards, table.cards > tbody, table.cards > tfoot { display: block; width: 100%; }
  table.cards > thead { display: none; }
  table.cards > tbody > tr, table.cards > tfoot > tr {
    display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; width: 100%;
    border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--card, #fff);
  }
  table.cards > tbody > tr > :is(td, th), table.cards > tfoot > tr > :is(td, th) {
    display: block; flex: 1 1 100%; position: relative; width: auto; min-width: 0; min-height: 1.4em; padding: 3px 0 3px calc(36% + 10px);
    border: 0; background: none; text-align: left; white-space: normal; overflow-wrap: anywhere;
  }
  table.cards :is(td, th)::before {
    content: attr(data-label); position: absolute; left: 0; top: 4px; width: 36%;
    color: var(--muted); font-size: .78rem; font-weight: 600; line-height: 1.35;
  }
  table.cards:not(.m-titled) > tbody > tr > :is(td, th):first-child, table.cards :is(td, th)[data-label=""] { padding-left: 0; }
  table.cards:not(.m-titled) > tbody > tr > :is(td, th):first-child::before, table.cards :is(td, th)[data-label=""]::before { content: none; }
  table.cards:not(.m-titled) > tbody > tr > :is(td, th):first-child { font-weight: 600; padding-bottom: 6px; }
  table.cards :is(td, th):empty { display: none; }
  table.cards > tbody > tr > td.cell-actions, table.cards > tfoot > tr > td.cell-actions {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center; order: 9; margin-top: 6px; padding: 10px 0 0; border-top: 1px dashed var(--line);
  }
  table.cards td.cell-actions:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
  table.cards td.cell-actions::before { content: none; }
  table.cards td.cell-actions > form, table.cards td.cell-actions form.filters { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
  table.cards .row-actions { flex-wrap: wrap; white-space: normal; }
  table.cards details.probation-actions[open] { min-width: 0; width: 100%; }
  table.cards details.attach-more[open] { width: 100%; }
  table.cards details.attach-more[open] form { min-width: 0; }
  table.cards :is(td, th) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { max-width: 100%; min-width: 0; }
  table.cards td.empty { display: block; text-align: center; }
  table.cards .nowrap { white-space: normal; }
  table.cards .person { flex-wrap: wrap; row-gap: 2px; }
  /* Rows of buttons, titles, tabs and form buttons wrap instead of running past the edge */
  .row-actions, .card-title, .form-actions, .tabs { flex-wrap: wrap; }
  .row-actions { white-space: normal; }
  .tabs { overflow-x: visible; }
  .card-title > * { min-width: 0; }
  .content code { overflow-wrap: anywhere; }
  table.cards.notify-table td:first-child { min-width: 0; }
  .filters .picker, .filters label, .filters select, .filters input:not([type=checkbox]):not([type=radio]) { max-width: 100%; }
  /* Grids that stay tables (week schedule): the name column stays in view while the days scroll */
  .schedule-table td:first-child, .schedule-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--card, #fff); }

  /* Shorter cards (2026-11-11, static/hr/table-cards.js "data-m"): heading line, grey sub line,
     number boxes, then the other lines. Two empty full-width items break the lines between the groups. */
  table.cards > :is(tbody, tfoot) > tr::before, table.cards > :is(tbody, tfoot) > tr::after { content: ""; flex: 0 0 100%; height: 0; }
  table.cards > :is(tbody, tfoot) > tr::before { order: -3; }
  table.cards > :is(tbody, tfoot) > tr::after { order: -1; }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th):is(.m-title, .m-badge, .m-sub, .m-plain) { padding-left: 0; }
  table.cards :is(td, th):is(.m-title, .m-badge, .m-sub, .m-plain)::before { content: none; }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th).m-title { order: -5; flex: 1 1 auto; padding-bottom: 4px; font-weight: 700; font-size: 1rem; }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th).m-badge { order: -4; flex: 0 1 auto; width: auto; margin-left: auto; padding: 0 0 4px; text-align: right; font-size: .85rem; color: var(--muted); }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th).m-sub { order: -2; flex: 0 1 auto; padding: 0 0 2px; color: var(--muted); font-size: .88rem; }
  table.cards :is(td, th).m-sub:not(.m-sub-first)::before { content: "·"; position: static; width: auto; margin-right: 8px; font-size: inherit; color: inherit; }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th).m-num { flex: 1 1 22%; min-width: 68px; padding: 8px 0 0; text-align: left; font-variant-numeric: tabular-nums; }
  table.cards :is(td, th).m-num::before { position: static; display: block; width: auto; margin-bottom: 1px; }
  table.cards > :is(tbody, tfoot) > tr > :is(td, th):is(.m-hide, .m-empty) { display: none; }
  table.cards tr.row-link { cursor: pointer; padding-right: 30px; background-repeat: no-repeat; background-position: right 12px top 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='15' viewBox='0 0 9 15'%3E%3Cpath d='M1.5 1.5l6 6-6 6' fill='none' stroke='%236d28d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
  table.cards tr.row-link:active { background-color: var(--brand-softer); }
}


/* Phones, the whole system at once (owner request 2026-11-11, mobile review). Desktop is unchanged.
   mobile.js adds the small buttons used here (kv-more, fold-toggle); they show on a phone only. */
.m-only, .search-open, .search-toggle, .nav-logout, .kv-more, .fold-toggle { display: none; }
.nav-logout button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: #ddd6fe; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
@media (max-width: 640px) {
  .m-only { display: inline; }
  .d-only { display: none !important; }
  /* Fields: 16px text, or iPhone / the LINE browser zooms in on every tap and stays zoomed */
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), select { min-height: 44px; }
  .schedule-table select { font-size: 16px; min-height: 40px; }
  /* Finger-size buttons and ticks */
  .btn { min-height: 44px; justify-content: center; }
  .btn.sm { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
  .move-btn { min-width: 40px; }
  input[type="checkbox"], input[type="radio"], .field input[type="checkbox"], .field input[type="radio"] { width: 22px; height: 22px; }
  label.check-row { min-height: 40px; }
  /* Top bar: 🔍 opens the search under the bar; log out moves into the menu */
  .topbar .search, .topbar-logout { display: none; }
  .search-toggle { display: grid; place-items: center; width: 40px; height: 40px; margin-left: auto; border-radius: 10px;
    border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 1.05rem; }
  .search-toggle ~ .user { margin-left: 0; }
  .search-open:checked ~ .search { display: block; position: absolute; left: 0; right: 0; top: 100%; max-width: none;
    padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .search-open:checked + .search-toggle { background: var(--brand-soft); border-color: #c4b5fd; }
  .nav-logout { display: block; }
  .sys-alert { padding: 6px 12px; font-size: .85rem; margin-bottom: 10px; }
  /* Page heading: smaller, long descriptions show two lines and "อ่านต่อ" */
  h1 { font-size: 1.35rem; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .fold:not(.open) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .fold-toggle { display: inline-block; padding: 2px 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
  .card { padding: 16px; }
  /* Number boxes two per line, not one per screen */
  .grid:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .label { font-size: .8rem; line-height: 1.35; }
  .stat .value { font-size: 1.35rem; overflow-wrap: anywhere; }
  .net-banner strong { font-size: 1.35rem; }
  /* Profile lists: name left, value right; lines that only say "—" fold behind a button */
  .kv { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 6px 12px; }
  .kv dd { text-align: left; }
  .kv:not(.show-empty) > .kv-empty { display: none; }
  .kv-more { display: inline-block; align-self: flex-start; margin-top: 8px; padding: 6px 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
  /* Filters: two per line, a search box on its own line */
  form.filters:has(> label) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; align-items: end; }
  form.filters:has(> label) > label { min-width: 0; }
  form.filters:has(> label) > label:has(> input[type=search], > input[type=text], > .picker) { grid-column: 1 / -1; }
  form.filters:has(> label) > label > :is(input:not([type=checkbox]):not([type=radio]), select) { width: 100%; min-width: 0; }
  form.filters:has(> label) > label.check-row { grid-column: 1 / -1; }
  /* A select is as wide as its longest choice: never wider than the screen */
  select { max-width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > label { min-width: 0; }
  table.cards td.cell-actions > form > :is(select, input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .picker) { flex: 1 1 160px; min-width: 0; max-width: 100%; }
  /* The save buttons of a long form stay at the bottom of the screen */
  form:not(:has(.schedule-table)) > .form-actions:last-child { position: sticky; bottom: 0; z-index: 4;
    margin-top: 16px; padding: 10px 0; background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 12px -10px rgba(30, 20, 60, .25); }
}

/* Phones, part 2 (owner request 2026-11-11, phases 3 and 4) */
.bottom-nav, .tab-bar, .day-switch, .desktop-hint { display: none; }
.todo-card .pick-row { justify-content: space-between; font-weight: 600; }
.todo-card .count { font-style: normal; background: #f43f5e; color: #fff; font-size: .78rem; padding: 1px 9px; border-radius: 999px; }
.eval-progress { align-self: center; font-size: .9rem; font-weight: 600; color: var(--warn); }
.eval-progress.done { color: var(--ok); }
/* Menu (every screen; desktop owner request 2026-11-11): sub-items and the settings sections fold,
   mobile.js remembers what was opened */
.nav li.nav-group { display: flex; align-items: center; gap: 4px; }
.nav li.nav-group > a { flex: 1 1 auto; min-width: 0; }
.nav-fold { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.08); color: #ddd6fe; cursor: pointer; position: relative; }
.nav-fold:hover { background: rgba(255,255,255,.16); }
.nav-fold::after { content: "▾"; font-size: .9rem; transition: transform .15s; }
.nav-fold[aria-expanded="true"]::after { transform: rotate(180deg); }
.nav li.has-count > .nav-fold[aria-expanded="false"]::before { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #f43f5e; }
.nav li.nav-folded, ul.nav.nav-folded { display: none; }
.nav-section-fold { display: flex; align-items: center; justify-content: space-between; cursor: pointer; margin-right: 0; }
.nav-section-fold .nav-fold { width: 32px; height: 28px; }
@media (max-width: 980px) { .nav-fold { width: 40px; height: 40px; } .nav-section-fold .nav-fold { width: 34px; height: 30px; } }
@media (max-width: 640px) {
  /* Bottom bar: the main pages of each role one tap away, ☰ opens the whole menu */
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 2px;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(30, 20, 60, .08); }
  .bottom-nav > a, .bottom-nav > label { flex: 1 1 0; min-width: 0; min-height: 52px; position: relative; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px; border-radius: 10px; color: var(--muted); font-size: .72rem; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap; }
  .bottom-nav > a:hover { text-decoration: none; }
  .bottom-nav .bn-icon { font-size: 1.25rem; line-height: 1.1; }
  .bottom-nav > .active { color: var(--brand); background: var(--brand-softer); }
  .bottom-nav .count { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 999px;
    background: #f43f5e; color: #fff; font-size: .66rem; font-style: normal; line-height: 1.5; text-align: center; }
  body:has(.bottom-nav) .content { padding-bottom: 96px; }
  body:has(.bottom-nav) form:not(:has(.schedule-table)) > .form-actions:last-child { bottom: calc(60px + env(safe-area-inset-bottom)); }
  /* typing: the bar steps aside so it never sits on the keyboard or the field */
  body:has(:is(input:not([type=checkbox]):not([type=radio]), textarea):focus) .bottom-nav { display: none; }
  body:has(:is(input:not([type=checkbox]):not([type=radio]), textarea):focus) form:not(:has(.schedule-table)) > .form-actions:last-child { bottom: 0; }
  .link-form { grid-template-columns: minmax(0, 1fr); }
  /* สิทธิ์การลาพนักงาน (2026-11-12): only the leave types used or waiting; the rest in one line */
  table.cards td.lb-idle { display: none; }
  table.cards td.lb-idle-note { display: block; flex-basis: 100%; padding: 6px 0 0; }
  table.cards td.lb-idle-note:empty { display: none; }
  .desktop-hint { display: block; margin-bottom: 12px; font-size: .85rem; }
  /* Profile tabs (mobile.js profileTabs) */
  .tab-bar { display: flex; gap: 6px; overflow-x: auto; position: sticky; top: 68px; z-index: 4; margin: 0 -16px 12px; padding: 8px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-bar button { flex: none; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
    color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
  .tab-bar button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
  .content .tab-off { display: none !important; }
  .profile-head { padding: 16px; gap: 12px 16px; }
  .profile-head .avatar.lg { width: 64px; height: 64px; font-size: 1.35rem; border-width: 3px; }
  .profile-head .actions { margin-left: 0; }
  /* Payslip: the net amount first, the whole width */
  .grid > .stat-net { order: -1; grid-column: 1 / -1; }
  .grid > .stat-net .value { font-size: 1.7rem; }
  /* Week schedule: one day at a time (mobile.js scheduleDays) */
  .day-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
  .day-switch .btn.sm { min-height: 38px; padding: 6px 10px; }
  .schedule-table[data-day]:not([data-day="all"]) :is(th, td):not(:first-child) { display: none; }
  .schedule-table[data-day="1"] :is(th, td):nth-child(2), .schedule-table[data-day="2"] :is(th, td):nth-child(3),
  .schedule-table[data-day="3"] :is(th, td):nth-child(4), .schedule-table[data-day="4"] :is(th, td):nth-child(5),
  .schedule-table[data-day="5"] :is(th, td):nth-child(6), .schedule-table[data-day="6"] :is(th, td):nth-child(7),
  .schedule-table[data-day="7"] :is(th, td):nth-child(8) { display: table-cell !important; }
  .schedule-table[data-day]:not([data-day="all"]) { width: 100%; }
  .schedule-table[data-day]:not([data-day="all"]) :is(td, th):first-child { white-space: normal; width: 55%; position: static; }
  .schedule-table[data-day]:not([data-day="all"]) td:first-child .person { flex-wrap: wrap; row-gap: 0; }
  .schedule-table[data-day]:not([data-day="all"]) td:first-child .person-name { flex-basis: 100%; font-size: .9rem; }
  .schedule-table[data-day]:not([data-day="all"]) select { min-width: 0; width: 100%; }
  .schedule-table td[colspan] { display: table-cell !important; }
}

/* โควตาข้อความ LINE (owner request 2026-11-13) */
.quota-line { margin: 0 0 6px; }
.quota-left { font-size: 1.5rem; }
progress.quota-bar { display: block; width: 100%; height: 12px; margin: 4px 0 8px; accent-color: var(--brand); }

/* ข้อมูลพนักงาน: columns the viewer ticks (owner request 2026-11-17) */
details.col-picker { position: relative; }
details.col-picker > summary { list-style: none; cursor: pointer; }
details.col-picker > summary::-webkit-details-marker { display: none; }
details.col-picker .col-panel { position: absolute; right: 0; z-index: 20; margin-top: 6px; width: min(460px, 90vw); padding: 14px;
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); }
details.col-picker .col-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
details.col-picker .col-options label.check-row { font-weight: 400; font-size: .9rem; color: inherit; }
details.col-picker .col-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
p.duties-text { margin: 0 0 8px; line-height: 1.6; white-space: normal; overflow-wrap: anywhere; }

/* อนุมัติเบิกเงิน: HR may approve less than asked (owner request 2026-11-30) */
.amount-input { width: 7.5em; padding: 4px 6px; }
[data-room-out] { margin-top: 6px; }
