/* =====================================================================
   money.iamhch — premium UI
   Design tokens, type scale, component overrides on top of Bootstrap 5.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Surfaces */
  --bg:           #fafaf9;
  --surface:      #ffffff;
  --surface-2:    #f4f4f5;
  --surface-3:    #e7e5e4;
  --hover:        rgba(0, 0, 0, 0.025);

  /* Borders */
  --border:        rgba(15, 23, 42, 0.07);
  --border-strong: rgba(15, 23, 42, 0.14);

  /* Text */
  --text:         #18181b;
  --text-muted:   #71717a;
  --text-subtle:  #a1a1aa;

  /* Brand + semantic */
  --brand:        #16a34a;
  --brand-strong: #15803d;
  --brand-soft:   #dcfce7;
  --danger:       #dc2626;
  --danger-soft:  #fee2e2;
  --warning:      #d97706;
  --warning-soft: #fef3c7;
  --info:         #0ea5e9;
  --info-soft:    #e0f2fe;
  --crypto:       #f7931a;
  --crypto-soft:  #fef3c7;

  /* Effects */
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    18px;
  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:       0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg:    0 10px 24px -8px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
  --transition:   150ms cubic-bezier(.4, 0, .2, 1);

  /* Type */
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Menlo', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0b0d13;
    --surface:      #15181f;
    --surface-2:    #1c2029;
    --surface-3:    #262b36;
    --hover:        rgba(255, 255, 255, 0.04);

    --border:        rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.12);

    --text:         #f1f5f9;
    --text-muted:   #94a3b8;
    --text-subtle:  #64748b;

    --brand:        #22c55e;
    --brand-strong: #4ade80;
    --brand-soft:   rgba(34, 197, 94, 0.14);
    --danger-soft:  rgba(239, 68, 68, 0.14);
    --warning-soft: rgba(245, 158, 11, 0.14);
    --info-soft:    rgba(14, 165, 233, 0.14);
    --crypto-soft:  rgba(247, 147, 26, 0.14);

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow:       0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg:    0 14px 32px -10px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- Base ---------- */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01';
  font-size: 14.5px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}
.h3, h3 { font-size: 24px; }
.h4, h4 { font-size: 19px; }
.h5, h5 { font-size: 16px; }

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-strong); }

.text-muted { color: var(--text-muted) !important; }
.small { font-size: 12.5px; }
.font-monospace, .font-mono { font-family: var(--font-mono); font-feature-settings: 'tnum', 'zero'; }

/* tabular numerics for money / IDs everywhere */
.money, .metric-value, td.text-end, .badge {
  font-variant-numeric: tabular-nums;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text) !important;
  font-size: 16px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  margin-right: 6px;
  box-shadow: 0 1px 2px rgba(22, 163, 74, 0.3);
}
.navbar .nav-link {
  color: var(--text-muted) !important;
  font-weight: 500;
  font-size: 13.5px;
  padding: 0.35rem 0.75rem !important;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.navbar .nav-link:hover { color: var(--text) !important; background: var(--hover); }
.navbar .nav-link.active { color: var(--text) !important; background: var(--brand-soft); }

.btn-outline-secondary {
  --bs-btn-color: var(--text-muted);
  --bs-btn-border-color: var(--border-strong);
  --bs-btn-hover-bg: var(--hover);
  --bs-btn-hover-border-color: var(--border-strong);
  --bs-btn-hover-color: var(--text);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-strong); }

.card-header, .card-footer {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  padding: 0.85rem 1.1rem;
}
.card-header strong { color: var(--text); }
.card-header { font-size: 14px; }
.card-body { padding: 1.2rem; }
@media (max-width: 575px) { .card-body { padding: 1rem; } }

/* ---------- Metric cards (Dashboard top row) ---------- */
.metric-card {
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.metric-card .card-body {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
}
.metric-card .metric-sub { margin-top: auto; }
.metric-card .metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.metric-card .metric-value {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.metric-card .metric-sub {
  font-size: 11.5px;
  margin-top: 4px;
  color: var(--text-subtle);
}

.remaining-card {
  border-width: 1.5px;
  border-color: var(--border-strong);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
}
.remaining-card.bg-success-subtle {
  background: linear-gradient(135deg, var(--brand-soft) 0%, var(--surface) 60%) !important;
  border-color: rgba(22, 163, 74, 0.2);
}
.remaining-card.bg-danger-subtle {
  background: linear-gradient(135deg, var(--danger-soft) 0%, var(--surface) 60%) !important;
  border-color: rgba(220, 38, 38, 0.2);
}

/* Semantic text colors */
.text-success { color: var(--brand) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--hover);
  --bs-table-striped-bg: transparent;
  font-size: 13.5px;
  margin-bottom: 0;
}
.table > thead {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.table > thead th {
  border-bottom: 1px solid var(--border-strong);
  padding: 0.75rem 0.85rem;
  font-weight: 600;
  background: transparent;
}
.table > tbody > tr > td {
  padding: 0.8rem 0.85rem;
  border-color: var(--border);
  vertical-align: middle;
}
.table > tbody > tr { transition: background var(--transition); }
.table > tbody > tr:hover { background: var(--hover); }
.table > tbody > tr:last-child > td { border-bottom: 0; }

/* paid row */
.table-success {
  --bs-table-bg: var(--brand-soft) !important;
  --bs-table-hover-bg: var(--brand-soft) !important;
}

.table tfoot { background: var(--surface-2); font-weight: 600; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: 13px; color: var(--text); margin-bottom: 0.4rem; }
.form-label.small { font-size: 12px; color: var(--text-muted); }

.form-control, .form-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
  outline: none;
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control-sm, .form-select-sm { padding: 0.35rem 0.6rem; font-size: 13px; border-radius: var(--radius-sm); }
.form-control-lg { font-size: 18px; padding: 0.7rem 0.9rem; font-weight: 600; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-control-color { width: 56px; padding: 4px; }

textarea.form-control { line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13.5px;
  padding: 0.5rem 0.95rem;
  transition: all var(--transition);
  letter-spacing: -0.005em;
}
.btn-sm { font-size: 12.5px; padding: 0.35rem 0.7rem; border-radius: var(--radius-sm); }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline-primary {
  color: var(--brand);
  border-color: var(--brand);
}
.btn-outline-primary:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.btn-warning:hover { background: #b45309; border-color: #b45309; color: #fff; }

.btn-outline-secondary {
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-outline-secondary:hover {
  background: var(--hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-link { color: var(--text-muted); text-decoration: none; font-weight: 500; }
.btn-link:hover { color: var(--brand); }

.btn-check:checked + .btn-outline-danger {
  background: var(--danger-soft); color: var(--danger); border-color: var(--danger);
}
.btn-check:checked + .btn-outline-success {
  background: var(--brand-soft); color: var(--brand); border-color: var(--brand);
}
.btn-check:checked + .btn-outline-warning {
  background: var(--crypto-soft); color: var(--crypto); border-color: var(--crypto);
}

.btn-group .btn { border-radius: var(--radius-sm); }
.btn-group > .btn:not(:first-child) { margin-left: -1px; }

/* ---------- Badges ---------- */
.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.3em 0.55em;
  border-radius: var(--radius-sm);
}
.bg-success    { background: var(--brand) !important; }
.bg-warning    { background: var(--warning) !important; color: #fff !important; }
.bg-danger     { background: var(--danger) !important; }
.bg-secondary  { background: var(--surface-3) !important; color: var(--text-muted) !important; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius);
  border-width: 1px;
  padding: 0.85rem 1.05rem;
  font-size: 13.5px;
}
.alert-success { background: var(--brand-soft); color: var(--brand-strong); border-color: rgba(22, 163, 74, 0.2); }
.alert-danger  { background: var(--danger-soft); color: var(--danger); border-color: rgba(220, 38, 38, 0.2); }

/* ---------- Progress ---------- */
.progress {
  background: var(--surface-2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-bar { transition: width 400ms cubic-bezier(.4, 0, .2, 1); border-radius: 999px; }

/* ---------- Brand icons + letter-mark fallback ---------- */
.brand-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 7px;
  vertical-align: middle;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.04);
}
.icon-emoji {
  font-size: 18px;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}
.letter-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  background: var(--bg, var(--text-muted));
  color: #fff;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.metric-card .metric-label .brand-icon,
.metric-card .metric-label .icon-emoji,
.metric-card .metric-label .letter-mark {
  width: 16px;
  height: 16px;
  font-size: 13px;
  border-radius: 4px;
}

/* ---------- Brand dots & cat rows ---------- */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--surface);
}
.cat-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cat-row:last-child { border-bottom: 0; }

.src-tag {
  display: inline-block;
  font-weight: 600;
  font-size: 11.5px;
  min-width: 38px;
  color: var(--text-muted);
}

.toggle { display: inline-block; width: 30px; height: 16px; border-radius: 999px; background: var(--surface-3); position: relative; vertical-align: middle; }
.toggle.on { background: var(--brand); }
.toggle::after { content:''; position:absolute; top:2px; left:2px; width:12px; height:12px; border-radius:50%; background:#fff; transition: left var(--transition); }
.toggle.on::after { left: 16px; }

/* ---------- Bills grouped by category (dashboard) ---------- */
.bill-cat-section + .bill-cat-section {
  border-top: 1px solid var(--border);
}
.bill-cat-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.1rem 0.45rem;
}
.bill-cat-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.bill-cat-name .icon-emoji { font-size: 16px; }
.bill-cat-count {
  color: var(--text-subtle);
  font-weight: 500;
  font-size: 12px;
  margin-left: 2px;
}
.bill-cat-paid {
  color: var(--brand);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.bill-cat-section > .table > tbody > tr:last-child > td {
  border-bottom: 0;
}

/* ---------- Cards page card rows ---------- */
.card-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 0.85rem;
  background: var(--surface);
  transition: border-color var(--transition), transform var(--transition);
}
.card-row:hover { border-color: var(--border-strong); }

/* ---------- Login page ---------- */
.login-shell {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  max-width: 380px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
}

/* ---------- Utilities ---------- */
.gap-2 { gap: 0.5rem !important; }
.text-end { text-align: right !important; }
.opacity-50 { opacity: 0.5; }

/* Scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }
::-webkit-scrollbar-track { background: transparent; }

/* Optional crisp dark-mode chart legends (Chart.js inherits color from canvas style) */
@media (prefers-color-scheme: dark) {
  canvas { filter: brightness(1.05); }
}
