:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --accent-red: #dc2626;
  --accent-red-bg: #fef2f2;
  --accent-red-border: #fecaca;
  --accent-green: #059669;
  --accent-green-bg: #ecfdf5;
  --accent-green-border: #a7f3d0;
  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Bengali", "Hind Siliguri", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 92px;
}

.app-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px 32px;
}

/* Top Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #0f766e 0%, #065f46 100%);
  color: #ffffff;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.2);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 12.5px;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Strict Language Switcher */
.lang-switch {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.lang-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: #ffffff;
  color: #0f766e;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Hero Balance Card */
.hero-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
}

.hero-card.owed {
  border-color: var(--accent-red-border);
  background: linear-gradient(180deg, #ffffff 0%, #fffafa 100%);
}

.hero-card.credit {
  border-color: var(--accent-green-border);
  background: linear-gradient(180deg, #ffffff 0%, #f4fdf9 100%);
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.owed {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
}

.status-pill.credit {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green-border);
}

.rent-mode-toggle {
  display: inline-flex;
  background: var(--surface-soft);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.hero-amount-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}

.hero-main-amount {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.hero-main-amount.owed {
  color: var(--accent-red);
}

.hero-main-amount.credit {
  color: var(--accent-green);
}

.hero-explain {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Formula Breakdown Grid */
.formula-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.formula-box {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 10px;
  border: 1px solid var(--border);
}

.formula-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.formula-val {
  font-size: 16px;
  font-weight: 800;
}

.formula-val.neg {
  color: var(--accent-red);
}

.formula-val.pos {
  color: var(--accent-green);
}

.formula-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-whatsapp {
  background: #16a34a;
  color: #ffffff;
  flex: 1;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline {
  background: var(--surface);
  color: var(--text-main);
  border: 1.5px solid var(--border);
}

/* Section Card */
.section-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Filter Controls */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.select-input,
.text-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 14.5px;
  font-family: inherit;
  color: var(--text-main);
  font-weight: 600;
}

.select-input:focus,
.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Category Filter Pills */
.cat-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.cat-pills::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-main);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.cat-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Month Group Header */
.month-group {
  margin-bottom: 16px;
}

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
  padding: 10px 13px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.month-header-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-dark);
}

.month-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.photo-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

/* Ledger Row */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.tx-item.credit-row {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.tx-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
}

.tx-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}

.tx-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.tx-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tx-right {
  text-align: right;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 16px;
  font-weight: 800;
}

.tx-amount.neg {
  color: var(--accent-red);
}

.tx-amount.pos {
  color: var(--accent-green);
}

.tx-delete-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  padding: 2px 4px;
}

.tx-delete-btn:hover {
  color: var(--accent-red);
}

/* 1-Tap Quick-Add Chips for Mami */
.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 13px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}

.quick-chip.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Voice & Photo Scanner Bar */
.smart-assist-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.assist-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 12px;
  border-radius: 14px;
  border: 2px dashed var(--primary);
  background: #f0fdfa;
  color: var(--primary-dark);
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
}

.assist-btn.recording {
  background: var(--accent-red-bg);
  border-color: var(--accent-red);
  color: var(--accent-red);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* Big Amount Input & Preset Denomination Buttons */
.big-amount-input {
  width: 100%;
  font-size: 28px;
  font-weight: 900;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--primary);
  background: #f8fafc;
  color: var(--text-main);
  text-align: center;
  margin-bottom: 10px;
}

.denom-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.denom-btn {
  padding: 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-dark);
  cursor: pointer;
}

/* Rent Calendar Grid */
.rent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.rent-card {
  padding: 12px;
  border-radius: 13px;
  border: 1.5px solid var(--border);
  background: var(--surface);
}

.rent-card.paid {
  border-color: var(--accent-green-border);
  background: #f0fdf4;
}

.rent-card.partial {
  border-color: #fde68a;
  background: var(--accent-amber-bg);
}

.rent-card.due {
  border-color: var(--accent-red-border);
  background: var(--accent-red-bg);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 90;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

.nav-tab {
  flex: 1;
  max-width: 160px;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.nav-tab .nav-icon {
  font-size: 20px;
}

.nav-tab.active {
  color: var(--primary);
  background: #f0fdfa;
}

/* Photo Modal Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: var(--surface);
  border-radius: 18px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}

.modal-body {
  padding: 12px;
  overflow-y: auto;
  text-align: center;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

@media (max-width: 520px) {
  .formula-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .hero-main-amount {
    font-size: 30px;
  }
}

/* Security PIN Lock Screen */
.lock-screen-wrap {
  min-height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
}

.lock-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 26px 22px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.1);
  border: 2px solid var(--border);
  text-align: center;
}

.lock-icon-badge {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
}

.lock-title {
  font-size: 21px;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 4px;
}

.lock-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--primary);
  background: transparent;
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--primary);
  transform: scale(1.1);
}

.pin-error-msg {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.pin-key {
  height: 58px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-main);
  font-size: 23px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: background 0.1s ease, transform 0.08s ease;
}

.pin-key:active {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(0.96);
}

.pin-key.action-key {
  font-size: 15px;
  color: var(--text-muted);
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.2);
  color: #ffffff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

