/* ============================================================
   CHẤM CA — Hệ thống quản lý chấm công & lương nhà hàng
   Design tokens: bảng màu "gạch bếp" (tile teal) + ánh đồng
   thau (brass), số liệu trình bày kiểu sổ sách bằng font mono.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root{
  /* ---- Màu nền tảng ---- */
  --ink:        #14201C;
  --tile:       #16423C;
  --tile-2:     #1E5C50;
  --tile-3:     #0F332E;
  --brass:      #C99A3C;
  --brass-dark: #A87B28;
  --brass-bg:   #FBF0DC;
  --paper:      #F3F5F1;
  --surface:    #FFFFFF;
  --border:     #E1E4DD;
  --border-2:   #CBD1C8;
  --muted:      #5C6B63;
  --muted-2:    #8A968F;

  /* ---- Màu trạng thái ---- */
  --success:     #2F7D5A;
  --success-bg:  #E4F2E9;
  --danger:      #B5493C;
  --danger-bg:   #FBEAE7;
  --warning:     #C07C1E;
  --warning-bg:  #FBF0DC;
  --info:        #2F6690;
  --info-bg:     #E7EFF5;

  /* ---- Bo góc ---- */
  --r-sm: 6px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* ---- Đổ bóng (chỉ dùng cho lớp nổi: modal, dropdown, camera) ---- */
  --shadow-elevated: 0 20px 48px -14px rgba(15, 32, 27, 0.38);
  --shadow-soft: 0 2px 10px -4px rgba(15, 32, 27, 0.12);

  /* ---- Font ---- */
  --font-ui: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --topbar-h: 68px;
}

*, *::before, *::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; }
body{
  margin: 0;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4{ margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p{ margin: 0; }
a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; cursor: pointer; }
input, select, textarea{ font-family: inherit; font-size: inherit; color: inherit; }
img{ max-width: 100%; display: block; }
.mono{ font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

::selection{ background: var(--brass-bg); color: var(--tile-3); }

/* Focus rõ ràng cho bàn phím */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible{
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================
   LỚP DÙNG CHUNG: nút, thẻ, input, badge, bảng, modal, toast
   ============================================================ */

/* --- Buttons --- */
.btn{
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn:active{ transform: translateY(1px); }
.btn svg{ width: 17px; height: 17px; flex-shrink: 0; }
.btn-primary{ background: var(--brass); color: var(--tile-3); }
.btn-primary:hover{ background: var(--brass-dark); }
.btn-dark{ background: var(--tile); color: #fff; }
.btn-dark:hover{ background: var(--tile-3); }
.btn-outline{ background: transparent; border-color: var(--border-2); color: var(--ink); }
.btn-outline:hover{ background: var(--surface); border-color: var(--muted-2); }
.btn-ghost{ background: transparent; color: var(--muted); }
.btn-ghost:hover{ background: rgba(20,32,28,.05); color: var(--ink); }
.btn-danger{ background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover{ background: #f5d9d4; }
.btn-sm{ padding: 7px 13px; font-size: 13.5px; }
.btn-block{ width: 100%; }
.btn:disabled{ opacity: .55; cursor: not-allowed; }
.btn-icon{ padding: 9px; border-radius: var(--r-sm); }

/* --- Card --- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px;
}
.card-title{ font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-sub{ color: var(--muted); font-size: 13.5px; }

/* --- Form --- */
.field{ margin-bottom: 16px; }
.field label{
  display: block; font-size: 13.5px; font-weight: 600; color: var(--ink);
  margin-bottom: 6px;
}
.field .hint{ font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.input, .select, textarea.input{
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink);
  font-size: 14.5px; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea.input:focus{
  border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-bg); outline: none;
}
.input::placeholder{ color: var(--muted-2); }
.input-group{ position: relative; }
.input-group .input{ padding-right: 42px; }
.input-group .icon-btn{
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); padding: 6px; border-radius: var(--r-sm);
}
.input-group .icon-btn:hover{ background: rgba(20,32,28,.06); color: var(--ink); }
.row-2{ display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3{ display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
select.input{ appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%235C6B63' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

/* --- Badges / chips --- */
.chip{
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600;
  border-left: 3px solid transparent;
}
.chip::before{ content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-success{ background: var(--success-bg); color: var(--success); }
.chip-danger{ background: var(--danger-bg); color: var(--danger); }
.chip-warning{ background: var(--warning-bg); color: var(--warning); }
.chip-info{ background: var(--info-bg); color: var(--info); }
.chip-muted{ background: var(--paper); color: var(--muted); border: 1px solid var(--border); }

/* --- Table (kiểu sổ sách) --- */
.table-wrap{ overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
table.ledger{ width: 100%; border-collapse: collapse; min-width: 720px; background: var(--surface); }
table.ledger thead th{
  text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted);
  padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--paper);
  white-space: nowrap;
}
table.ledger tbody td{
  padding: 15px 20px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle;
}
table.ledger tbody tr:last-child td{ border-bottom: none; }
table.ledger tbody tr:hover{ background: #FAFBF9; }
table.ledger td.num, table.ledger th.num{ text-align: right; font-family: var(--font-mono); }
.avatar{
  width: 34px; height: 34px; border-radius: 50%; background: var(--tile);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.person-cell{ display: flex; align-items: center; gap: 11px; }
.person-cell .name{ font-weight: 600; }
.person-cell .sub{ font-size: 12.5px; color: var(--muted); }
.cell-sub{ font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* --- Modal --- */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(15, 32, 27, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open{ display: flex; }
.modal{
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-elevated);
  width: 100%; max-width: 680px; max-height: 88vh; display: flex; flex-direction: column;
  max-height: min(88dvh, calc(100dvh - 40px)); min-height: 0; overflow: hidden;
  animation: modal-in .16s ease;
}
.modal > form{ display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.modal.modal-lg{ max-width: 920px; }
@keyframes modal-in{ from{ opacity: 0; transform: translateY(8px) scale(.98); } to{ opacity: 1; transform: none; } }
.modal-head{ display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-head h3{ font-size: 17px; }
.modal-body{ padding: 22px 24px; overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-foot{ padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; background: var(--surface); }
.adjustment-net{ display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px 0; font-weight: 700; font-size: 16px; }
.modal-close{ background: none; border: none; color: var(--muted); padding: 6px; border-radius: var(--r-sm); }
.modal-close:hover{ background: var(--paper); color: var(--ink); }

/* --- Steps (form nhiều bước) --- */
.steps{ display: flex; gap: 6px; margin-bottom: 22px; }
.step-dot{ flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--border); }
.step-dot.active{ background: var(--brass); }
.step-dot.done{ background: var(--tile-2); }
.step-label{ display:flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* --- Toast --- */
#toast-stack{ position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast{
  background: var(--tile-3); color: #fff; padding: 13px 18px; border-radius: var(--r-sm);
  font-size: 13.5px; box-shadow: var(--shadow-elevated); display: flex; align-items: center; gap: 10px;
  animation: toast-in .18s ease;
}
.toast.success{ background: var(--success); }
.toast.error{ background: var(--danger); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(8px);} to{opacity:1; transform:none;} }

/* --- Tabs (segmented) --- */
.tabs{ display: inline-flex; background: var(--paper); border: 1px solid var(--border); padding: 4px; border-radius: var(--r-pill); gap: 2px; }
.tab-btn{ border: none; background: transparent; padding: 9px 18px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 600; color: var(--muted); }
.tab-btn.active{ background: var(--tile); color: #fff; }

/* ============================================================
   TOPBAR — thanh điều hướng ngang (khu quản lý)
   ============================================================ */
.topbar{
  height: var(--topbar-h); background: var(--tile); color: #fff;
  display: flex; align-items: center; gap: 28px; padding: 0 26px;
  position: sticky; top: 0; z-index: 50; border-bottom: 3px solid var(--brass);
}
.brand{ display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand .mark{ width: 34px; height: 34px; flex-shrink: 0; }
.brand .sub{ font-size: 11px; font-weight: 500; color: rgba(255,255,255,.6); display: block; letter-spacing: 0; }
.nav-main{ display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-link{
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 600; color: rgba(255,255,255,.72); transition: background .15s ease, color .15s ease;
}
.nav-link svg{ width: 18px; height: 18px; }
.nav-link:hover{ background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active{ background: var(--tile-2); color: #fff; }
.nav-link.active::after{ content:''; }
.topbar-right{ display: flex; align-items: center; gap: 14px; }
.user-chip{ display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; border-radius: var(--r-pill); position: relative; }
.user-chip:hover{ background: rgba(255,255,255,.08); }
.user-chip .avatar{ background: var(--brass); color: var(--tile-3); }
.user-chip .who{ text-align: left; }
.user-chip .who .name{ font-size: 13px; font-weight: 700; display: block; }
.user-chip .who .role{ font-size: 11px; color: rgba(255,255,255,.6); }
.dropdown{
  position: absolute; top: calc(100% + 10px); right: 0; background: var(--surface); color: var(--ink);
  border-radius: var(--r-md); box-shadow: var(--shadow-elevated); min-width: 190px; padding: 6px;
  display: none; border: 1px solid var(--border);
}
.dropdown.open{ display: block; }
.dropdown a, .dropdown button{
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--ink);
}
.dropdown a:hover, .dropdown button:hover{ background: var(--paper); }
.dropdown .danger{ color: var(--danger); }
.dropdown hr{ border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page{ max-width: 1440px; margin: 0 auto; padding: 30px 32px 60px; }
.page-head{ display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1{ font-size: 23px; }
.page-head .desc{ color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.toolbar{ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .input{ width: 230px; }
.section-title{ font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* --- KPI ticket cards (dashboard) --- */
.kpi-row{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi-ticket{
  background: var(--surface); border: 1px solid var(--border); border-top: 3px dashed var(--border-2);
  border-radius: 0 0 var(--r-md) var(--r-md); padding: 18px 18px 16px;
}
.kpi-ticket .label{ font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-ticket .value{ font-family: var(--font-mono); font-size: 27px; font-weight: 700; margin-top: 6px; color: var(--ink); }
.kpi-ticket .delta{ font-size: 12px; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-ticket .delta.up{ color: var(--success); }
.kpi-ticket .delta.down{ color: var(--danger); }

.grid-2{ display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }

/* ============================================================
   AUTH — màn đăng nhập / đăng ký (khu quản lý)
   ============================================================ */
.auth-shell{ min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side{
  background: var(--tile); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(201,154,60,.16), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(201,154,60,.12), transparent 45%);
  position: relative; overflow: hidden;
}
.auth-side .ticket-pattern{ position: absolute; inset: 0; opacity: .5; pointer-events: none; }
.auth-side .quote{ font-size: 22px; line-height: 1.45; font-weight: 600; max-width: 420px; position: relative; z-index: 1; }
.auth-side .quote span{ color: var(--brass); }
.auth-side .stat-line{ display: flex; gap: 28px; position: relative; z-index: 1; }
.auth-side .stat-line .n{ font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.auth-side .stat-line .l{ font-size: 12px; color: rgba(255,255,255,.65); }
.auth-main{ display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--paper); }
.auth-box{ width: 100%; max-width: 380px; }
.auth-box h1{ font-size: 24px; margin-bottom: 6px; }
.auth-box .lead{ color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.auth-foot{ margin-top: 22px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-foot a{ color: var(--brass-dark); font-weight: 700; }
.auth-badge{ display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; margin-bottom: 40px; position: relative; z-index: 1; }

@media (max-width: 900px){
  .auth-shell{ grid-template-columns: 1fr; }
  .auth-side{ display: none; }
}

/* --- Employee-only auth (không có tách đôi, đơn giản hơn) --- */
.emp-auth-shell{ min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--tile); padding: 24px;
  background-image: radial-gradient(circle at 50% 0%, rgba(201,154,60,.18), transparent 55%); }
.emp-auth-box{ width: 100%; max-width: 360px; background: var(--surface); border-radius: var(--r-lg); padding: 34px 30px; box-shadow: var(--shadow-elevated); }
.emp-auth-box .auth-badge{ color: var(--ink); margin-bottom: 22px; }
.emp-auth-box .auth-badge .mark path{ fill: var(--tile); }

/* ============================================================
   EMPLOYEE SHELL (mobile-first)
   ============================================================ */
.emp-shell{ min-height: 100vh; background: var(--paper); }
.emp-topbar{
  background: var(--tile); color: #fff; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 3px solid var(--brass); position: sticky; top: 0; z-index: 40;
}
.emp-topbar .who{ font-size: 13px; }
.emp-topbar .who .name{ font-weight: 700; display:block; font-size: 14px;}
.emp-topbar .who .role{ color: rgba(255,255,255,.6); font-size: 11.5px; }
.emp-content{ max-width: 480px; margin: 0 auto; padding: 22px 18px 40px; }
.emp-tabs{ display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 4px; margin-bottom: 22px; }
.emp-tab{ flex: 1; text-align: center; padding: 11px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 700; color: var(--muted); }
.emp-tab.active{ background: var(--tile); color: #fff; }

/* --- Camera viewfinder --- */
.viewfinder{
  position: relative; width: 100%; aspect-ratio: 1 / 1; max-width: 340px; margin: 0 auto;
  background: var(--tile-3); border-radius: var(--r-lg); overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.viewfinder video{ width: 100%; height: 100%; object-fit: cover; display: none; transform: scaleX(-1); }
.viewfinder.live video{ display: block; }
.viewfinder .vf-idle{ color: rgba(255,255,255,.55); text-align: center; padding: 20px; }
.viewfinder.live .vf-idle{ display: none; }
.viewfinder .corner{ position: absolute; width: 26px; height: 26px; border: 3px solid var(--brass); opacity: .9; }
.viewfinder .corner.tl{ top: 14px; left: 14px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.viewfinder .corner.tr{ top: 14px; right: 14px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.viewfinder .corner.bl{ bottom: 14px; left: 14px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.viewfinder .corner.br{ bottom: 14px; right: 14px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.viewfinder .scan-line{
  position: absolute; left: 6%; right: 6%; height: 2px; background: var(--brass); box-shadow: 0 0 10px 1px var(--brass);
  top: 10%; display: none;
}
.viewfinder.scanning .scan-line{ display: block; animation: scan 1.3s ease-in-out infinite; }
@keyframes scan{ 0%{ top: 10%; } 50%{ top: 88%; } 100%{ top: 10%; } }
.status-banner{ display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); margin-top: 18px; font-size: 13.5px; }
.status-banner.success{ background: var(--success-bg); color: var(--success); }
.status-banner.error{ background: var(--danger-bg); color: var(--danger); }
.status-banner.info{ background: var(--info-bg); color: var(--info); }
.status-banner svg{ width: 22px; height: 22px; flex-shrink: 0; }
.status-banner strong{ display: block; }

/* --- Payslip card --- */
.payslip{ background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.payslip-head{ background: var(--tile); color: #fff; padding: 20px 22px; }
.payslip-head .period{ font-size: 12.5px; color: rgba(255,255,255,.65); }
.payslip-head .amount{ font-family: var(--font-mono); font-size: 30px; font-weight: 700; margin-top: 4px; }
.payslip-rows{ padding: 6px 22px; }
.payslip-row{ display: flex; justify-content: space-between; padding: 13px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.payslip-row:last-child{ border-bottom: none; }
.payslip-row .amt{ font-family: var(--font-mono); font-weight: 600; }
.payslip-row .amt.plus{ color: var(--success); }
.payslip-row .amt.minus{ color: var(--danger); }

/* --- Phiếu lương dạng BILL IN NHIỆT 80mm (dùng máy in POS của quầy) --- */
.receipt-preview-wrap{ background: #EAEBE6; padding: 28px 14px; display: flex; justify-content: center; }
.pos-receipt{
  width: 72mm; background: #fff; color: #000; font-family: var(--font-mono);
  font-size: 11.5px; line-height: 1.55; padding: 6mm 4.5mm 10mm; box-shadow: var(--shadow-soft);
}
.pos-receipt .r-title{ text-align: center; font-weight: 800; font-size: 14.5px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.pos-receipt .r-emp{ display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pos-receipt .r-emp-info div{ margin-bottom: 2px; }
.pos-receipt .r-name{ font-weight: 700; font-size: 12.5px; }
.pos-receipt .r-photo{ width: 44px; height: 44px; object-fit: cover; border: 1.5px solid #000; flex-shrink: 0; }
.pos-receipt .r-divider{ border-top: 1px dashed #000; margin: 9px 0; }
.pos-receipt .r-divider.double{ border-top: 2px solid #000; }
.pos-receipt .r-base{ text-align: center; padding: 2px 0 4px; }
.pos-receipt .r-label{ font-size: 10.5px; letter-spacing: .4px; }
.pos-receipt .r-value{ font-size: 19px; font-weight: 800; margin-top: 3px; }
.pos-receipt .r-sub{ font-size: 10px; color: #333; margin-top: 2px; }
.pos-receipt .r-section-title{ font-weight: 700; font-size: 10.5px; letter-spacing: .4px; margin-bottom: 3px; }
.pos-receipt .r-row{ display: flex; justify-content: space-between; padding: 2px 0; }
.pos-receipt .r-note{ font-size: 10.5px; margin: 8px 0; }
.pos-receipt .r-net{ display: flex; justify-content: space-between; font-weight: 800; font-size: 13.5px; padding-top: 4px; }
.pos-receipt .r-meta{ font-size: 10px; margin-top: 10px; line-height: 1.7; }
.pos-receipt .r-quote{ text-align: center; font-style: italic; font-size: 10.5px; margin-top: 14px; }
#bulk-print-area{ display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px){
  .kpi-row{ grid-template-columns: repeat(2, 1fr); }
  .grid-2{ grid-template-columns: 1fr; }
}
@media (max-width: 860px){
  .nav-main .label{ display: none; }
  .row-2, .row-3{ grid-template-columns: 1fr; }
  .page-head{ flex-direction: column; align-items: stretch; }
}
@media (max-width: 640px){
  .topbar{ padding: 0 14px; gap: 10px; }
  .brand .sub{ display: none; }
  .brand span > span.sub{ display: none; }
  .page{ padding: 18px 14px 50px; }
  .kpi-row{ grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-ticket .value{ font-size: 22px; }

  /* Toolbar: search/select/nút xếp chồng full-width thay vì chen chúc 1 hàng */
  .toolbar{ width: 100%; flex-direction: column; align-items: stretch; }
  .toolbar .input, .toolbar select, .toolbar .btn{ width: 100%; }

  /* Modal: chiếm gần hết màn hình, không còn khoảng trắng lãng phí 2 bên */
  .modal-backdrop{ padding: 10px; align-items: flex-end; }
  .modal, .modal.modal-lg{ max-width: 100%; max-height: 92vh; max-height: calc(100dvh - 20px); border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-head, .modal-body, .modal-foot{ padding-left: 18px; padding-right: 18px; }

  /* Nút trong modal-foot xếp dọc, dễ bấm bằng ngón tay hơn khi có 2-3 nút */
  .modal-foot{ flex-wrap: wrap; }
  .modal-foot > *{ flex: 1 1 auto; }

  /* Bảng: cho phép cuộn ngang mượt, không co chữ lại gây khó đọc */
  table.ledger{ min-width: 640px; }
  table.ledger thead th, table.ledger tbody td{ padding: 12px 14px; }

  /* Tabs khu nhân viên: 3 tab vẫn gọn trên màn hình nhỏ */
  .emp-tab{ padding: 10px 4px; font-size: 12.5px; }
  .emp-content{ padding: 16px 12px 32px; }

  /* Khung camera co theo chiều rộng màn hình thay vì cố định 340px */
  .viewfinder{ max-width: min(340px, 86vw); }

  /* Danh sách chọn nhân viên (tab Ứng lương & điều chỉnh) đỡ chật */
  #employee-picker .emp-pick-item{ padding: 12px 10px; }
}
@media (max-width: 420px){
  .kpi-row{ grid-template-columns: 1fr; }
  .user-chip .who{ display: none; }
}

/* ============================================================
   PRINT — In phiếu lương ra máy in nhiệt POS khổ 80mm
   Kỹ thuật: ẩn toàn bộ trang, chỉ hiện phần tử mang class
   .print-target (và các con của nó) khi in.
   ============================================================ */
@media print{
  @page{ size: auto; margin: 0; }
  html, body{ background: #fff; margin: 0; padding: 0; width: 80mm; }
  body > :not(.page){ display: none !important; }
  .page{ width: 80mm; max-width: none; margin: 0; padding: 0; }
  .page > :not(#modal-payslip):not(#bulk-print-area){ display: none !important; }
  .modal-backdrop, .modal, .modal > form, .modal-body{
    position: static; max-height: none; height: auto; overflow: visible;
    transform: none; animation: none; padding: 0; margin: 0; border: 0;
    box-shadow: none; backdrop-filter: none; width: 80mm; max-width: 80mm;
  }
  #modal-payslip.open, #modal-payslip .modal, #modal-payslip .modal-body{ display: block; }
  body.printing-bulk #modal-payslip{ display: none !important; }
  .receipt-preview-wrap, #print-receipt{ padding: 0; }
  .modal-head, .modal-foot{ display: none; }
  body.printing-bulk #print-receipt{ display: none !important; }
  body *{ visibility: hidden !important; }
  .print-target, .print-target *{ visibility: visible !important; }
  .print-target{
    position: static; width: 80mm; background: #fff;
  }
  .pos-receipt{ width: 80mm; box-shadow: none; padding: 5mm 4.5mm 10mm; page-break-after: always; break-after: page; }
  .pos-receipt:last-child{ page-break-after: auto; break-after: auto; }
}

.pos-receipt .r-row{gap:8px;align-items:flex-start}.pos-receipt .r-row>span:first-child{min-width:0;overflow-wrap:anywhere}.pos-receipt .r-row>span:last-child{white-space:nowrap;flex-shrink:0}