:root {
  --primary: #14b8a6;
  --primary-dark: #0d9488;
  --primary-light: #5eead4;
  --bg: #f0fdfa;
  --card: #ffffff;
  --text: #134e4a;
  --text-muted: #64748b;
  --danger: #ef4444;
  --income: #22c55e;
  --expense: #f97316;
  --shadow: 0 4px 14px rgba(20, 184, 166, 0.15);
  --radius: 14px;
  --nav-h: 72px;
  --lang-bar-h: 48px;
  --header-h: 56px;
  --input-border: #cbd5e1;
  --input-focus: #14b8a6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
html, body {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* ຟອນທັ້ງລະບົບ – ລວມເມນູລຸ່ມ */
button,
input,
select,
textarea,
optgroup,
option,
.btn,
.nav-item,
.bottom-nav,
.bottom-nav .nav-item,
.bottom-nav .nav-item span,
.lang-select,
.app-header,
.auth-screen,
.main-content {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  box-shadow: 0 0 40px rgba(0,0,0,.08);
}

.hidden { display: none !important; }

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 { font-size: 1.1rem; font-weight: 600; }
.app-header .btn-icon {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}

/* Global inputs – ທຸກ textbox ໃນແອັບ */
.input-field,
input:not([type]),
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-field:focus,
input:not([type]):focus,
input[type="text"]:focus,
input[type="tel"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--input-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
input[type="file"] {
  padding: 10px;
  border: 2px dashed var(--input-border);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  vertical-align: middle;
  margin-right: 6px;
}

/* Header actions – ແຊັດ, ຕັ້ງຄ່າ, ພາສາ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.header-nav.active {
  background: rgba(255, 255, 255, 0.35) !important;
}
/* ປ່ຽນພາສາ – droplist ນ້ອຍ */
.lang-select {
  width: auto;
  min-width: 58px;
  max-width: 72px;
  padding: 6px 28px 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary-dark);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%230d9488'%3E%3Cpath d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  line-height: 1.2;
}
.lang-select-auth {
  min-width: 72px;
  padding: 8px 32px 8px 12px;
  font-size: 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background-color: rgba(255, 255, 255, 0.95);
}

/* Bottom Nav – 4 ເມນູ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .65rem;
  padding: 6px 0;
  border: none;
  background: none;
  cursor: pointer;
}
.bottom-nav .nav-item i { font-size: 1.35rem; margin-bottom: 4px; }
.bottom-nav .nav-item span {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
}
.bottom-nav .nav-item.active { color: #fff; }
.bottom-nav .nav-item.active i { transform: scale(1.15); }

.main-content {
  padding: 12px 16px calc(var(--nav-h) + 20px);
  min-height: calc(100dvh - var(--header-h));
}
.settings-form .form-group input.input-field,
.settings-form .form-group input[type="text"],
.settings-form .form-group input[type="date"],
.settings-form .form-group input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--input-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  background: var(--card);
  color: var(--text);
  box-sizing: border-box;
}
.settings-form .form-group input:focus {
  border-color: var(--input-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}
#page-settings .form-group {
  margin-bottom: 14px;
}
.type-toggle .input-field,
.type-toggle select {
  flex: 1;
}
.filter-date-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: stretch;
}
.filter-date-row .input-field {
  flex: 1;
  min-width: 0;
}
.btn-filter {
  width: auto !important;
  padding: 12px 16px !important;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Cards & filters */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.filter-tab {
  flex: 1;
  min-width: 70px;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: .2s;
}
.filter-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}
.filter-tab .amount { font-size: .75rem; opacity: .9; margin-top: 4px; }

.type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.type-toggle button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  background: var(--card);
  color: var(--primary);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.type-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card .icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.card .info { flex: 1; min-width: 0; }
.card .info h3 { font-size: .95rem; margin-bottom: 2px; }
.card .info p { font-size: .75rem; color: var(--text-muted); }
.card .amount-col { text-align: right; font-weight: 700; }
.card .amount-col.income { color: var(--income); }
.card .amount-col.expense { color: var(--expense); }
.progress-bar {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
}

/* Category grid */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.cat-item {
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
}
.cat-item:active {
  transform: scale(0.96);
}
.cat-item .icon-circle {
  width: 56px;
  height: 56px;
  margin: 0 auto 6px;
  font-size: 1.3rem;
  position: relative;
  transition: box-shadow 0.2s;
}
.cat-item.selected .icon-circle {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--primary);
}
.cat-check {
  display: none;
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.cat-item.selected .cat-check {
  display: flex;
}
.cat-item span { font-size: .75rem; display: block; }

/* ໃບບິນ – ແກ້ໄຂ/ລຶບ */
.bill-card {
  position: relative;
}
.bill-card-clickable {
  cursor: pointer;
}
.bill-card-clickable:active {
  opacity: 0.92;
}
.bill-split-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: #ccfbf1;
  color: #0f766e;
  vertical-align: middle;
  margin-left: 4px;
}
.bill-card .bill-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.btn-bill-icon {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn-bill-edit {
  background: #e0f2fe;
  color: #0284c7;
}
.btn-bill-del {
  background: #fee2e2;
  color: #ef4444;
}

/* ວິທີຊຳລະ – ເງິນສົດ / ໂອນ */
.payment-method-bar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.payment-method-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.pay-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pay-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pay-toggle i {
  font-size: 1.25rem;
  opacity: 0.7;
}
.pay-toggle.active {
  border-color: var(--primary);
  background: #ccfbf1;
  color: #0f766e;
}
.pay-toggle.active i {
  opacity: 1;
  color: var(--primary);
}

/* Calculator */
.calc-screen {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: right;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.keypad button {
  padding: 18px;
  font-size: 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
}
.keypad .btn-confirm {
  grid-column: span 3;
  background: var(--danger);
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50px;
  margin-top: 8px;
}

/* Charts */
.chart-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-card .val { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.summary-card.income .val { color: var(--income); }
.summary-card.expense .val { color: var(--expense); }
.summary-card.balance .val { color: var(--primary); }
.summary-card label { font-size: .7rem; color: var(--text-muted); display: block; margin-top: 4px; }
.summary-card.income,
.summary-card.expense {
  text-align: left;
  padding: 12px 10px;
}
.summary-card.income .val,
.summary-card.expense .val {
  text-align: center;
}
.summary-card.income label,
.summary-card.expense label {
  text-align: center;
}
.summary-pay-split {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pay-chip {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.pay-chip i {
  font-size: 0.65rem;
  color: var(--primary);
  text-align: center;
}
.pay-chip b {
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.summary-card.income .pay-chip b { color: var(--income); }
.summary-card.expense .pay-chip b { color: var(--expense); }
.summary-card.expense .pay-chip i { color: #ea580c; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .85rem; margin-bottom: 6px; color: var(--text-muted); font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
#btn-clear-cache { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.settings-divider { margin: 24px 0; border: none; border-top: 1px solid #e2e8f0; }
.settings-tools-title { margin: 0 0 6px; font-size: 1rem; color: #334155; }
.settings-tool-hint,
.settings-reset-hint { margin: 0 0 8px; color: #64748b; font-size: 0.9rem; line-height: 1.45; }
.btn-danger { background: var(--danger); color: #fff; }

/* Auth */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 50%, #042f2e 100%);
}
.auth-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 0;
  width: 100%;
}
/* ກ່ອງຂາວດຽວ: ໂລໂກ້ + ຟອມລອກອິນ */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.auth-logo {
  text-align: center;
  padding: 28px 24px 8px;
  margin-bottom: 0;
  background: #fff;
}
.auth-logo .app-logo-lg {
  max-width: 220px;
  width: auto;
  height: auto;
  max-height: 80px;
  margin: 0 auto;
  display: block;
}
.auth-card .auth-box {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 16px 24px 28px;
  margin: 0;
}
.auth-card .auth-box + .auth-box {
  padding-top: 0;
}
.auth-link {
  text-align: center;
  margin-top: 16px;
}
.lang-bar-inline {
  margin-top: 20px;
  padding: 0;
  position: static;
  width: 100%;
  height: auto;
  transform: none;
  left: auto;
  max-width: none;
}
.lang-bar-inline.lang-bar-auth {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  background: transparent;
  border: none;
  text-align: center;
}
.lang-bar-inline.lang-bar-auth .lang-select,
.lang-bar-inline.lang-bar-auth .lang-select-auth {
  width: auto !important;
  min-width: 88px;
  margin: 0 auto;
}
.app-logo {
  display: block;
  object-fit: contain;
  width: 100%;
  height: auto;
}
.app-logo-lg { max-height: 72px; margin: 0 auto; }
.app-logo-sm { height: 32px; width: auto; flex-shrink: 0; }
.app-header .header-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.app-header .header-brand #header-title {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header:has(#btn-back:not(.hidden)) .header-brand {
  justify-content: flex-start;
  margin-left: 4px;
}
.auth-box {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}

/* Chat */
.chat-list .card { cursor: pointer; }
.chat-room {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h) - var(--nav-h) - 60px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  margin-bottom: 8px;
  font-size: .9rem;
}
.msg-bubble.mine {
  background: var(--primary);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
  background: var(--card);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--card);
  border-top: 1px solid #e2e8f0;
}
.chat-input-bar input {
  flex: 1;
  min-width: 0;
}

/* Ad popup */
.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ad-modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: min(400px, 92vw);
  width: 100%;
  min-width: 280px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.ad-modal .ad-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 118, 110, 0.85);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  font-size: 1rem;
}
.ad-modal .ad-title {
  padding: 14px 48px 8px 16px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
  border-bottom: 1px solid #e2e8f0;
}
.ad-modal .ad-body {
  min-height: 120px;
}
.ad-modal .ad-media {
  width: 100%;
  display: block;
  max-height: 70vh;
  object-fit: contain;
  background: #f8fafc;
}
.ad-modal video.ad-media {
  min-height: 200px;
  background: #000;
}
.ad-modal .ad-text {
  padding: 20px 16px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}
.ad-modal .ad-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}
.ad-modal .ad-countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.ad-modal .ad-countdown-ring {
  --ad-progress: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--ad-progress) * 360deg), #e2e8f0 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.ad-modal .ad-countdown-ring::before {
  content: '';
  position: absolute;
  inset: 5px;
  background: #fff;
  border-radius: 50%;
}
.ad-modal .ad-countdown-num {
  position: relative;
  z-index: 1;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary-dark);
}
.ad-modal .ad-timer-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0;
  margin: 0;
}
.ad-modal .ad-views-live {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.ad-modal .ad-views-num.ad-views-bump {
  animation: adViewsBump 0.4s ease;
}
@keyframes adViewsBump {
  50% { color: var(--primary); transform: scale(1.15); }
}
.ad-modal .ad-close--wait {
  opacity: 0.45;
  cursor: not-allowed;
}
.ad-modal .ad-skip-btn {
  width: 100%;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-color: var(--primary);
  color: var(--primary-dark);
  cursor: pointer;
  position: relative;
  z-index: 3;
}
.ad-modal--linked {
  cursor: pointer;
}
.ad-modal--linked .ad-footer {
  cursor: default;
}
.ad-modal--linked .ad-body,
.ad-modal--linked .ad-title,
.ad-modal--linked .ad-close {
  cursor: pointer;
}

/* Split expense */
.split-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 10px;
}
.split-row .split-name { flex: 1; min-width: 0; }
.split-row .split-units {
  width: 72px !important;
  flex-shrink: 0;
  text-align: center;
}
.split-row .split-amt {
  width: 100px !important;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.8rem;
  color: var(--primary-dark);
  font-weight: 600;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  padding: 10px 6px;
}
.split-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}
.split-summary {
  margin-top: 14px;
  padding: 14px;
  background: #f0fdfa;
  border: 2px solid #99f6e4;
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
}
.split-summary .split-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed #ccfbf1;
}
.split-summary .split-line:last-child {
  border-bottom: none;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 2px solid #5eead4;
}
.split-summary .split-formula {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.split-row .split-rm {
  width: 44px;
  height: auto;
  align-self: stretch;
  flex-shrink: 0;
  background: #fee2e2;
  color: var(--danger);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Settings profile */
.profile-header {
  text-align: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 0 0 24px 24px;
  margin: -12px -16px 20px;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #fff;
  object-fit: cover;
  margin-bottom: 10px;
}
.payment-qr-wrap {
  margin: 16px 0 20px;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
}
.payment-info-text {
  margin: 8px 0 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
  font-family: inherit;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  color: var(--text);
}
.payment-qr-area {
  display: flex;
  justify-content: center;
  min-height: 220px;
  align-items: center;
}
.payment-qr-canvas {
  max-width: 220px;
  width: 220px;
  height: 220px;
  border-radius: 12px;
  background: #fff;
}
.payment-qr-img {
  max-width: 220px;
  border-radius: 12px;
}
.payment-qr-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 8px 0 0;
}
.premium-price-label {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 8px 0 4px;
}
.premium-status-line {
  margin-top: 8px;
  opacity: 0.95;
  font-size: 0.95rem;
}
.premium-remaining {
  margin: 8px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fef08a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.premium-status-line.hidden {
  display: none !important;
}
.premium-renew-hint {
  color: #b45309;
  font-size: 0.9rem;
  margin: 0 0 8px;
  font-weight: 600;
}
.premium-pending-box {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--primary-dark);
}
.premium-slip-preview {
  max-width: 100%;
  max-height: 160px;
  margin-top: 10px;
  border-radius: 8px;
}
.premium-slip-form label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.premium-slip-form .form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 6px 0 12px;
}
.premium-slip-form.hidden {
  display: none !important;
}
.premium-badge {
  display: inline-block;
  background: gold;
  color: #333;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  margin-top: 8px;
}

.page { display: none; }
.page.active { display: block; }

.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: calc(50% - 220px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: 0 4px 20px rgba(20,184,166,.5);
  cursor: pointer;
  z-index: 150;
}
@media (max-width: 480px) {
  .fab { right: 20px; }
}

/* Language bar – ລຸ່ມສຸດ */
.lang-bar-bottom {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--lang-bar-h);
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom);
}
.lang-bar-bottom.lang-bar-auth {
  background: rgba(4, 47, 46, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.lang-bar-inline.lang-bar-auth .lang-switch .lang-btn {
  border-color: rgba(255, 255, 255, 0.75);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.lang-bar-inline.lang-bar-auth .lang-switch .lang-btn.active {
  background: #fff;
  color: var(--primary-dark);
  border-color: #fff;
}
.lang-bar-app {
  background: var(--card);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}
.lang-switch {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.lang-switch .lang-btn {
  padding: 8px 24px;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.lang-switch .lang-btn.active {
  background: var(--primary);
  color: #fff;
}
.lang-bar-bottom.lang-bar-auth .lang-switch .lang-btn {
  border-color: rgba(255, 255, 255, 0.6);
  color: #fff;
}
.lang-bar-bottom.lang-bar-auth .lang-switch .lang-btn.active {
  background: #fff;
  color: var(--primary-dark);
  border-color: #fff;
}

/* SweetAlert2 inputs */
.swal2-input,
.swal2-textarea {
  border: 2px solid var(--input-border) !important;
  border-radius: var(--radius) !important;
  font-family: inherit !important;
}
.swal2-input:focus,
.swal2-textarea:focus {
  border-color: var(--input-focus) !important;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2) !important;
}
.swal2-popup,
.swal2-title,
.swal2-html-container,
.swal2-confirm,
.swal2-cancel {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif !important;
}

/* ຈັດການປະເພດ – SweetAlert */
.swal-cat-mgr.swal2-popup {
  width: 92%;
  max-width: 360px;
  padding: 1.25rem 1rem 1rem;
  border-radius: 16px;
}
.swal-cat-mgr .swal2-title {
  font-size: 1.1rem;
  color: var(--text);
  padding-bottom: 0.5rem;
}
.swal-cat-mgr .swal2-html-container {
  margin: 0;
  padding: 0 0.25rem;
  overflow: visible;
}
.cat-mgr-wrap {
  text-align: left;
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.cat-mgr-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius);
  background: var(--bg);
}
.cat-mgr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.cat-mgr-item:last-child {
  border-bottom: none;
}
.cat-mgr-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-mgr-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}
.cat-mgr-del {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
}
.cat-mgr-del:active {
  transform: scale(0.95);
}
.cat-mgr-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}
.cat-mgr-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cat-mgr-input,
.swal-cat-mgr #swal-cat-name {
  width: 100% !important;
  margin: 0 !important;
  padding: 12px 14px !important;
  border: 2px solid var(--input-border) !important;
  border-radius: var(--radius) !important;
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif !important;
  font-size: 1rem !important;
  box-sizing: border-box !important;
}
.cat-mgr-input:focus,
.swal-cat-mgr #swal-cat-name:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2) !important;
}
.swal-cat-mgr .swal2-actions {
  margin-top: 1rem;
  gap: 10px;
}
.swal-cat-mgr .swal2-confirm {
  background: var(--primary) !important;
  border-radius: var(--radius) !important;
  font-weight: 600 !important;
}
.swal-cat-mgr .swal2-cancel {
  background: #64748b !important;
  border-radius: var(--radius) !important;
}

.swal-bill-edit .bill-edit-form {
  text-align: left;
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.swal-bill-edit .bill-edit-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 10px 0 4px;
  font-weight: 600;
}
.swal-bill-edit .bill-edit-form label:first-child {
  margin-top: 0;
}
.bill-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.swal-bill-detail .bill-detail {
  text-align: left;
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif;
}
.bill-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.bill-detail-head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.bill-detail-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}
.bill-detail-type.tag-income {
  background: #dcfce7;
  color: #15803d;
}
.bill-detail-type.tag-expense {
  background: #fee2e2;
  color: #b91c1c;
}
.bill-detail-amount {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin: 8px 0 16px;
}
.bill-detail-amount.income { color: #15803d; }
.bill-detail-amount.expense { color: #b91c1c; }
.bill-detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
  font-size: 0.9rem;
}
.bill-detail-meta dt {
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
}
.bill-detail-meta dd {
  margin: 0;
  text-align: right;
}
.bill-detail-split {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.bill-detail-section {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--primary);
  margin: 0 0 8px;
}
.bill-detail-formula {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  line-height: 1.4;
}
.bill-detail-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.88rem;
  border-bottom: 1px dashed #e2e8f0;
}
.bill-detail-line:last-child { border-bottom: none; }
.bill-detail-sum {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px solid var(--primary);
  border-bottom: none;
  font-weight: 700;
  color: var(--primary);
}
.bill-detail-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

#bill-detail-export {
  background: #fff;
  padding: 4px 2px 8px;
  border-radius: 8px;
}

.swal-bill-detail .swal2-actions {
  display: none !important;
}
.bill-detail-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.bill-detail-actions-share {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.bill-detail-actions-share-2 {
  grid-template-columns: 1fr 1fr;
}
.btn-bill-share {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
  padding: 10px 6px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-bill-share i {
  font-size: 1.2rem;
  color: #fff;
  opacity: 0.95;
}
.btn-bill-share span {
  line-height: 1.15;
  text-align: center;
}
.btn-bill-share:active {
  transform: scale(0.97);
}
.btn-share-social {
  background: linear-gradient(145deg, #3b82f6, #2563eb);
}
.btn-share-download {
  background: linear-gradient(145deg, #8b5cf6, #7c3aed);
}

.bill-capture-root,
.bill-capture-sheet,
.bill-capture-sheet *:not(i):not([class*="fa-"]) {
  font-family: 'Noto Sans Lao', 'Noto Sans', sans-serif !important;
}
.bill-capture-root,
.bill-capture-sheet {
  background: #fff;
}
.bill-capture-sheet {
  padding: 20px 18px;
  border-radius: 16px;
  border: 2px solid #ccfbf1;
  max-width: 380px;
  -webkit-font-smoothing: antialiased;
}
.bill-capture-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}
.bill-capture-brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.bill-capture-brand strong {
  display: block;
  color: var(--primary);
  font-size: 1rem;
}
.bill-capture-brand span {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bill-detail-actions-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bill-detail-actions-main .btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
}
.btn-outline-muted {
  background: #fff;
  color: var(--text-muted);
  border: 2px solid #e2e8f0;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-outline-muted:active {
  background: #f8fafc;
}

.swal-btn {
  border: none !important;
  border-radius: var(--radius) !important;
  font-family: inherit !important;
  font-weight: 600 !important;
  padding: 12px 24px !important;
  margin: 0 6px !important;
  box-shadow: none !important;
}
.swal-btn-primary {
  background: var(--primary) !important;
  color: #fff !important;
}
.swal-btn-primary:hover {
  background: var(--primary-dark) !important;
}
.swal-btn-muted {
  background: #f1f5f9 !important;
  color: var(--text-muted) !important;
}

.msg-bill-link {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
}
.msg-bubble.mine .msg-bill-link {
  background: rgba(255, 255, 255, 0.35);
}

.auth-box a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.auth-box a:hover { text-decoration: underline; }
