/* ===== PayHub — light SaaS theme (top navbar) ===== */
:root {
  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-soft: #eff6ff;
  --blue-soft-2: #dbeafe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --teal: #0d9488;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e8edf3;
  --line-2: #eef2f7;
  --bg: #f6f8fb;
  --white: #ffffff;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Phetsarath OT", "Noto Sans Lao", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
:lang(en), .en, .tab span, .t-en { font-family: "Phetsarath OT", "Noto Sans Lao", sans-serif; }

/* ===== App bar ===== */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(16,24,40,.02);
}
.appbar-inner {
  max-width: none; width: 100%;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--line); /* ເສັ້ນຄັ່ນລະຫວ່າງ header ກັບ menu */
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), #3b82f6);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fff;
  box-shadow: 0 6px 14px rgba(37,99,235,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 20px; letter-spacing: .2px; }
.brand-text span { font-size: 12px; color: var(--muted); font-family: "Phetsarath OT", "Noto Sans Lao", sans-serif; }

.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.app-date {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-2); font-weight: 600;
  background: var(--bg); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 9px; white-space: nowrap;
}
.app-date svg { color: var(--blue); }
.icon-btn { display: grid; place-items: center; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--white); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  background: var(--red); border-radius: 50%; border: 1.5px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--white);
}
.user-ava {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-soft-2); color: var(--blue-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 13px; }
.user-meta .online { font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 4px; font-family: "Phetsarath OT", "Noto Sans Lao", sans-serif; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }

/* ===== Tabs ===== */
.tabs {
  max-width: none; width: 100%;
  display: flex; gap: 2px; padding: 0 24px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding: 12px 16px; text-decoration: none; white-space: nowrap;
  color: var(--muted); border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s; border-radius: 8px 8px 0 0;
}
.tab b { font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.tab svg { color: var(--muted); }
.tab:hover { background: var(--bg); }
.tab.active { border-bottom-color: var(--blue); }
.tab.active b { color: var(--blue); }
.tab.active svg { color: var(--blue); }

/* ===== Content ===== */
.content { max-width: none; margin: 0; padding: 24px 32px 60px; width: 100%; }

/* page header */
.page-head {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head-text { display: flex; flex-direction: column; }
.page-title { margin: 0; font-size: 23px; font-weight: 700; }
.page-title .t-en { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 8px; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { margin-left: auto; display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.page-actions .filter-item { min-width: 0; }
.page-actions .sel { width: 190px; }
.page-actions .search-box { width: 300px; }
.page-actions .search-box input { width: 100%; }
.page-actions .btn { align-self: flex-end; }
@media (max-width: 900px) {
  .page-actions { width: 100%; margin-left: 0; }
  .page-actions .sel, .page-actions .search-box { width: auto; flex: 1 1 160px; }
}

/* ===== Cards ===== */
.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }

/* stat grid */
.stat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 22px;
}
/* store sub-tabs (Store Dashboard) */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.subtab {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 9px 14px; border: none; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
}
.subtab:hover { background: var(--bg); color: var(--ink-2); }
.subtab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* KPI grid — 4 per row desktop, 2 tablet, 1 mobile */
.kpi-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: 1fr; } }
.stat {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
a.stat-link { text-decoration: none; color: inherit; display: block; transition: border-color .15s, box-shadow .15s, transform .15s; cursor: pointer; }
a.stat-link:hover { border-color: var(--blue); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat .stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat .stat-ic { color: var(--blue); flex-shrink: 0; }
.stat .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .stat-value { font-size: 24px; font-weight: 700; margin-top: 8px; line-height: 1.2; color: var(--ink); }
.stat .stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--line); background: var(--white); color: var(--ink-2);
  padding: 9px 15px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; transition: all .15s; white-space: nowrap; line-height: 1.2;
}
.btn:hover { background: var(--bg); border-color: #d7dee7; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: var(--white); border-color: #f3c2c2; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--blue-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field label .t-en { color: var(--muted); font-weight: 500; }
.field .req { color: var(--red); }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--white); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--blue-soft); border-color: var(--blue); }
textarea { resize: vertical; min-height: 64px; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-calc { font-size: 13px; color: var(--blue-dark); font-weight: 600; background: var(--blue-soft); padding: 9px 12px; border-radius: 9px; }

/* ===== Toolbar ===== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 100px; }

/* single-row filter bar (Dashboard / Employees / Stores / Attendance / Advance / Payroll) */
.filter-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: nowrap; overflow-x: auto; margin-bottom: 20px; padding-bottom: 2px; }
.filter-bar::-webkit-scrollbar { height: 6px; }
.filter-item { display: flex; flex-direction: column; gap: 5px; min-width: 220px; flex: 0 0 auto; }
.filter-item.small { min-width: 160px; }
.filter-item.grow { flex: 1 1 auto; min-width: 200px; }
.filter-item > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.filter-item .search-box { min-width: 0; }
@media (max-width: 768px) { .filter-bar { overflow-x: auto; } }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box input { padding-left: 38px; }
.search-box .s-ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: flex; }
.help-text { color: var(--muted); font-size: 13px; }
.sel { min-width: 180px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: #f8fafc; color: var(--ink-2); text-align: left;
  padding: 12px 14px; font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { text-align: right; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--blue-soft-2); color: var(--blue-dark); }
.badge.gray { background: #f1f5f9; color: var(--muted); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .em-ico { display: inline-flex; color: var(--blue); opacity: .7; margin-bottom: 4px; }
.empty p { margin: 10px 0 16px; }

/* mini summary list */
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); }
.mini-row:last-child { border-bottom: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--blue-soft-2); color: var(--blue-dark);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.mini-row .mr-name { font-weight: 600; }
.mini-row .mr-sub { font-size: 12px; color: var(--muted); }
.mini-row .mr-amt { margin-left: auto; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* two-column layout for dashboard */
.cols { display: grid; gap: 18px; grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 880px) { .cols { grid-template-columns: 1fr; } }

/* quick actions */
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.quick-actions .btn {
  flex: 1; min-width: 150px;
  background: var(--blue-soft); color: var(--blue);
  border: 1px solid var(--blue-soft-2); font-weight: 700;
}
.quick-actions .btn:hover { background: var(--blue-soft-2); }
.quick-actions .btn:first-child { background: var(--blue); color: #fff; border-color: var(--blue); }
.quick-actions .btn:first-child:hover { background: var(--blue-600); }

/* info box (formula / example) */
.info-box { background: var(--blue-soft); border: 1px solid var(--blue-soft-2); border-radius: 12px; padding: 14px 16px; }
.info-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--blue-dark); }
.info-box code, .info-box .formula { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-family: "Phetsarath OT", "Noto Sans Lao", monospace; }
.totals-row td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--blue); }

/* ===== Modal ===== */
.modal-host { position: fixed; inset: 0; z-index: 60; display: none; }
.modal-host.show { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); }
.modal {
  position: relative; margin: 6vh auto; max-width: 640px; width: calc(100% - 32px);
  background: var(--white); border-radius: 16px; box-shadow: var(--shadow-lg);
  max-height: 88vh; display: flex; flex-direction: column; animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-close { margin-left: auto; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Toast ===== */
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: slidein .2s ease; max-width: 320px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 760px) {
  .appbar-inner { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .app-date, .user-meta { display: none; }
  .content { padding: 18px 14px 50px; }
  .page-actions { width: 100%; margin-left: 0; }
}

/* ===== Print ===== */
@media print {
  .appbar, .tabs, .toolbar, .col-actions, .btn, .modal-host, .toast-host, .page-actions, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card, .table-wrap { box-shadow: none; border-color: #999; }
  thead th { background: #eef4ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-header { display: block !important; margin-bottom: 16px; }
}
.print-header { display: none; }
.print-header h2 { margin: 0 0 4px; }
.print-header p { margin: 0; color: var(--muted); }
