/* ============================================================
   ລະບົບລາຍຮັບ-ລາຍຈ່າຍ — ສະໄຕລ໌ຫຼັກ (ໂທນສີຟ້າ)
   ============================================================ */

:root {
  /* ສີຫຼັກ (ຟ້າ) */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-darker: #1e3a8a;
  --primary-light:  #3b82f6;
  --primary-50:     #eff6ff;
  --primary-100:    #dbeafe;
  --primary-grad:   linear-gradient(135deg, #2563eb 0%, #1e40af 100%);

  /* ສະຖານະ */
  --income:  #16a34a;
  --income-bg: #dcfce7;
  --expense: #ef4444;
  --expense-bg: #fee2e2;
  --warning: #f59e0b;

  /* ໂທນເທົາ */
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,.10);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.16);
  --sidebar-w: 264px;
  --font: 'Noto Sans Lao Looped', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   ປຸ່ມ
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--income); color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text-soft); }
.btn-ghost:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-50); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.icon-btn {
  width: 40px; height: 40px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }

/* ============================================================
   ໜ້າເຂົ້າສູ່ລະບົບ
   ============================================================ */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--primary-grad);
  position: relative; overflow: hidden;
}
.login-screen::before,
.login-screen::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.login-screen::before { width: 380px; height: 380px; top: -120px; right: -100px; }
.login-screen::after { width: 300px; height: 300px; bottom: -120px; left: -80px; }

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 410px;
  background: var(--surface); border-radius: 22px;
  padding: 38px 32px; box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 68px; height: 68px; margin: 0 auto 16px;
  background: var(--primary-grad); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 30px; box-shadow: 0 8px 20px rgba(37,99,235,.35);
}
.login-brand h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-brand p { color: var(--text-mute); font-size: 14px; margin-top: 4px; }

.login-form .field { margin-bottom: 16px; }
.login-error {
  color: var(--expense); font-size: 13.5px; min-height: 20px;
  margin-bottom: 6px; text-align: center;
}
.login-hint { text-align: center; color: var(--text-mute); font-size: 13px; margin-top: 18px; }

/* ============================================================
   ຟອມ
   ============================================================ */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13.5px; font-weight: 600;
  color: var(--text-soft); margin-bottom: 7px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; font-size: 14.5px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-icon { position: relative; }
.input-icon > i:first-child {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-mute); font-size: 14px; pointer-events: none;
}
.input-icon input { padding-left: 40px; }
.toggle-pw {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-mute); cursor: pointer;
  padding: 8px; font-size: 14px;
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ============================================================
   ໂຄງສ້າງແອັບ
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px; border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--primary-grad); border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.brand-text { font-weight: 700; font-size: 16px; color: var(--text); }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 14px; margin-bottom: 3px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500; font-size: 14.5px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: right;
  transition: background .15s, color .15s; text-align: left;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--primary-50); color: var(--primary-dark); }
.nav-item.active {
  background: var(--primary-grad); color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.sidebar-footer { padding: 14px 12px; border-top: 1px solid var(--border); }
.logout-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--expense); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background .15s;
}
.logout-btn:hover { background: var(--expense-bg); }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.45); z-index: 99;
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; }
.page-title { font-size: 19px; font-weight: 700; flex: 1; }

.topbar-user {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 6px 10px; border-radius: var(--radius-sm); position: relative;
  transition: background .15s;
}
.topbar-user:hover { background: var(--bg); }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 12px; color: var(--text-mute); }
.topbar-user > i { color: var(--text-mute); font-size: 12px; }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  min-width: 190px; padding: 6px; display: none; z-index: 60;
}
.user-dropdown.open { display: block; }
.user-dropdown button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border: none; background: none; border-radius: 7px;
  color: var(--text-soft); font-size: 14px; cursor: pointer; text-align: left;
}
.user-dropdown button:hover { background: var(--bg); }
.user-dropdown button i { width: 16px; }

.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; }

/* ============================================================
   ກາດ ແລະ ສ່ວນຫົວ
   ============================================================ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-header h3 { font-size: 18px; font-weight: 700; }
.page-header .subtitle { color: var(--text-mute); font-size: 13.5px; margin-top: 2px; }

/* ການ໌ດສະຫຼຸບໜ້າຫຼັກ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-card.accent { background: var(--primary-grad); border: none; color: #fff; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.stat-card.income .stat-icon { background: var(--income-bg); color: var(--income); }
.stat-card.expense .stat-icon { background: var(--expense-bg); color: var(--expense); }
.stat-card.accent .stat-icon { background: rgba(255,255,255,.2); color: #fff; }
.stat-card.count .stat-icon { background: var(--primary-100); color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-mute); }
.stat-card.accent .stat-label { color: rgba(255,255,255,.85); }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-wrap { position: relative; height: 300px; }

/* ============================================================
   ຕາຕະລາງ
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 13px 14px; font-size: 12.5px; font-weight: 700;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--primary-50); }
tbody tr:last-child td { border-bottom: none; }

.cat-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: 500;
}
.cat-chip i { font-size: 12px; }

.amount-income { color: var(--income); font-weight: 700; }
.amount-expense { color: var(--expense); font-weight: 700; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-income { background: var(--income-bg); color: var(--income); }
.badge-expense { background: var(--expense-bg); color: var(--expense); }
.badge-admin { background: var(--primary-100); color: var(--primary-dark); }
.badge-user { background: #f1f5f9; color: var(--text-soft); }
.badge-active { background: var(--income-bg); color: var(--income); }
.badge-inactive { background: #f1f5f9; color: var(--text-mute); }

.row-actions { display: flex; gap: 6px; }
.action-btn {
  width: 32px; height: 32px; border: none; border-radius: 8px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all .15s;
}
.action-edit { background: var(--primary-50); color: var(--primary); }
.action-edit:hover { background: var(--primary-100); }
.action-delete { background: var(--expense-bg); color: var(--expense); }
.action-delete:hover { background: #fecaca; }
.action-perm { background: #f3e8ff; color: #9333ea; }
.action-perm:hover { background: #e9d5ff; }

/* ============================================================
   ຕົວກອງ
   ============================================================ */
.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 18px;
}
.filter-bar .field { margin-bottom: 0; min-width: 150px; }
.filter-bar .field label { margin-bottom: 5px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.5); align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn .2s ease;
}
.modal-sm { max-width: 380px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ກ່ອງຢືນຢັນ */
.confirm-body { text-align: center; }
.confirm-icon {
  width: 60px; height: 60px; margin: 4px auto 16px;
  background: var(--expense-bg); color: var(--expense); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.confirm-body p { font-size: 15px; margin-bottom: 22px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* ============================================================
   Toast
   ============================================================ */
.toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border-radius: 11px; padding: 13px 18px;
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--primary);
  min-width: 260px; animation: toastIn .25s ease;
}
.toast.success { border-left-color: var(--income); }
.toast.error { border-left-color: var(--expense); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--income); }
.toast.error i { color: var(--expense); }
.toast span { font-size: 14px; font-weight: 500; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ============================================================
   ສະຖານະວ່າງເປົ່າ ແລະ ໂຫຼດ
   ============================================================ */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-mute); }
.empty-state i { font-size: 44px; margin-bottom: 14px; opacity: .5; }
.empty-state p { font-size: 15px; }

.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 50px; color: var(--primary);
}
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--primary-100);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   ການກຳນົດສິດ (Permission grid)
   ============================================================ */
.perm-table th, .perm-table td { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-menu { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.perm-menu i { color: var(--primary); width: 20px; text-align: center; }
.perm-check {
  width: 22px; height: 22px; cursor: pointer; accent-color: var(--primary);
}
.perm-head-toggle {
  font-size: 11px; color: var(--primary); cursor: pointer;
  background: none; border: none; font-weight: 600; margin-top: 3px;
}

/* ============================================================
   ໝວດໝູ່ (icon picker)
   ============================================================ */
.icon-picker {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px;
  max-height: 160px; overflow-y: auto; padding: 8px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
.icon-pick {
  aspect-ratio: 1; border: 1.5px solid transparent; border-radius: 8px;
  background: var(--bg); cursor: pointer; display: flex;
  align-items: center; justify-content: center; font-size: 15px; color: var(--text-soft);
}
.icon-pick:hover { background: var(--primary-50); }
.icon-pick.selected { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-pick {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2.5px solid transparent;
}
.color-pick.selected { border-color: var(--text); }

.cat-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text-soft);
  margin: 18px 0 10px;
}
.cat-section-title:first-child { margin-top: 0; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; }
.cat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.cat-item-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: #fff;
}
.cat-item-name { flex: 1; font-weight: 600; font-size: 14px; }
.cat-item .row-actions { opacity: 0; transition: opacity .15s; }
.cat-item:hover .row-actions { opacity: 1; }

/* ============================================================
   ມືຖື (Responsive)
   ============================================================ */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .topbar-user > i { display: none; }
  .page-title { font-size: 17px; }
  .stat-value { font-size: 19px; }
  .filter-bar .field { min-width: 130px; flex: 1; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 18px; }
  .stat-value { font-size: 17px; }
  .login-card { padding: 30px 22px; }
  .icon-picker { grid-template-columns: repeat(6, 1fr); }
  .cat-grid { grid-template-columns: 1fr; }
}

/* ການເຂົ້າເຖິງ (Accessibility) */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   ສ່ວນເພີ່ມເຕີມ: ກຳນົດສິດ / ຜູ້ໃຊ້ / ລາຍງານ
   ============================================================ */

/* --- ຫົວຕາຕະລາງກຳນົດສິດ --- */
.perm-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin: 14px 0 16px;
}
.perm-user-info { display: flex; align-items: center; gap: 12px; }
.perm-user-name { font-weight: 700; font-size: 15px; color: var(--text); }
.perm-legend {
  font-size: 12.5px; color: var(--text-soft); display: flex; align-items: center; gap: 7px;
  background: var(--primary-50); padding: 8px 12px; border-radius: var(--radius-sm);
}
.perm-legend i { color: var(--primary); }
.perm-col { width: 86px; }
.perm-table thead th { font-size: 12.5px; white-space: nowrap; }
.perm-table thead th i { margin-right: 4px; color: var(--text-mute); }

/* --- Checkbox ແບບກຳນົດເອງ (override ຂອງເກົ່າ) --- */
.perm-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: auto; height: auto; cursor: pointer; position: relative;
}
.perm-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.perm-box {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  transition: all .15s; color: #fff;
}
.perm-box i { font-size: 12px; opacity: 0; transform: scale(.5); transition: all .15s; }
.perm-check input:checked + .perm-box {
  background: var(--primary); border-color: var(--primary);
}
.perm-check input:checked + .perm-box i { opacity: 1; transform: scale(1); }
.perm-check input:disabled + .perm-box { opacity: .45; cursor: not-allowed; }
.perm-check:hover input:not(:disabled) + .perm-box { border-color: var(--primary-light); }

.perm-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.perm-actions .btn-primary { margin-left: auto; }

/* --- ເຊລຜູ້ໃຊ້ໃນຕາຕະລາງ --- */
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-grad); color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* --- ກ່ອງຂໍ້ມູນ / ຄຳແນະນຳ --- */
.info-box {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--primary-50); color: var(--text-soft);
  font-size: 13px; line-height: 1.6; padding: 11px 14px;
  border-radius: var(--radius-sm); margin: 4px 0 16px;
}
.info-box i { color: var(--primary); margin-top: 2px; }

/* --- ປຸ່ມຊ່ວງເວລາໄວ (ລາຍງານ) --- */
.quick-range { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-end; }
.quick-range .btn-sm { background: var(--bg); }
.quick-range .btn-sm:hover { background: var(--primary-50); color: var(--primary); }

/* --- Select ນ້ອຍໃນຫົວກາດ --- */
.inline-select {
  padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; background: var(--surface); color: var(--text); cursor: pointer;
}

/* --- ປຸ່ມສິດ (ໄອຄອນ) --- */
.action-perm { color: var(--primary); }
.action-perm:hover { background: var(--primary-50); }

/* --- ສ່ວນທ້າຍຕາຕະລາງ --- */
tfoot td { border-top: 2px solid var(--border); background: var(--bg); }

@media (max-width: 860px) {
  .perm-legend { width: 100%; }
  .perm-col { width: 60px; }
  .quick-range { width: 100%; }
}

.btn-danger { background-color: #ef4444 !important; color: white !important; border: 1px solid #ef4444; }
.btn-success { background-color: #16a34a !important; color: white !important; border: 1px solid #16a34a; }
.btn-outline { background-color: transparent !important; color: #64748b !important; border: 1px solid #cbd5e1; }


/* Budget Calendar */
.budget-nav { display:flex;align-items:center;justify-content:center;gap:20px;padding:12px 20px; }
.budget-month-label { font-size:18px;font-weight:700;color:var(--text);min-width:180px;text-align:center; }
.budget-progress-wrap { grid-column:1/-1;padding:14px 18px;background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow); }
.budget-progress-label { display:flex;justify-content:space-between;font-size:13px;color:var(--text-soft);margin-bottom:8px; }
.budget-progress-bar { height:10px;background:var(--border);border-radius:999px;overflow:hidden; }
.budget-progress-fill { height:100%;border-radius:999px;transition:width .4s ease; }
.cal-grid-header { display:grid;grid-template-columns:repeat(7,1fr);gap:4px;margin-bottom:4px; }
.cal-dow { text-align:center;font-size:12px;font-weight:700;color:var(--text-mute);padding:6px 0; }
.cal-grid { display:grid;grid-template-columns:repeat(7,1fr);gap:6px; }
.cal-cell { position:relative;border-radius:var(--radius-sm);border:1.5px solid var(--border);background:var(--surface);padding:8px 7px 28px;min-height:90px;transition:box-shadow .15s; }
.cal-cell:hover { box-shadow:var(--shadow-md); }
.cal-empty { border-color:transparent;background:transparent;box-shadow:none; }
.cal-ok { border-color:#bbf7d0;background:#f0fdf4; }
.cal-over { border-color:#fecaca;background:#fff5f5; }
.cal-unlogged { border-color:#fef9c3;background:#fefce8; }
.cal-today { border-color:var(--primary)!important;box-shadow:0 0 0 2px var(--primary-100); }
.cal-day-num { font-weight:700;font-size:15px;color:var(--text);line-height:1; }
.cal-today .cal-day-num { color:var(--primary); }
.cal-avail { font-size:11px;color:var(--text-mute);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.cal-spent { font-size:11.5px;font-weight:700;margin-top:5px;display:flex;align-items:center;gap:4px; }
.cal-spent-ok { color:var(--income); }
.cal-spent-over { color:var(--expense); }
.cal-no-log { font-size:10.5px;color:var(--warning);margin-top:5px;display:flex;align-items:center;gap:4px; }
.cal-note { font-size:10px;color:var(--text-mute);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; }
.cal-log-btn { position:absolute;bottom:5px;right:5px;padding:3px 7px;font-size:11px;border:none;border-radius:6px;cursor:pointer;background:var(--primary-50);color:var(--primary);opacity:0;transition:opacity .15s; }
.cal-cell:hover .cal-log-btn { opacity:1; }
.cal-legend { display:flex;gap:16px;flex-wrap:wrap;margin-top:14px;padding-top:14px;border-top:1px solid var(--border);font-size:12.5px;color:var(--text-soft); }
.cal-legend-item { display:flex;align-items:center;gap:6px; }
.cal-dot { width:12px;height:12px;border-radius:3px;flex-shrink:0; }
.cal-dot.cal-ok { background:#bbf7d0;border:1.5px solid #86efac; }
.cal-dot.cal-over { background:#fecaca;border:1.5px solid #fca5a5; }
.cal-dot.cal-unlogged { background:#fef9c3;border:1.5px solid #fde047; }
.cal-dot.cal-today-dot { background:var(--primary-100);border:1.5px solid var(--primary); }
@media(max-width:640px){
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 58px; padding: 5px 4px 4px; }
  .cal-day-num { font-size: 12px; }
  .cal-avail { font-size: 9px; margin-top: 2px; }
  .cal-spent { font-size: 9px; margin-top: 2px; gap: 2px; }
  .cal-spent i { display: none; }
  .cal-no-log { font-size: 9px; margin-top: 2px; gap: 2px; }
  .cal-no-log i { display: none; }
  .cal-diff { font-size: 9px; }
  .cal-dow { font-size: 10px; padding: 4px 0; }
  .budget-month-label { font-size: 15px; min-width: 120px; }
}
@media(max-width:400px){
  .cal-grid { gap: 2px; }
  .cal-cell { min-height: 48px; padding: 4px 3px 3px; }
  .cal-day-num { font-size: 11px; }
  .cal-avail { display: none; }
  .cal-spent { font-size: 8.5px; }
  .cal-no-log { font-size: 8.5px; }
  .cal-dow { font-size: 9px; }
}
/* ກ່ອງວັນທີ່ກົດໄດ້ */
.cal-clickable { cursor: pointer; user-select: none; }
.cal-clickable:hover { transform: scale(1.03); box-shadow: var(--shadow-md); transition: transform .12s, box-shadow .12s; }
.cal-clickable:active { transform: scale(0.97); }

/* ລຶບ cal-log-btn ເກົ່າ (ໃຊ້ click cell ແທນ) */
.cal-log-btn { display: none; }

/* ສະຖານະ "ໄຫຼໄປຕໍ່" */
.cal-no-log { font-size: 10.5px; color: #ca8a04; margin-top: 5px; display: flex; align-items: center; gap: 4px; }

/* ສ່ວນຕ່າງ: ຈ່າຍເກີນ/ຫຼຸດ */
.cal-diff { font-size: 10px; font-weight: 700; margin-top: 2px; }
.cal-diff-over  { color: var(--expense); }
.cal-diff-under { color: var(--income); }