/* Minimal, calm UI: neutral surfaces, one muted indigo accent, hairline borders, no decorative shadows. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --border: #e7e7e3;
  --border-strong: #d9d9d4;
  --text: #22242b;
  --text-2: #565a64;
  --text-3: #737783;

  --primary: #4651b8;
  --primary-strong: #3a449f;
  --primary-soft: #eef0f9;

  /* status tones: pale fills, readable inks */
  --mint: #ecf6f1;   --mint-ink: #2a7656;
  --peach: #fbf1ea;  --peach-ink: #a65a2f;
  --rose: #fbeef0;   --rose-ink: #b23c58;
  --sky: #edf4fa;    --sky-ink: #2c6a9e;
  --lemon: #faf5e4;  --lemon-ink: #85640c;
  --lilac: #f3f0fa;  --lilac-ink: #6a4cb0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: none;
  --shadow-lg: 0 12px 32px rgba(34, 36, 43, .10), 0 2px 6px rgba(34, 36, 43, .05);
  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* always reserve the scrollbar's space, so short and long pages line up and the menu does not shift between pages */
html { scrollbar-gutter: stable; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #d9dcf3; color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a.card:hover, a.user-card:hover, .nav a:hover, .bottomnav a:hover, a.btn:hover { text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Sign-in ---------- */
/* The shop's side reads like the clock on the wall: name, the time, today's date. The form side stays quiet. */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 42%) minmax(0, 1fr); background: var(--bg); }
.auth-brand {
  --ink: #f3f3ef; --ink-2: #a8abb5;
  background: #1f2128; color: var(--ink);
  padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-brand ::selection { background: #3d4152; color: #fff; }
.auth-shop { display: flex; align-items: center; gap: 14px; max-width: 34ch; }
.auth-shop b { font-weight: 500; font-size: 15px; line-height: 1.4; text-wrap: balance; }
.auth-logo { width: 48px; height: 48px; border-radius: 12px; flex: none; display: grid; place-items: center; background: #fff; color: #1f2128; overflow: hidden; }
.auth-logo.has-img { padding: 5px; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo .icon { width: 22px; height: 22px; stroke-width: 2; }
.auth-time { font-size: clamp(72px, 8.4vw, 120px); font-weight: 500; line-height: .95; letter-spacing: -.035em; }
.auth-date { margin-top: 14px; font-size: 16px; color: var(--ink-2); }
.auth-foot { font-size: 13px; color: var(--ink-2); border-top: 1px solid #343743; padding-top: 16px; }

.auth-main { display: grid; place-items: center; padding: 48px 24px; }
.auth-form { width: 100%; max-width: 360px; animation: auth-in .5s cubic-bezier(.16, 1, .3, 1) both; }
.auth-form h1 { font-size: 26px; letter-spacing: -.01em; }
.auth-form > p.muted { margin: 6px 0 28px; }
.auth-form .input { height: 46px; }
.auth-code { text-transform: uppercase; letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.auth-code::placeholder { text-transform: none; letter-spacing: 0; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 50px; }
.pw-wrap .icon-btn { position: absolute; right: 5px; top: 5px; color: var(--text-3); }
.pw-wrap .icon-btn[aria-pressed="true"] { color: var(--primary); }
.auth-form .alert { margin-bottom: 14px; }
.auth-form .btn-primary { margin-top: 4px; }
.auth-help { margin: 18px 0 0; text-align: center; }
@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } }

/* phones and tablets: the shop becomes a band on top, the form below */
@media (max-width: 899px) {
  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-brand { padding: max(20px, env(safe-area-inset-top)) 16px 22px; gap: 22px; }
  .auth-shop b { font-size: 14px; }
  .auth-logo { width: 40px; height: 40px; border-radius: 10px; }
  .auth-time { font-size: 52px; }
  .auth-date { margin-top: 8px; font-size: 14px; }
  .auth-foot { display: none; }
  .auth-main { place-items: start center; padding: 32px 16px 40px; }
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--text); color: #fff; display: grid; place-items: center; }
.brand .logo .icon { width: 18px; height: 18px; stroke-width: 2; }
.brand b { display: block; font-size: 14.5px; }
.brand span { font-size: 12px; color: var(--text-3); }
.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--text-3); padding: 18px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 400; transition: background .15s, color .15s;
}
.nav a .icon { width: 18px; height: 18px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.nav a.active .icon { color: var(--primary); }
.nav a .badge { margin-left: auto; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; border: 1px solid var(--border); margin-top: 12px; }
.user-card .meta { flex: 1; min-width: 0; }
.user-card .meta b { display: block; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .meta span { font-size: 12px; color: var(--text-3); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 500; font-size: 13px; background: var(--surface-2); color: var(--text-2);
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* one-line title / date / bell with fixed heights, so the bar is the same on every page */
.topbar { display: flex; align-items: center; gap: 12px; padding: 28px 36px 4px; min-height: 68px; }
.topbar h1 { font-size: 21px; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .date { margin-left: auto; color: var(--text-3); font-size: 13.5px; white-space: nowrap; flex: none; }
.topbar .bell-btn { flex: none; }
.view { padding: 18px 36px 48px; max-width: 1280px; width: 100%; }
/* pages with a wide table (schedule grid, payroll sheet) use the whole window, so a wide screen shows the full table */
.view:has(.team-grid-wrap, .pay-wrap) { max-width: none; }

.bottomnav { display: none; }
.drawer-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; z-index: 60; transform: translateX(-105%);
    transition: transform .22s cubic-bezier(.25, 1, .5, 1); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .drawer-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(34, 36, 43, .22); z-index: 55; }
  /* phone: title + bell on the first line, date on its own line below */
  .topbar { padding: calc(14px + env(safe-area-inset-top)) 16px 2px; flex-wrap: wrap; row-gap: 0; min-height: 0; }
  .topbar h1 { font-size: 19px; line-height: 36px; }
  .topbar .date { order: 3; width: 100%; margin: 0; font-size: 12.5px; line-height: 18px; }
  .view { padding: 12px 16px 104px; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a, .bottomnav button {
    display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-3);
    padding: 6px 0; background: none; border: 0; cursor: pointer; position: relative;
  }
  .bottomnav .active { color: var(--text); }
  .bottomnav .active .icon { color: var(--primary); }
  .bottomnav .clock-btn .bubble {
    width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
    margin-top: -16px; box-shadow: 0 4px 12px rgba(70, 81, 184, .25); border: 3px solid var(--surface);
  }
  .bottomnav .clock-btn.active .icon, .bottomnav .clock-btn .bubble .icon { color: #fff; }
  .bottomnav .dot { position: absolute; top: 4px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 50%; background: var(--rose-ink); }
}

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
a.card, a.user-card { color: inherit; }
a.card.stat { transition: border-color .15s; }
a.card.stat:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15.5px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.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)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .card { padding: 18px; }
}
.split { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 500; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-success { background: var(--surface); border-color: var(--border-strong); color: var(--mint-ink); }
.btn-success:hover { background: var(--mint); }
.btn-danger { background: var(--surface); border-color: var(--border-strong); color: var(--rose-ink); }
.btn-danger:hover { background: var(--rose); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13.5px; border-radius: 7px; }
.btn-lg { height: 48px; font-size: 15.5px; border-radius: 10px; padding: 0 20px; }
.btn-block { width: 100%; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, select.input, textarea.input {
  height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.input::placeholder { color: var(--text-3); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) { .form-row, .form-row.three { grid-template-columns: minmax(0, 1fr); } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; }
.checks input { position: absolute; opacity: 0; pointer-events: none; }
.checks span {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 13.5px; cursor: pointer; user-select: none;
}
.checks input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); }
.checks input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge.mint { background: var(--mint); color: var(--mint-ink); }
.badge.peach { background: var(--peach); color: var(--peach-ink); }
.badge.rose { background: var(--rose); color: var(--rose-ink); }
.badge.sky { background: var(--sky); color: var(--sky-ink); }
.badge.lemon { background: var(--lemon); color: var(--lemon-ink); }
.badge.lilac { background: var(--lilac); color: var(--lilac-ink); }
.badge.primary { background: var(--primary-soft); color: var(--primary-strong); }
.count-badge { min-width: 18px; height: 18px; border-radius: 9px; background: var(--rose-ink); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; padding: 0 5px; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.segmented button { border: 0; background: transparent; padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(34, 36, 43, .08); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-color: var(--text); }

.empty { text-align: center; color: var(--text-3); padding: 32px 12px; font-size: 14px; }
.empty .icon { width: 28px; height: 28px; margin-bottom: 8px; stroke-width: 1.4; opacity: .7; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 8px; font-size: 14px; align-items: flex-start; }
.alert .icon { margin-top: 1px; width: 18px; height: 18px; }
.alert.warn { background: var(--lemon); color: var(--lemon-ink); }
.alert.error { background: var(--rose); color: var(--rose-ink); }
.alert.info { background: var(--sky); color: var(--sky-ink); }
.alert.ok { background: var(--mint); color: var(--mint-ink); }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .right { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { font-weight: 500; display: block; }
.person span { font-size: 12.5px; color: var(--text-3); }

/* stats: number leads, the icon is a quiet tinted glyph */
.stat { display: flex; gap: 14px; align-items: center; }
.stat .ic { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.stat .ic .icon { width: 19px; height: 19px; }
.stat .v { font-size: 22px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--text-2); }
.tone-mint { background: var(--mint); color: var(--mint-ink); }
.tone-peach { background: var(--peach); color: var(--peach-ink); }
.tone-rose { background: var(--rose); color: var(--rose-ink); }
.tone-sky { background: var(--sky); color: var(--sky-ink); }
.tone-lilac { background: var(--lilac); color: var(--lilac-ink); }
.tone-primary { background: var(--primary-soft); color: var(--primary-strong); }

.hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
}
.hero h2 { font-size: 22px; }
.hero .shift-big { font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.hero .times { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.hero .times .chip { background: var(--surface-2); border-radius: 8px; padding: 8px 14px; font-size: 13px; color: var(--text-2); }
.hero .times .chip b { display: block; font-size: 16px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero .cta { margin-left: auto; }
@media (max-width: 600px) { .hero { padding: 20px; } .hero .cta { margin-left: 0; width: 100%; } .hero .cta .btn { width: 100%; } }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.date-tile { width: 46px; text-align: center; border-radius: 8px; background: var(--surface-2); padding: 5px 0; flex: none; }
.date-tile b { display: block; font-size: 17px; line-height: 1.1; font-weight: 600; }
.date-tile span { font-size: 11.5px; color: var(--text-3); }
.shift-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 500; color: #2c2f3a; white-space: nowrap; }

/* ---------- Clock ---------- */
.camera-box { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: #ececea; }
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-box video { transform: scaleX(-1); }
.camera-box .overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-2); padding: 20px; }
.camera-box .frame { position: absolute; inset: 14% 24%; border: 1.5px dashed rgba(255, 255, 255, .7); border-radius: 50% / 45%; pointer-events: none; }
.camera-box .live { position: absolute; top: 12px; left: 12px; background: rgba(0, 0, 0, .5); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 999px; display: flex; gap: 6px; align-items: center; }
.camera-box .live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #ff6b81; }
.clock-now { font-size: 40px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.loc-status { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 10px; }
.distance-bar { height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .06); overflow: hidden; margin-top: 8px; }
.distance-bar i { display: block; height: 100%; border-radius: 2px; }

/* ---------- Calendar ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav h3 { min-width: 150px; text-align: center; font-size: 15.5px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { text-align: center; font-size: 12.5px; color: var(--text-3); padding: 4px 0; font-weight: 500; }
.cal .day {
  min-height: 92px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); padding: 8px; display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; transition: border-color .15s; text-align: left;
}
.cal .day:hover { border-color: var(--border-strong); background: #fcfcfb; }
.cal .day.blank { background: transparent; border: 0; cursor: default; }
.cal .day .n { font-size: 13px; font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cal .day.today { border-color: var(--primary); }
.cal .day.today .n { color: var(--primary); font-weight: 600; }
.cal .day.weekend .n { color: var(--rose-ink); }
.cal .day .shift-chip { font-size: 12px; padding: 1px 6px; }
.cal .day .t { font-size: 11.5px; color: var(--text-3); }
@media (max-width: 700px) {
  .cal { gap: 3px; }
  .cal .day { min-height: 62px; padding: 5px; border-radius: 6px; }
  .cal .day .t { display: none; }
  .cal .day .shift-chip { font-size: 12px; padding: 1px 4px; justify-content: center; }
  .cal .day .shift-chip .full { display: none; }
}
@media (min-width: 701px) { .cal .day .shift-chip .short { display: none; } }
.legend { display: flex; gap: 8px; flex-wrap: wrap; }

/* team grid */
.team-grid-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 70vh; }
table.team-grid { min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.team-grid th, .team-grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; padding: 0; height: 38px; min-width: 38px; }
.team-grid thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 4px 2px; line-height: 1.2; }
.team-grid thead th b { color: var(--text-2); font-weight: 500; }
.team-grid thead th.weekend, .team-grid thead th.weekend b { color: var(--rose-ink); }
.team-grid thead th.today { background: var(--primary-soft); color: var(--primary); }
.team-grid thead th.today b { color: var(--primary); font-weight: 600; }
.team-grid .name-col { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; padding: 4px 12px; min-width: 170px; white-space: nowrap; }
.team-grid thead .name-col { z-index: 3; }
.team-grid .name-col b { font-weight: 500; display: block; font-size: 13.5px; }
.team-grid .name-col span { font-size: 11.5px; color: var(--text-3); }
.team-grid .pos-row td { background: var(--surface-2); text-align: left; padding: 6px 12px; font-size: 12px; font-weight: 500; color: var(--text-2); height: auto; }
.team-grid .pos-row td.name-col { background: var(--surface-2); }
.team-grid td.cell { font-weight: 500; color: #2c2f3a; }
.team-grid td.cell.off { color: var(--text-3); font-weight: 400; background: #fafaf8; }
.team-grid td.cell.leave { background: var(--peach); color: var(--peach-ink); font-size: 11px; }
.team-grid tr.me td.name-col { background: var(--primary-soft); }
.team-grid.editable td.cell { cursor: pointer; }
.team-grid.editable td.cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.team-grid .cov td { font-size: 11.5px; height: 28px; font-weight: 500; }
.team-grid .cov td.ok { color: var(--mint-ink); }
.team-grid .cov td.short { color: var(--rose-ink); background: var(--rose); font-weight: 600; }
.team-grid .cov td.over { color: var(--sky-ink); background: var(--sky); font-weight: 600; }
.team-grid .cov td.name-col { font-weight: 400; color: var(--text-2); }
.team-grid td.total { font-weight: 500; color: var(--text-2); min-width: 54px; }

.team-grid .sub-mark { color: var(--lilac-ink); font-weight: 600; margin-left: 1px; }
.team-grid .dbl-mark { display: inline-block; margin-left: 2px; padding: 0 3px; border-radius: 4px; font-size: 10px; font-weight: 600; line-height: 14px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }

/* ---------- Scheduling conditions ---------- */
.staff-table th, .staff-table td { padding: 6px 4px; text-align: center; }
.staff-table th:first-child, .staff-table td:first-child { text-align: left; padding-left: 0; }
.staff-table th.weekend { color: var(--rose-ink); }
.extra-box { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); }
.extra-opts { margin-top: 10px; padding-left: 26px; }
.staff-table th:nth-child(2), .staff-table td:nth-child(2) { border-right: 1px solid var(--border); padding-right: 10px; }
.input.mini { height: 34px; width: 50px; padding: 0 4px; text-align: center; border-radius: 7px; font-variant-numeric: tabular-nums; }
.input.mini::placeholder { color: var(--text-3); }
.input.mini.changed { background: var(--lemon); border-color: #e9d79a; color: var(--lemon-ink); font-weight: 600; }
.kind-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 600px) { .kind-grid { grid-template-columns: minmax(0, 1fr); } }
.kind-opt input { position: absolute; opacity: 0; pointer-events: none; }
.kind-opt span { display: block; height: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.kind-opt span small { display: block; color: var(--text-2); font-size: 12.5px; line-height: 1.4; margin-top: 2px; }
.kind-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.kind-opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(34, 36, 43, .28); z-index: 100;
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px);
  overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.25, 1, .5, 1);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 20px 22px 6px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h3 { font-size: 17px; flex: 1; }
.modal-body { padding: 10px 22px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
@media (max-width: 600px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { border-radius: 14px 14px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: pop .2s cubic-bezier(.25, 1, .5, 1); }
.toast .icon { width: 18px; height: 18px; }
.toast.ok { background: #24654a; }
.toast.error { background: #a8354f; }

.slip-card { cursor: pointer; transition: border-color .15s; }
.slip-card:hover { border-color: var(--border-strong); }

.photo-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; cursor: zoom-in; background: var(--surface-2); display: block; }

.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #efefec 0%, #f6f6f4 50%, #efefec 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Payroll sheet ---------- */
.pay-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.pay-sum { gap: 6px 18px; font-size: 13.5px; color: var(--text-2); margin-bottom: 12px; }
.pay-sum b { color: var(--text); font-weight: 600; }
.pay-wrap { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pay-sheet { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.pay-sheet th, .pay-sheet td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0 8px; height: 38px; white-space: nowrap; background: var(--surface); }
.pay-sheet tr > :last-child { border-right: 0; }
.pay-sheet thead th { font-weight: 500; font-size: 12.5px; color: var(--text-2); text-align: center; background: var(--surface-2); height: 34px; white-space: normal; line-height: 1.3; padding-top: 4px; padding-bottom: 4px; }
.pay-sheet thead th.grp { color: var(--mint-ink); }
.pay-sheet thead th.grp.ded, .pay-sheet thead th.ded { color: var(--rose-ink); }
.pay-sheet thead th.off { color: var(--text-3); font-style: italic; }
.pay-sheet tbody tr:hover td { background: #fafaf8; }
.pay-sheet .c-no { width: 44px; text-align: center; color: var(--text-3); }
.pay-sheet .c-name { position: sticky; left: 0; z-index: 1; min-width: 170px; text-align: left; box-shadow: 1px 0 0 var(--border); }
.pay-sheet td.c-name b { font-weight: 500; display: block; line-height: 1.25; }
.pay-sheet td.c-name span { font-size: 11.5px; color: var(--text-3); }
.pay-sheet td.c-name { padding-top: 4px; padding-bottom: 4px; }
.pay-sheet .c-net { text-align: right; font-weight: 600; min-width: 100px; }
.pay-sheet td.c-net.neg { color: var(--rose-ink); }
.pay-sheet .c-note { min-width: 160px; }
.pay-sheet td.pc { padding: 0; }
.pay-in { width: 100%; min-width: 66px; height: 37px; border: 0; background: transparent; font: inherit; color: inherit; text-align: right; padding: 0 8px; outline: none; border-radius: 0; }
.pay-in:focus { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.pay-in.saving { color: var(--text-3); }
.pay-in.err { box-shadow: inset 0 0 0 2px var(--rose-ink); background: var(--rose); }
td.c-note .pay-in { text-align: left; min-width: 160px; }
.pay-sheet tfoot td { font-weight: 600; text-align: right; background: var(--surface-2); border-bottom: 0; border-top: 1px solid var(--border-strong); }
.pay-sheet tfoot td.c-name { text-align: left; }
.pay-add { margin-top: 14px; gap: 8px; }
.pay-add .input { max-width: 300px; }
.pay-col .input { flex: 1; min-width: 0; height: 36px; }
.pay-col .pc-opt { flex: none; width: 118px; }
.pay-col.is-off .input { color: var(--text-3); }
.pay-col .check, .pay-col-add .check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-2); }
.pay-col-add { margin-top: 16px; gap: 8px; flex-wrap: wrap; }
.pay-col-add .input { flex: 1; min-width: 180px; }
.pay-col-add select.input { flex: 0 0 130px; min-width: 0; }
.icon.rot90 { transform: rotate(90deg); }
@media (max-width: 600px) {
  .pay-col { flex-wrap: wrap; gap: 8px; }
  .pay-col .input { flex-basis: 100%; }
  .pay-sheet .c-name { min-width: 130px; }
}

/* ---------- Payslip: minimal document, formal structure (ink on paper, hairlines, no fills) ---------- */
.slip { --ink: #1d1f26; --rule: #d6d6d0; color: var(--ink); font-size: 13.5px; font-variant-numeric: tabular-nums; background: #fff; }
.slip .en { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 400; margin-left: 4px; }
.slip-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding-bottom: 16px; border-bottom: 1.5px solid var(--ink); flex-wrap: wrap; }
.slip-co { display: flex; align-items: center; gap: 14px; min-width: 0; }
.slip-logo { width: 54px; height: 54px; object-fit: contain; flex: none; }
.slip-co-name { font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.slip-addr { font-size: 12px; color: var(--text-2); max-width: 360px; white-space: pre-line; margin-top: 2px; }
.slip-doc { text-align: right; line-height: 1.3; }
.slip-doc-t { font-size: 16px; font-weight: 600; }
.slip-doc-e { font-size: 10.5px; letter-spacing: .24em; color: var(--text-3); margin: 1px 0 6px; }
.slip-doc-p { font-size: 12.5px; color: var(--text-2); }
.slip-meta { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px 20px; margin: 16px 0 20px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.slip-meta dt { font-size: 11.5px; color: var(--text-3); }
.slip-meta dd { margin: 1px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.slip-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.slip-tbl { width: 100%; border-collapse: collapse; }
.slip-tbl th { text-align: left; font-weight: 600; font-size: 12.5px; padding: 0 0 7px; border-bottom: 1px solid var(--ink); }
.slip-tbl th.amt { font-weight: 400; font-size: 11px; color: var(--text-3); }
.slip-tbl td { padding: 7px 0; border-bottom: 1px solid #ecece8; }
.slip-tbl .amt { text-align: right; white-space: nowrap; }
.slip-tbl tfoot td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 600; padding-top: 8px; }
.slip-tbl tbody tr:last-child td { border-bottom: 0; }
.slip-net { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 22px; padding: 14px 0 12px; border-top: 1.5px solid var(--ink); border-bottom: 3px double var(--ink); }
.slip-net-l { font-weight: 600; font-size: 14.5px; }
.slip-words { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.slip-net-v { font-size: 24px; font-weight: 600; white-space: nowrap; letter-spacing: -.01em; }
.slip-net-v span { font-size: 13px; font-weight: 400; color: var(--text-2); margin-left: 2px; }
.slip-info { display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.slip-info div { display: flex; align-items: baseline; gap: 10px; }
.slip-info span { color: var(--text-2); font-size: 12.5px; }
.slip-info b { font-size: 16px; font-weight: 600; }
.slip-note { font-size: 12.5px; color: var(--text-2); margin: 12px 0 0; }
.slip-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 26px; flex-wrap: wrap; }
.slip-fine { font-size: 11.5px; color: var(--text-3); margin: 0; max-width: 360px; }
.sign-box { width: 230px; text-align: center; font-size: 13px; margin-left: auto; }
.sign-art { position: relative; height: 92px; }
.sign-stamp { position: absolute; right: 4px; top: 0; height: 92px; width: 92px; object-fit: contain; opacity: .85; }
.sign-sig { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); max-height: 60px; max-width: 190px; object-fit: contain; }
.sign-line { border-top: 1px solid var(--ink); margin: 0 14px 6px; }
.sign-title { font-size: 12px; color: var(--text-2); }
@media (max-width: 600px) {
  .slip-meta { grid-template-columns: 1fr 1fr; }
  .slip-meta > div:first-child { grid-column: span 2; }
  .slip-cols { grid-template-columns: 1fr; gap: 20px; }
  .slip-doc { text-align: left; }
  .slip-net-v { font-size: 20px; }
}

/* Excel import */
.imp-top { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.imp-top .field { flex: 1; min-width: 160px; margin-bottom: 4px; }
.imp-file { height: 40px; display: flex; align-items: center; gap: 8px; color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.imp-h { font-size: 13.5px; font-weight: 600; margin: 18px 0 8px; }
.imp-h .faint { font-weight: 400; margin-left: 6px; }
.imp-map { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.imp-map-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.2fr); align-items: center; gap: 8px; }
.imp-map-row .input { height: 36px; font-size: 13.5px; }
.imp-xl { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-rows td { padding: 6px 12px; }
.imp-rows .input { height: 34px; font-size: 13.5px; min-width: 190px; }
.imp-emp.missing { border-color: var(--peach-ink); background: var(--peach); }
.imp-off { color: var(--rose-ink); }
.imp-rows .icon { width: 14px; height: 14px; vertical-align: -2px; }
.imp-warn { display: flex; gap: 8px; align-items: center; padding: 14px; margin-top: 12px; border-radius: var(--radius-sm); background: var(--peach); color: var(--peach-ink); }
@media (max-width: 600px) { .imp-map { grid-template-columns: minmax(0, 1fr); } }
.pay-sheet thead th.info { color: var(--lilac-ink); white-space: nowrap; }
.pay-sheet thead th.c-net { white-space: nowrap; }

.brand .logo.has-img { background: transparent; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; }

.brand-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 4px 0 16px; }
@media (max-width: 700px) { .brand-slots { grid-template-columns: minmax(0, 1fr); } }
.brand-slot { display: flex; flex-direction: column; gap: 8px; }
.brand-slot .row { gap: 6px; }
.brand-prev { height: 110px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); display: grid; place-items: center; padding: 10px;
  background: repeating-conic-gradient(#f3f3f1 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.brand-prev img { max-width: 100%; max-height: 90px; object-fit: contain; }
/* ---------- Branches ---------- */
.branch-switch { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 6px 0 10px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface); color: var(--text-2); }
.branch-switch .icon { width: 16px; height: 16px; }
.branch-switch select { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--text); padding: 0 2px; max-width: 200px; cursor: pointer; outline: none; }
.branch-switch:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.branch-list { display: flex; flex-direction: column; }
.branch-item { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.branch-item:last-child { border-bottom: 0; }
.branch-logo { width: 44px; height: 44px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); overflow: hidden; }
.branch-logo.has-img { background: #fff; border: 1px solid var(--border); padding: 4px; }
.branch-logo img { width: 100%; height: 100%; object-fit: contain; }
.pay-co { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 2px; }
@media (max-width: 700px) {
  .branch-item { flex-wrap: wrap; }
  .branch-switch select { max-width: 120px; }
}

.sig-pad { width: 100%; aspect-ratio: 900 / 330; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; display: block; }

@page payroll { size: A4 landscape; margin: 10mm; }
/* ---------- News ---------- */
.bell-btn { position: relative; align-self: center; margin-right: -8px; color: var(--text-2); }
.bell-btn .count-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.news-list { display: flex; flex-direction: column; gap: 10px; }
.news-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.news-item.unread { border-color: var(--primary); background: var(--primary-soft); }
.news-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.news-head b { font-size: 15px; font-weight: 600; }
.news-body { font-size: 14px; color: var(--text); line-height: 1.6; overflow-wrap: anywhere; }
.news-row.is-off { opacity: .6; }
.month-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-days label { display: block; }
.month-days label span { display: block; width: 100%; text-align: center; padding-left: 0; padding-right: 0; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--border-strong); transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 600px) { .month-days { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; } }

/* ---------- Public holidays ---------- */
.team-grid thead th.holiday, .team-grid thead th.holiday b { color: var(--rose-ink); }
.team-grid thead th.holiday { box-shadow: inset 0 -2px 0 var(--rose-ink); }
.cal .day.holiday { background: var(--rose); }
.cal .day .hol-name { font-size: 11px; line-height: 1.25; color: var(--rose-ink); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 700px) { .cal .day .hol-name { display: none; } }
.hol-legend { margin-top: 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hol-legend .icon { width: 15px; height: 15px; color: var(--rose-ink); }
.hol-list { max-height: 320px; overflow: auto; }
.hol-add { margin-top: 12px; }
.hol-add .thai-date { width: 180px; }
.hol-add input[name=name] { flex: 1; min-width: 160px; }

/* ---------- Payroll: monthly / daily groups, pull from schedule ---------- */
.pay-sheet tr.pay-group td, .table tr.pay-group td { background: var(--surface-2); height: 32px; }
.pay-sheet tr.pay-group td.c-name span, .table tr.pay-group span { font-size: 12px; color: var(--text-2); margin-left: 8px; }
.pay-sheet tr.pay-group td.c-name { white-space: nowrap; }
.pay-sheet tr.pay-group td.c-name b { display: inline; }
.fs-table td, .fs-table th { padding: 7px 8px; white-space: nowrap; }
.modal.wide:has(.fs-table) { width: min(1180px, 96vw); max-width: none; }
.fs-table input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); }

/* ---------- Bell: notifications ---------- */
.notif-list { max-height: 60vh; overflow: auto; }
a.list-item.notif { color: inherit; text-decoration: none; padding-left: 10px; padding-right: 10px; border-radius: var(--radius-sm); }
a.list-item.notif:hover { background: var(--surface-2); }
a.list-item.notif.unread { background: var(--primary-soft); }
a.list-item.notif.unread b::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 7px; vertical-align: 2px; }

/* ---------- Settings: leave quota, backups ---------- */
.quota-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0 12px; }
.card-head h3 .icon { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.num.neg { color: var(--rose-ink); }

/* ---------- Reports / audit log ---------- */
.view:has(.report-table) { max-width: none; }
.report-table tfoot td { font-weight: 600; background: var(--surface-2); }
.audit-detail { max-width: 520px; word-break: break-word; color: var(--text-2); }

/* ---------- Touch devices (phones, tablets) ---------- */
/* employee pages are used on phones and tablets: finger-sized targets, no double-tap zoom, no zoom-in when a field is tapped */
@media (pointer: coarse), (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; }
  a, button, label, select, input, textarea { touch-action: manipulation; }
  /* iPhone Safari zooms into any field under 16px when it is tapped */
  .input, select.input, textarea.input, .input.mini { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .icon-btn, .bell-btn { width: 44px; height: 44px; }
  .segmented button { min-height: 40px; padding: 8px 16px; }
  .tabs button { min-height: 44px; }
  .nav a { min-height: 44px; }
  .bottomnav a, .bottomnav button { font-size: 12px; }
  .checks span { min-height: 40px; }
}
/* back-office pages (schedule planner, payroll, employees, settings) are made for a computer */
.grid-span { grid-column: 1 / -1; }
.pc-hint { display: none; }
@media (max-width: 1023px) { .pc-hint { display: flex; margin-bottom: 14px; } }

/* date fields shown as วว/ดด/ปปปป (the browser's own date input sits hidden behind, for the calendar) */
.thai-date { position: relative; display: block; min-width: 0; }
.thai-date > .input { padding-right: 44px; font-variant-numeric: tabular-nums; }
.thai-date > .thai-date-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.thai-date > .icon-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.thai-date > .icon-btn:hover { color: var(--text); }
.thai-date > .icon-btn .icon { width: 18px; height: 18px; }
.thai-date > .input[type=text]:invalid:not(:focus):not(:placeholder-shown) { border-color: var(--rose-ink); background: var(--rose); }
.thai-cal {
  position: fixed; z-index: 150; width: 296px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 10px 12px 8px; animation: pop .16s cubic-bezier(.25, 1, .5, 1);
}
.thai-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.thai-cal-head b { font-weight: 600; font-size: 15px; }
.thai-cal-dow, .thai-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.thai-cal-dow span { font-size: 12px; color: var(--text-3); padding: 4px 0; }
.thai-cal .we { color: var(--rose-ink); }
.thai-cal-grid button {
  height: 36px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.thai-cal-grid button.we { color: var(--rose-ink); }
.thai-cal-grid button:hover:not(:disabled) { background: var(--surface-2); }
.thai-cal-grid button.today { box-shadow: inset 0 0 0 1px var(--border-strong); font-weight: 600; }
.thai-cal-grid button.sel, .thai-cal-grid button.sel:hover { background: var(--primary); color: #fff; font-weight: 600; box-shadow: none; }
.thai-cal-grid button:disabled { color: var(--text-3); opacity: .45; cursor: default; }
.thai-cal-time { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.thai-cal-time select.input { width: auto; height: 34px; padding: 0 8px; }
.thai-cal-foot { display: flex; justify-content: space-between; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
@media (pointer: coarse) { .thai-cal-grid button { height: 40px; } }
/* two-step sign-in */
.otp-input { font-size: 22px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; height: 52px !important; }
.otp-input::placeholder { letter-spacing: .3em; color: var(--border-strong); }
.tf-steps { margin: 0 0 12px; padding-left: 20px; color: var(--text-2); }
.tf-steps li + li { margin-top: 4px; }
.tf-qr { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tf-qr img { border: 1px solid var(--border); border-radius: 8px; image-rendering: pixelated; }
.tf-qr .small { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tf-key { font-size: 15px; letter-spacing: .04em; word-break: break-all; user-select: all; }
.rec-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rec-codes code { text-align: center; padding: 8px; font-size: 15px; letter-spacing: .06em; user-select: all; }
.offsite { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.thai-time { width: 300px; }
.thai-time-label { margin: 2px 2px 4px; }
.thai-time-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin-bottom: 8px; }
.thai-time-grid button {
  height: 34px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.thai-time-grid button:hover:not(:disabled) { background: var(--surface-2); }
.thai-time-grid button.sel, .thai-time-grid button.sel:hover { background: var(--primary); color: #fff; font-weight: 600; }
.thai-time-grid button:disabled { color: var(--text-3); opacity: .45; cursor: default; }
.thai-time-show { font-size: 15px; align-self: center; }
@media (pointer: coarse) { .thai-time-grid button { height: 40px; } }

/* stock of supplies */
.stock-head .input[type=search] { flex: 1 1 220px; max-width: 360px; height: 38px; }
.stock-lowonly { gap: 6px; cursor: pointer; color: var(--text-2); }
.stock-cats { margin: -4px 0 8px; }
.stock-group + .stock-group { margin-top: 18px; }
.stock-group-head { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.stock-item { gap: 14px; }
.stock-item.inactive { opacity: .55; }
.stock-name { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.stock-name .small { flex-basis: 100%; }
.stock-name:hover b { text-decoration: underline; text-underline-offset: 3px; }
.stock-qty { text-align: right; min-width: 64px; line-height: 1.2; }
.stock-qty b { display: block; font-size: 18px; font-weight: 600; }
.stock-qty span { font-size: 12px; color: var(--text-3); }
.stock-qty.low b { color: var(--peach-ink); }
.stock-qty.out b { color: var(--rose-ink); }
.stock-qty.big { text-align: left; min-width: 0; }
.stock-qty.big b { font-size: 28px; }
.stock-acts { display: flex; gap: 6px; flex: none; }
/* sending stock between branches */
.tr-sub { font-size: 13.5px; font-weight: 600; color: var(--text-2); margin: 16px 0 4px; display: flex; align-items: center; gap: 6px; }
.transfer-row { align-items: flex-start; }
.transfer-no { display: flex; flex-direction: column; min-width: 96px; }
.tr-lines { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tr-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 56px 40px; gap: 8px; align-items: center; }
.recv-table .input { min-width: 90px; }
.recv-table select.input { min-width: 200px; }
a.alert { color: inherit; text-decoration: none; }
@media (max-width: 600px) {
  .tr-line { grid-template-columns: minmax(0, 1fr) 90px 40px; }
  .tr-line [data-unit] { display: none; }
  .transfer-row { flex-wrap: wrap; gap: 4px 12px; }
  .transfer-no { flex-direction: row; align-items: baseline; gap: 8px; width: 100%; min-width: 0; }
  .transfer-row .grow { flex-basis: calc(100% - 80px); }
}
.qty-step { display: flex; gap: 6px; }
.qty-step .input { flex: 1; text-align: center; font-size: 17px; }
.qty-step .btn { width: 44px; height: 44px; font-size: 20px; }
@media (max-width: 600px) {
  .stock-item { flex-wrap: wrap; gap: 8px 12px; }
  .stock-name { flex: 1 1 150px; }
  .stock-qty { min-width: 48px; }
  .stock-acts { margin-left: auto; }
  .stock-acts .btn { height: 38px; }
  .stock-head .input[type=search] { max-width: none; }
}

@media print {
  body.printing-payroll .sidebar, body.printing-payroll .topbar, body.printing-payroll .bottomnav, body.printing-payroll .drawer-backdrop,
  body.printing-payroll .pay-print .card-head, body.printing-payroll .no-print, body.printing-payroll #toasts { display: none !important; }
  body.printing-payroll .layout, body.printing-payroll .main, body.printing-payroll .view { display: block; margin: 0 !important; padding: 0 !important; }
  body.printing-payroll .pay-print { page: payroll; border: 0; padding: 0; }
  body.printing-payroll .pay-title { text-align: center; }
  body.printing-payroll .pay-wrap { overflow: visible; margin: 0; padding: 0; }
  body.printing-payroll .pay-sheet { font-size: 10.5px; width: 100%; }
  body.printing-payroll .pay-sheet .c-name { position: static; box-shadow: none; min-width: 0; }
  body.printing-payroll .pay-sheet th, body.printing-payroll .pay-sheet td { height: 26px; padding: 0 4px; }
  body.printing-payroll .pay-in { min-width: 46px; height: 26px; padding: 0 2px; }
  body.printing-payroll td.c-note .pay-in { min-width: 90px; }
  .slip img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { background: #fff; }
  body.printing-slip > #app { display: none; }
  body.printing-slip .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  body.printing-slip .modal { box-shadow: none; max-height: none; max-width: none; }
  body.printing-slip .modal-head, body.printing-slip .modal-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- report forms (ส่งรายงาน) ---------- */
.modal.xwide { max-width: 1040px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.form-card { display: flex; flex-direction: column; gap: 10px; margin: 0 !important; }
.form-card-head { display: flex; align-items: center; gap: 10px; }
.form-card-head h3 { font-size: 16px; }
.form-card-head .ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.form-card-head .ic .icon { width: 18px; height: 18px; }
.form-desc { margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.form-card-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.form-card-foot .badge .icon { width: 14px; height: 14px; }
button.list-item { background: none; border: 0; border-bottom: 1px solid var(--border); width: 100%; text-align: left; cursor: pointer; color: inherit; }
button.list-item:last-child { border-bottom: 0; }
button.list-item:hover .grow b { color: var(--primary); }
.form-entry .icon { width: 16px; height: 16px; color: var(--text-3); }

.rep-table th { white-space: normal; vertical-align: bottom; line-height: 1.35; }
.rep-table .rep-no { width: 32px; padding-right: 4px; text-align: right; }
.rep-table td.rep-fixed { font-weight: 500; white-space: nowrap; }
.rep-table td.rep-calc { color: var(--text-2); background: var(--surface-2); }
.rep-table tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; }
.rep-fill td { padding: 6px 8px; }
.rep-fill .input { height: 38px; min-width: 96px; }
.rep-fill .input.num { text-align: right; }
.rep-fill .rep-rm { width: 40px; padding: 0; }
.req { color: var(--rose-ink); }
.input.invalid { border-color: var(--rose-ink); background: var(--rose); }
.rep-meta { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 14px; }
.rep-meta > div { display: flex; flex-direction: column; font-size: 13.5px; }
.rep-meta .faint { font-size: 12px; }
.rep-print-head, .rep-sign { display: none; }

.form-tpl.inactive b { color: var(--text-3); }
.order-btns { display: flex; flex-direction: column; }
.order-btns .icon-btn { width: 28px; height: 22px; }
.order-btns .icon { width: 16px; height: 16px; }
.form-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

.form-editor section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.form-editor section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.te-h { font-size: 14.5px; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.te-h .small { font-weight: 400; }
.te-cols { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.te-col { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.te-col .input { height: 36px; }
.te-label { flex: 1 1 160px; width: auto; }
.te-type { flex: 0 1 220px; width: auto; }
.te-unit { flex: 0 0 84px; width: 84px; }
.te-formula { flex: 1 1 160px; width: auto; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.te-opts { display: flex; gap: 12px; font-size: 13px; color: var(--text-2); }
.te-opts label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }
.te-acts { display: flex; margin-left: auto; }
.te-acts .icon-btn { width: 32px; height: 32px; }
.te-acts [data-cmove] .icon { transform: rotate(-90deg); }
.te-ferr { flex-basis: 100%; color: var(--rose-ink); }
.te-ferr:empty { display: none; }
.te-letter { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; font-size: 13px; flex: none; }
.te-letter.sm { width: 20px; height: 20px; font-size: 11.5px; }
.te-rows td { padding: 6px 8px; }
.te-rows .input { height: 36px; min-width: 110px; }
.te-rows .te-blank { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.te-rows .icon-btn { width: 30px; height: 30px; }

/* phones: each row of a report becomes a small card with the column names on the left */
@media (max-width: 600px) {
  .rep-table thead { display: none; }
  .rep-table, .rep-table tbody, .rep-table tfoot, .rep-table tr, .rep-table td { display: block; width: 100%; }
  .rep-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; margin-bottom: 10px; position: relative; }
  .rep-table td, .rep-table tfoot td { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 10px; align-items: center; border: 0; padding: 5px 0; text-align: right; }
  .rep-table td::before { content: attr(data-label); text-align: left; color: var(--text-3); font-size: 13px; font-weight: 400; }
  .rep-table td.rep-fixed { display: block; text-align: left; font-size: 15px; padding: 4px 32px 4px 0; border-bottom: 1px solid var(--border); margin-bottom: 4px; white-space: normal; }
  .rep-table td.rep-fixed::before { display: none; }
  .rep-table td.rep-fixed + td.rep-fixed { font-size: 14px; font-weight: 400; color: var(--text-2); margin-top: -4px; }
  .rep-table td.rep-fixed:has(+ td.rep-fixed) { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
  .rep-table td.rep-calc { background: none; }
  .rep-table .rep-no { display: none; }
  .rep-table tfoot tr { background: var(--surface-2); border-color: transparent; }
  .rep-table tfoot td:not([data-tot]):not(.right) { display: none; }
  .rep-fill .input { min-width: 0; height: 42px; }
  .rep-fill .rep-rm { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; display: block; }
  .rep-fill .rep-rm::before { display: none; }
  .te-acts { margin-left: 0; }
  .te-type, .te-label { flex-basis: 100%; }
}

@media print {
  body.printing-slip .rep-print-head { display: block; text-align: center; margin-bottom: 14px; }
  body.printing-slip .rep-print-head h2 { font-size: 18px; }
  body.printing-slip .rep-sign { display: flex; justify-content: space-around; margin-top: 48px; text-align: center; font-size: 13px; }
  body.printing-slip .rep-sign span { color: var(--text-2); }
  body.printing-slip .rep-table thead { display: table-header-group; }
  body.printing-slip .rep-table { display: table; }
  body.printing-slip .rep-table tbody { display: table-row-group; }
  body.printing-slip .rep-table tfoot { display: table-footer-group; }
  body.printing-slip .rep-table tr { display: table-row; }
  body.printing-slip .rep-table td { display: table-cell; }
  body.printing-slip .rep-table td::before { display: none; }
  body.printing-slip .rep-table th, body.printing-slip .rep-table td { border: 1px solid #999; padding: 5px 8px; }
  body.printing-slip .table-wrap { overflow: visible; margin: 0; padding: 0; }
}

/* ---------- Correcting clock-in / clock-out times ---------- */
.att-reasons { gap: 6px; margin: 8px 0 6px; }
.att-chip { font: inherit; font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.att-chip:hover { border-color: var(--border-strong); color: var(--text); }
button.badge.att-edited { border: 0; font-family: inherit; cursor: pointer; }
button.badge.att-edited:hover { text-decoration: underline; }
.att-hist s { color: var(--text-3, var(--text-2)); }
