@import url("https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&text=%24%E2%82%AC%C2%A3%C2%A5%E2%82%B9%D8%AF.%D8%A5%E0%B8%BFABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&display=swap");

:root {
  --paper: #F6F3EC;
  --ink: #18221B;
  --brand: #0F766E;
  --brand-dark: #115E59;
  --stamp: #B0402A;
  --muted: #64748B;
  --line: #D8D2C2;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

/* Space Mono has no Indian Rupee (₹) or many currency signs — never use it for money. */
.currency-sym,
select.bb-input {
  font-family: "Noto Sans", Inter, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(transparent, transparent 27px, var(--line) 28px);
  background-attachment: local;
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}

.bb-bg { background-color: var(--paper); }
.text-ink { color: var(--ink); }
.text-brand { color: var(--brand); }
.border-brand { border-color: var(--brand); }
.bg-brand { background-color: var(--brand) !important; }

.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.7;
}
.nav-tab:hover {
  opacity: 1;
  background-color: rgba(24, 34, 27, 0.06);
}
.nav-tab.active {
  background-color: var(--brand) !important;
  color: #ffffff !important;
  opacity: 1;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.25);
}

.font-mono { font-family: 'Space Mono', monospace; }

.page-header {
  padding-top: var(--safe-top);
}

.page-main {
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.app-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.stamp-mark {
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 2px dashed var(--brand);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  transform: rotate(-5deg);
  flex-shrink: 0;
}

.tab-nav {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 8px 14px;
  border-radius: 6px;
  color: color-mix(in srgb, var(--ink) 65%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color .15s ease, color .15s ease;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tab-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tab-btn.active {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.bb-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.bb-label {
  display: block;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
  font-weight: 600;
}

.bb-input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 8px 4px;
  outline: none;
  font-family: 'Space Mono', monospace;
  font-size: 15px;
  color: var(--ink);
}
.bb-input:focus { border-color: var(--brand); }

select.bb-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%230F766E' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 20px;
}

.bb-btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--brand);
  color: #fff;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 16px;
  border-radius: 6px;
  transition: all .15s ease;
  border: none;
  cursor: pointer;
  min-height: 40px;
  text-align: center;
  font-weight: 600;
}
.bb-btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
.bb-btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.bb-btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(26, 26, 26, 0.2);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  border-radius: 6px;
  transition: border-color .15s ease, background .15s ease;
  cursor: pointer;
  min-height: 40px;
  text-align: center;
}
.bb-btn-secondary:hover {
  border-color: var(--brand);
  background: rgba(15, 118, 110, 0.06);
}

.bb-chip {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  background: transparent;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .15s ease;
}
.bb-chip.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 700;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #E2E8F0;
  color: #334155;
}
.cat-Food { background: #FEF3C7; color: #92400E; }
.cat-Groceries { background: #DCFCE7; color: #166534; }
.cat-Travel { background: #E0E7FF; color: #3730A3; }
.cat-Transit { background: #E0F2FE; color: #075985; }
.cat-Housing { background: #FCE7F3; color: #9D174D; }
.cat-Utilities { background: #F3E8FF; color: #6B21A8; }
.cat-Entertainment { background: #FFE4E6; color: #9F1239; }
.cat-Shopping { background: #FFEDD5; color: #9A3412; }
.cat-Healthcare { background: #CCFBF1; color: #115E59; }
.cat-General { background: #F1F5F9; color: #475569; }

.split-type-pill {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'Space Mono', monospace;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #F8FAFC;
  color: var(--muted);
  transition: all .15s ease;
}
.split-type-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dropzone.dragover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 6%, transparent);
}

.receipt-preview {
  clip-path: polygon(
    0% 2%, 3% 0%, 6% 2%, 9% 0%, 12% 2%, 15% 0%, 18% 2%, 21% 0%, 24% 2%, 27% 0%,
    30% 2%, 33% 0%, 36% 2%, 39% 0%, 42% 2%, 45% 0%, 48% 2%, 51% 0%, 54% 2%, 57% 0%,
    60% 2%, 63% 0%, 66% 2%, 69% 0%, 72% 2%, 75% 0%, 78% 2%, 81% 0%, 84% 2%, 87% 0%,
    90% 2%, 93% 0%, 96% 2%, 100% 0%,
    100% 98%, 96% 100%, 93% 98%, 90% 100%, 87% 98%, 84% 100%, 81% 98%, 78% 100%,
    75% 98%, 72% 100%, 69% 98%, 66% 100%, 63% 98%, 60% 100%, 57% 98%, 54% 100%,
    51% 98%, 48% 100%, 45% 98%, 42% 100%, 39% 98%, 36% 100%, 33% 98%, 30% 100%,
    27% 98%, 24% 100%, 21% 98%, 18% 100%, 15% 98%, 12% 100%, 9% 98%, 6% 100%, 3% 98%, 0% 100%
  );
  max-height: 280px;
  object-fit: contain;
}

.status-active { color: var(--brand); border-color: var(--brand); }
.status-settled { color: var(--stamp); border-color: var(--stamp); }

.balance-positive { color: #16A34A; }
.balance-negative { color: var(--stamp); }

.auth-card {
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.auth-toggle {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  cursor: pointer;
}
.auth-toggle:hover { color: var(--brand); }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 34, 27, 0.5);
  backdrop-filter: blur(3px);
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal-overlay.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.group-card {
  transition: all .15s ease;
}
.group-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.08);
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  padding: 0.75rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 6%, transparent);
}
.settings-toggle:last-child { border-bottom: none; }
.settings-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.settings-toggle-label {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--ink);
}
.settings-toggle-hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.settings-switch {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--line);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background .2s ease;
}
.settings-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.settings-toggle input:checked + .settings-switch {
  background: var(--brand);
}
.settings-toggle input:checked + .settings-switch::after {
  transform: translateX(18px);
}

.bb-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px;
}

.bb-mobile-list {
  display: none;
}

.bb-mobile-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  background: color-mix(in srgb, var(--paper) 30%, #fff);
}

@media (max-width: 767px) {
  .bb-table-wrap { display: none; }
  .bb-mobile-list { display: block; }
  .bb-card { padding: 16px; }
  .dropzone { padding: 28px 16px; min-height: 120px; }
}

@media (max-width: 480px) {
  .header-actions .btn-label {
    display: none;
  }
  .page-title {
    font-size: 15px !important;
  }
}
