/* ============================================================
   ລະບົບຈັດການຕະຫລາດ — Stylesheet
   ໂທນສີຫຼັກ: #39B1D1 | ຟອນ: Noto Sans Lao Looped
   ============================================================ */

:root {
  --primary: #39B1D1;
  --primary-600: #2A93B0;
  --primary-700: #1F7490;
  --primary-800: #155A72;
  --primary-tint: #E9F6FB;
  --primary-tint-2: #D3ECF4;

  --accent: #F2A516;      /* ສີເຕືອນ/ເງິນ */
  --success: #2BB673;
  --danger: #E5484D;
  --warning: #F2A516;

  --ink: #11242C;
  --ink-2: #43585F;
  --muted: #7A8B92;
  --line: #E3EAED;
  --bg: #F4F7F9;
  --card: #FFFFFF;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(21, 90, 114, 0.06);
  --shadow-lg: 0 12px 32px rgba(21, 90, 114, 0.14);
  --sidebar-w: 244px;

  --font: 'Noto Sans Lao Looped', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ============================ Login ============================ */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(57,177,209,.35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(31,116,144,.30), transparent 55%),
    linear-gradient(160deg, #0E3C4C, #155A72 60%, #1F7490);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  padding: 38px 32px;
  box-shadow: var(--shadow-lg);
  animation: rise .5s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.login-logo {
  width: 70px; height: 70px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), var(--primary-700));
  color: #fff; font-size: 30px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(57,177,209,.4);
}
.login-card h1 { text-align: center; font-size: 22px; color: var(--primary-800); }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 26px; font-size: 14px; }

/* ============================ Form fields ============================ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field .with-icon { position: relative; }
.field .with-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.field .with-icon input { padding-left: 40px; }
input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600; background: var(--primary-tint); color: var(--primary-800);
  transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-tint-2); }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-700)); color: #fff; box-shadow: 0 4px 12px rgba(57,177,209,.32); }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(57,177,209,.42); }
.btn-danger { background: #FCEBEC; color: var(--danger); }
.btn-danger:hover { background: #F8DADC; }
.btn-success { background: linear-gradient(135deg, var(--success), #1F9E61); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============================ App layout ============================ */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(185deg, var(--primary-800), var(--primary-700) 55%, #134A5E);
  color: #DCF0F7;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform .26s ease;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, var(--primary), #5CC6E3);
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.brand b { color: #fff; font-size: 16px; display: block; line-height: 1.2; }
.brand span { font-size: 11.5px; color: #9FD4E5; }

.nav { flex: 1; padding: 12px 12px 20px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px; margin-bottom: 3px;
  color: #C5E5EF; font-size: 14.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a i { width: 20px; text-align: center; font-size: 16px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 3px 0 0 #fff; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .av {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.18); display: grid; place-items: center; color: #fff; font-weight: 700;
}
.user-chip .meta b { color: #fff; font-size: 13.5px; display: block; }
.user-chip .meta span { color: #9FD4E5; font-size: 11.5px; }

/* ============================ Main ============================ */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 18px; color: var(--ink); font-weight: 700; }
.hamburger { display: none; background: var(--primary-tint); color: var(--primary-800); border: none; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; }
.topbar .spacer { flex: 1; }
.topbar .pill { background: var(--primary-tint); color: var(--primary-800); padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; }

.content { padding: 24px; width: 100%; }

/* ============================ Cards / stats ============================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
}
.stat .ic { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; color: #fff; flex-shrink: 0; }
.stat .ic.c1 { background: linear-gradient(145deg, var(--primary), var(--primary-700)); }
.stat .ic.c2 { background: linear-gradient(145deg, #2BB673, #1F9E61); }
.stat .ic.c3 { background: linear-gradient(145deg, var(--accent), #D98A06); }
.stat .ic.c4 { background: linear-gradient(145deg, #7C6CF5, #5A48E0); }
.stat .num { font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.stat .lbl { font-size: 13px; color: var(--muted); }

.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }

/* ==== Responsive card-head ໃຫ້ປຸ່ມ wrap ໃນຈໍນ້ອຍ ==== */
.card-head {
  flex-wrap: wrap;
  gap: 8px;
}

.card-head h3 {
  flex-shrink: 0;
}

.card-head .btn {
  white-space: nowrap;
}

/* ຈໍນ້ອຍກວ່າ 720px */
@media (max-width: 720px) {
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }
  
  .card-head h3 {
    margin-bottom: 4px;
  }
  
  .card-head .spacer {
    display: none;
  }
  
  .card-head .btn {
    flex: 1;
    min-width: calc(50% - 4px);
    justify-content: center;
    font-size: 13px;
    padding: 8px 10px;
  }
  
  /* ຈັດປຸ່ມເປັນ grid 2 ຄໍລຳ */
  .card-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .card-head h3 {
    grid-column: 1 / -1;
  }
}

/* ຈໍນ້ອຍພິເສດ (ໂທລະສັບ) */
@media (max-width: 480px) {
  .card-head .btn {
    font-size: 12px;
    padding: 8px 6px;
  }
  
  .card-head .btn i {
    display: block;
    margin-bottom: 2px;
    margin-right: 0;
  }
}

.card-head h3 { font-size: 16px; color: var(--ink); font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }

/* ============================ Table ============================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 12px 16px; background: var(--primary-tint);
  color: var(--primary-800); font-weight: 700; font-size: 13px; white-space: nowrap;
}
tbody td { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
tbody tr:hover { background: #FAFCFD; }
.row-actions { display: flex; gap: 6px; }
.icon-btn { width: 32px; height: 32px; border: none; border-radius: 8px; background: var(--bg); color: var(--ink-2); display: grid; place-items: center; }
.icon-btn:hover { background: var(--primary-tint); color: var(--primary-700); }
.icon-btn.danger:hover { background: #FCEBEC; color: var(--danger); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: #E3F6EC; color: #1F9E61; }
.badge.gray { background: #EDF1F3; color: var(--muted); }
.badge.amber { background: #FDF1DC; color: #C77F06; }
.badge.red { background: #FCEBEC; color: var(--danger); }
.badge.blue { background: var(--primary-tint); color: var(--primary-700); }

/* ============================ Modal ============================ */
.modal-bg { position: fixed; inset: 0; background: rgba(15,45,57,.5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 80; padding: 18px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
.modal-head { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; color: var(--ink); }
.modal-head .x { margin-left: auto; background: var(--bg); border: none; width: 34px; height: 34px; border-radius: 9px; color: var(--ink-2); font-size: 16px; }
.modal-head .x:hover { background: #FCEBEC; color: var(--danger); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }


.form-grid .full { grid-column: 1 / -1; }

/* ============================ Permission editor ============================ */
.perm-group { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.perm-group-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--primary-tint); font-weight: 700; color: var(--primary-800); }
.perm-group-head i { font-size: 16px; }
.perm-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; }
.perm-chk {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1.5px solid var(--line);
  border-radius: 20px; font-size: 13.5px; cursor: pointer; user-select: none; transition: all .12s;
}
.perm-chk input { width: auto; }
.perm-chk:has(input:checked) { background: var(--primary-tint); border-color: var(--primary); color: var(--primary-800); font-weight: 600; }

/* ============================ Misc ============================ */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty i { font-size: 42px; color: var(--primary-tint-2); margin-bottom: 12px; }
.money { font-weight: 700; color: var(--primary-800); }
.muted { color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 4px solid var(--primary-tint); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--card); border-left: 4px solid var(--primary); border-radius: 10px;
  padding: 13px 18px; box-shadow: var(--shadow-lg); min-width: 240px; font-size: 14px;
  display: flex; align-items: center; gap: 10px; animation: slideIn .25s ease;
}
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast i { font-size: 18px; }
.toast.ok i { color: var(--success); }
.toast.err i { color: var(--danger); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* ============================ Responsive ============================ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: grid; place-items: center; }
  .overlay.show { display: block; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .topbar h2 { font-size: 16px; }
  .topbar .pill { display: none; }
  .stat { padding: 14px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ============================ Login error ============================ */
.login-err {
  background: #FCEBEC; color: var(--danger);
  border: 1px solid #F3C9CC; border-radius: 10px;
  padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   v2 ADDITIONS
   ============================================================ */

/* ----- Remember me ----- */
.remember { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; }
.remember input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* ----- Search bar / toolbars ----- */
.search-bar { position: relative; flex: 1; min-width: 180px; }
.search-bar i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; }
.search-bar input { padding-left: 38px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar label.inline { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.toolbar .field-inline { display: flex; align-items: center; gap: 8px; }
.toolbar .field-inline input, .toolbar .field-inline select { width: auto; }

/* ----- Totals summary strip ----- */
.totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.totals .t { flex: 1; min-width: 140px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); }
.totals .t .lbl { font-size: 12.5px; color: var(--muted); }
.totals .t .val { font-size: 18px; font-weight: 800; color: var(--primary-800); }
.totals .t.green .val { color: var(--success); }
.totals .t.amber .val { color: #C77F06; }

/* ----- Payment modal: net box + method ----- */
.net-box { background: var(--primary-tint); border: 1px solid var(--primary-tint-2); border-radius: var(--radius-sm); padding: 12px 16px; margin: 4px 0 4px; display: flex; justify-content: space-between; align-items: center; }
.net-box .lbl { color: var(--primary-800); font-weight: 600; font-size: 13.5px; }
.net-box .val { color: var(--primary-800); font-weight: 800; font-size: 20px; }
.section-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 2px; grid-column: 1/-1; }
.hint { font-size: 12.5px; color: var(--muted); grid-column: 1/-1; }
.hint.warn { color: var(--danger); }

/* ----- Detail rows (myspace / view) ----- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--ink); font-weight: 600; text-align: right; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile h4 { font-size: 14px; color: var(--primary-800); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.greet { font-size: 18px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }

/* ============================================================
   ໂທລະສັບ: ປ່ຽນຕາຕະລາງເປັນ card
   ============================================================ */
@media (max-width: 700px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody,
  .table-wrap th, .table-wrap td, .table-wrap tr { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    margin-bottom: 12px; padding: 6px 14px; box-shadow: var(--shadow);
  }
  .table-wrap tbody tr:hover { background: var(--card); }
  .table-wrap tbody td {
    border: none; padding: 9px 0; display: flex; justify-content: space-between;
    align-items: center; gap: 14px; text-align: right; border-bottom: 1px dashed var(--line);
  }
  .table-wrap tbody td:last-child { border-bottom: none; }
  .table-wrap tbody td::before {
    content: attr(data-label); font-weight: 700; color: var(--primary-800);
    text-align: left; flex: 0 0 40%; font-size: 12.5px;
  }
  .table-wrap .row-actions { justify-content: flex-end; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .field-inline { justify-content: space-between; }
  .totals .t { min-width: calc(50% - 5px); }
}

/* ============================================================
   ໃບຮັບເງິນ (ບິນນ້ອຍ ~80mm) — ເຊື່ອງໃນໜ້າຈໍ, ສະແດງເວລາພິມ
   ============================================================ */
#receipt-area { display: none; }
.rc { width: 76mm; font-family: var(--font); color: #000; font-size: 12px; line-height: 1.5; }
.rc-h { text-align: center; }
.rc-h h2 { font-size: 15px; margin-bottom: 2px; }
.rc-h div { font-size: 11px; }
.rc-title { text-align: center; font-weight: 700; border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 3px 0; margin: 6px 0; }
.rc-meta { font-size: 11px; margin-bottom: 6px; }
.rc-meta div { display: flex; justify-content: space-between; gap: 8px; }
.rc-meta span { color: #333; }
.rc-lines { border-top: 1px dashed #000; padding-top: 4px; margin-top: 4px; }
.rc-lines .r { display: flex; justify-content: space-between; }
.rc-total { display: flex; justify-content: space-between; font-weight: 700; border-top: 1px solid #000; margin-top: 4px; padding-top: 3px; }
.rc-total.due { color: #b00; }
.rc-foot { text-align: center; margin-top: 8px; font-size: 11px; }
.rc-foot .thanks { margin-top: 6px; font-style: italic; }

@media print {
  body.printing { background: #fff; }
  body.printing * { visibility: hidden; }
    body.printing #receipt-area, body.printing #receipt-area * { visibility: visible; }
      body.printing #receipt-area { display: block; position: absolute; left: 0; top: 0; padding: 3mm; }
  @page { size: 80mm auto; margin: 0; }
}

/* QR ໃນໃບຮັບເງິນ */
.rc-qr { text-align: center; margin-top: 8px; border-top: 1px dashed #000; padding-top: 6px; }
.rc-qr-title { font-weight: 700; font-size: 11px; margin-bottom: 4px; }
.rc-qr-item { margin-bottom: 6px; }
.rc-qr-item img { width: 42mm; height: 42mm; object-fit: contain; }
.rc-qr-item div { font-size: 10px; }

/* ການແກ້ໄຂ QR ໃນຟອມທະນາຄານ */
.qr-edit { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.qr-prev { width: 96px; height: 96px; border: 1px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--primary-tint); }
.qr-prev img { width: 100%; height: 100%; object-fit: contain; }
.qr-btns { display: flex; flex-direction: column; gap: 8px; }

/* ຊ່ອງປ້ອນຈຳນວນເງິນ (ມີຈຸດຄັ່ນຫຼັກພັນ) */
input.money-in { text-align: right; font-variant-numeric: tabular-nums; }

/* ສ່ວນ "ເພີ່ມເຕີມ" ແບບເຊື່ອງ/ສະແດງ (ສ່ວນຫຼຸດ/ຄ່າປັບ/ໝາຍເຫດ) */
details.more-toggle { grid-column: 1/-1; }
details.more-toggle summary {
  cursor: pointer; color: var(--primary-800); font-weight: 600; font-size: 13.5px;
  padding: 8px 0; list-style: none; user-select: none;
}
details.more-toggle summary::-webkit-details-marker { display: none; }
details.more-toggle .more-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line);
}
details.more-toggle .more-body .field.full { grid-column: 1/-1; }

/* ===== Custom Searchable Dropdown (search-select) ===== */
.ss-wrap { position: relative; width: 100%; }
.ss-input-row { display: flex; align-items: center; width: 100%; }
.ss-input-row input[type="text"] {
  flex: 1; cursor: pointer;
}
.ss-arrow {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--muted); font-size: 12px;
}
.ss-dropdown {
  position: absolute; z-index: 9999; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 240px; overflow: hidden;
  display: flex; flex-direction: column;
}
.ss-search {
  padding: 8px 10px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.ss-search input {
  width: 100%; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text);
}
.ss-list { overflow-y: auto; flex: 1; }
.ss-item {
  padding: 9px 14px; font-size: 14px; cursor: pointer; color: var(--text);
  border-bottom: 1px solid var(--line);
}
.ss-item:last-child { border-bottom: none; }
.ss-item:hover, .ss-item.active { background: var(--primary-50, #e8f7fb); color: var(--primary); }
.ss-item.ss-placeholder { color: var(--muted); font-style: italic; }
.ss-empty { padding: 12px 14px; color: var(--muted); font-size: 13px; text-align: center; }

/* ===== ພິມລາຍງານ (ລາຍວັນ/ລາຍເດືອນ/ລາຍປີ) - ດາວໂຫລດ PDF ຜ່ານ browser print ===== */
#report-area { display: none; }
.report-print h2 { text-align:center; margin: 0 0 6px; font-size: 20px; }
.report-print .meta { margin-bottom: 14px; font-size: 13px; color: #444; }
.report-print table { width: 100%; border-collapse: collapse; font-size: 12px; }
.report-print th, .report-print td { border: 1px solid #999; padding: 6px 9px; text-align: left; }
.report-print thead th { background: #eee; }
.report-print tfoot td { font-weight: 700; background: #f5f5f5; }
.report-print .report-motto { text-align: center; font-weight: 700; font-size: 14px; }
.report-print .report-motto-sub { text-align: center; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.report-print .report-sign { display: flex; justify-content: space-around; margin-top: 50px; font-weight: 700;  font-size: 14px; }

.report-print .sign-box { text-align: center; }
.report-print .sign-space { height: 60px; }
@media print {
  body.printing-report > *:not(#report-area) { visibility: hidden; }
    body.printing-report #report-area, body.printing-report #report-area * { visibility: visible; }
      body.printing-report #report-area { display: block; position: absolute; left: 0; top: 0; width: 100%; padding: 10mm; page: reportpage; }
      }
      @page reportpage { size: A4 landscape; margin: 10mm; }


      .report-print .report-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid #000;
  padding-bottom: 12px;
  margin-bottom: 20px;
  margin-top: 8px;
}

.report-print .report-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
}

.report-print .report-company {
  flex: 1;
}

.report-print .company-name {
  font-weight: 700;
  font-size: 16px;
  color: #1e3a8a;
  margin-bottom: 4px;
}

.report-print .company-info {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

/* ==== ລວມບິນ PDF (A4) ==== */
#batch-area { display: none; }

@media print {
  body.printing-batch > *:not(#batch-area) { display: none !important; }
  body.printing-batch #batch-area { display: block !important; }
}

@page { size: A4; margin: 12mm; }

.batch-print {
  font-family: 'Noto Sans Lao', sans-serif;
  color: #000;
}

.batch-cover {
  page-break-after: always;
  padding-bottom: 20px;
}

.batch-cover .report-motto {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.batch-cover .report-motto-sub {
  text-align: center;
  font-size: 12px;
  margin-bottom: 8px;
}

.batch-cover .report-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid #000;
}

.batch-cover .report-logo { width: 80px; height: 80px; object-fit: contain; }

.batch-cover .report-company { flex: 1; text-align: center; }

.batch-cover .company-name { font-weight: 700; font-size: 16px; color: #1e3a8a; }

.batch-cover .company-info { font-size: 12px; color: #555; }

.batch-cover h2 { margin: 16px 0 8px; font-size: 18px; }

.batch-cover .meta { font-size: 13px; color: #555; margin-bottom: 20px; }

/* ==== ລວມບິນ PDF (A4) — ໃຊ້ layout ຂອງ rc ໂດຍກົງ ==== */
#batch-area { display: none; }

@media print {
  body.printing-batch > *:not(#batch-area) { display: none !important; }
  body.printing-batch #batch-area { display: block !important; }
  body.printing-batch { background: #fff; }
  @page { size: A4; margin: 8mm; }
}

/* Grid A4: 3 ຄໍລຳ × 4 ແຖວ = 12 ບິນຕໍ່ໜ້າ */
.batch-a4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 3mm;
}

.batch-a4 .rc {
  page-break-inside: avoid;
  break-inside: avoid;
  width: 100%;
  max-width: none;
  border: 1px dashed #999;
  padding: 4px 6px;
  font-size: 8px;
  line-height: 1.25;
}

.batch-a4 .rc-h h2 { font-size: 10px; margin: 0; }
.batch-a4 .rc-h { text-align: center; font-size: 7px; padding-bottom: 2px; }
.batch-a4 .rc-h > div { line-height: 1.2; }

.batch-a4 .rc-title {
  text-align: center; font-weight: 700; font-size: 9px;
  margin: 2px 0; padding: 2px 0;
  border-top: 1px dashed #999; border-bottom: 1px dashed #999;
}

.batch-a4 .rc-meta { font-size: 7.5px; margin: 2px 0; }
.batch-a4 .rc-meta > div { display: flex; justify-content: space-between; padding: 0.5px 0; }
.batch-a4 .rc-meta span { color: #666; }

.batch-a4 .rc-lines { border-top: 1px dashed #999; padding-top: 2px; margin-top: 2px; }
.batch-a4 .rc-lines .r { display: flex; justify-content: space-between; padding: 0.5px 0; font-size: 7.5px; }

.batch-a4 .rc-total {
  display: flex; justify-content: space-between;
  border-top: 1px solid #000; padding-top: 2px; margin-top: 2px;
  font-weight: 700; font-size: 8.5px;
}
.batch-a4 .rc-total.due { color: #b91c1c; }

.batch-a4 .rc-foot {
  border-top: 1px dashed #999; margin-top: 2px; padding-top: 2px;
  text-align: center; font-size: 7px;
}
.batch-a4 .rc-foot .thanks { font-style: italic; color: #666; margin-top: 1px; }

/* ==== ລວມສະລິບການໂອນ PDF (A4) ==== */
.slips-a4 {
  color: #000;
}

.slips-cover {
  page-break-after: always;
  padding-bottom: 20px;
}

.slips-motto {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

.slips-motto-sub {
  text-align: center;
  font-size: 12px;
  margin-bottom: 8px;
}

.slips-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 2px solid #000;
}

.slips-logo { width: 90px; height: 90px; object-fit: contain; }

.slips-company { flex: 1; text-align: center; }

.slips-company-name { font-weight: 700; font-size: 16px; color: #1e3a8a; }

.slips-company-info { font-size: 12px; color: #555; }

/* Grid: 3 ຄໍລຳ × 3 ແຖວ = 9 ສະລິບຕໍ່ໜ້າ */
.slips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4mm;
}

.slip-item {
  page-break-inside: avoid;
  break-inside: avoid;
  border: 1px dashed #999;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slip-img-box {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.slip-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.slip-error {
  color: #b91c1c;
  font-size: 10px;
}

.slip-info {
  font-size: 9px;
  line-height: 1.4;
}

.slip-info-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 1px 0;
}

.slip-info-row span {
  color: #666;
  flex-shrink: 0;
}

.slip-info-row b {
  text-align: right;
  word-break: break-word;
  font-size: 9px;
}

@media print {
  @page { size: A4; margin: 8mm; }
}


/* ==== ບັງຄັບຕົວອັກສອນເຂັມດຳໃນໃບຮັບເງິນລວມ (batch-a4) ==== */
.batch-a4,
.batch-a4 *,
.batch-a4 .rc,
.batch-a4 .rc *,
.batch-a4 .rc-h,
.batch-a4 .rc-h *,
.batch-a4 .rc-title,
.batch-a4 .rc-meta,
.batch-a4 .rc-meta *,
.batch-a4 .rc-meta span,
.batch-a4 .rc-lines,
.batch-a4 .rc-lines *,
.batch-a4 .rc-total,
.batch-a4 .rc-total *,
.batch-a4 .rc-foot,
.batch-a4 .rc-foot *,
.batch-a4 .rc-foot .thanks {
  color: #000 !important;
  font-weight: 500 !important;
}

/* ຫົວຂໍ້ + ຍອດລວມ ໃຫ້ໜາຫຼາຍຂຶ້ນ */
.batch-a4 .rc-h h2,
.batch-a4 .rc-title,
.batch-a4 .rc-meta b,
.batch-a4 .rc-lines b,
.batch-a4 .rc-total,
.batch-a4 .rc-total b {
  color: #000 !important;
  font-weight: 700 !important;
}

/* ບັງຄັບຕອນພິມ (PDF) */
@media print {
  .batch-a4,
  .batch-a4 * {
    color: #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  .batch-a4 .rc {
    border-color: #000 !important;
  }
  
  .batch-a4 .rc-h,
  .batch-a4 .rc-title,
  .batch-a4 .rc-lines,
  .batch-a4 .rc-total,
  .batch-a4 .rc-foot {
    border-color: #000 !important;
  }
}