/* === Variables === */
:root {
  --c-bg: #f0f4f8;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #1a202c;
  --c-muted: #718096;
  --c-income: #16a34a;
  --c-expense: #dc2626;
  --c-transfer: #2563eb;
  --c-exchange: #7c3aed;
  --c-accent: #16a34a;
  --c-accent-dark: #15803d;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / .10), 0 1px 2px -1px rgb(0 0 0 / .10);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .10), 0 2px 4px -2px rgb(0 0 0 / .10);
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
}

/* === Base === */
body {
  background-color: var(--c-bg) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--c-text);
  font-size: 0.9375rem;
}

a { text-decoration: none; }

/* === Navbar === */
.navbar-money {
  background: #166534 !important;
  box-shadow: var(--shadow);
  padding: 0.5rem 1.25rem;
}
.navbar-money .navbar-brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: #fff !important;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.navbar-money .nav-link {
  color: rgba(255,255,255,.80) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.375rem 0.625rem !important;
  border-radius: var(--radius-sm);
  transition: background .15s, color .15s;
}
.navbar-money .nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,.15);
}
.navbar-money .dropdown-menu {
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: .375rem;
  min-width: 200px;
}
.navbar-money .dropdown-item {
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: .875rem;
  padding: .45rem .75rem;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-money .dropdown-item:hover {
  background: #f0fdf4;
  color: var(--c-accent);
}
.navbar-money .dropdown-divider { margin: .375rem 0; }
.navbar-money .user-chip {
  font-size: .8125rem;
  color: rgba(255,255,255,.6) !important;
  cursor: default;
  padding: .375rem .625rem !important;
}

/* === Page content === */
.page-content {
  padding: 1.25rem 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* === Cards === */
.card {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  background: var(--c-surface);
}

/* === Toolbar === */
.page-toolbar {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .625rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  justify-content: space-between;
}
.toolbar-left  { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar-right { display: flex; align-items: center; gap: .5rem; }

/* === Filter pills === */
.filter-pill {
  font-size: .8125rem;
  font-weight: 500;
  padding: .3rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  background: transparent;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.filter-pill:hover            { border-color: var(--c-accent); color: var(--c-accent); }
.filter-pill.pill-active        { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.filter-pill.pill-active-mp     { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.filter-pill.pill-active-draft  { background: #b45309; border-color: #b45309; color: #fff; }
.filter-pill.pill-active-search { background: #0f766e; border-color: #0f766e; color: #fff; display: inline-flex; align-items: center; }
.filter-pill.pill-active-search a { color: #fff; text-decoration: none; }

/* === Search input === */
.search-input-wrap { position: relative; }
.search-input-icon {
  position: absolute; left: .6rem; top: 50%; transform: translateY(-50%);
  font-size: .85rem; color: var(--c-muted); pointer-events: none; z-index: 1;
}
.search-input { padding-left: 2rem !important; }
.search-input.has-clear { padding-right: 1.6rem !important; }
.search-clear-btn {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  color: var(--c-muted); text-decoration: none; font-size: 1.1rem; line-height: 1;
}
.search-clear-btn:hover { color: var(--c-text); }

/* === Moves group === */
.moves-date-header {
  font-size: .72rem;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 1.25rem 0 .4rem .25rem;
}
.moves-card {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* === Move row === */
.move-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
  transition: background .1s;
}
.move-row:last-child  { border-bottom: none; }
.move-row:hover       { background: #f8fafc; }
.move-row-selected    { background: #f0fdf4 !important; }
.move-select          { display: flex; align-items: center; padding-right: .5rem; }

.move-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.mi-expense  { background: #fef2f2; color: var(--c-expense); }
.mi-income   { background: #f0fdf4; color: var(--c-income);  }
.mi-transfer { background: #eff6ff; color: var(--c-transfer);}
.mi-exchange { background: #f5f3ff; color: var(--c-exchange);}

.move-body        { flex: 1; min-width: 0; }
.move-title       { font-size: .875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--c-text); }
.move-subtitle    { font-size: .72rem; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }

.move-right       { text-align: right; flex-shrink: 0; }
.move-amount-val  { font-size: .9375rem; font-weight: 600; }
.move-amount-sub  { font-size: .7rem; color: var(--c-muted); margin-top: .1rem; }
.col-expense      { color: var(--c-expense); }
.col-income       { color: var(--c-income);  }
.col-neutral      { color: var(--c-text);    }

/* === Draft / Review badges === */
.badge-draft {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* === Planned expenses === */
.planned-row {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  padding: .6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: .5rem;
  font-size: .875rem;
}
.planned-row a { color: var(--c-text); font-weight: 500; }

/* === Forms === */
.form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.form-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  margin-bottom: .5rem;
}
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}
.form-control, .form-select {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: .9375rem !important;
  padding: .5rem .75rem !important;
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--c-accent) !important;
  box-shadow: 0 0 0 3px rgba(22,163,74,.12) !important;
  outline: none;
}
.search-input {
  padding-left: 2rem !important;
}
.input-amount {
  font-size: 1.625rem !important;
  font-weight: 700 !important;
  padding: .625rem 1rem !important;
  text-align: right;
  letter-spacing: -.01em;
}

/* Type toggle */
.type-toggle { display: inline-flex; gap: .375rem; }
.type-toggle .btn {
  font-weight: 600;
  font-size: .8125rem;
  padding: .35rem .9rem;
  border-radius: var(--radius-sm) !important;
  transition: all .15s;
}
.type-toggle .btn-check:checked + .btn-outline-danger {
  background: var(--c-expense);
  border-color: var(--c-expense);
  color: #fff;
}
.type-toggle .btn-check:checked + .btn-outline-success {
  background: var(--c-income);
  border-color: var(--c-income);
  color: #fff;
}

/* === Quick-pick sidebar === */
.quickpick-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.quickpick-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-muted);
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quickpick-item {
  display: block;
  font-size: .8125rem;
  color: var(--c-text);
  padding: .3rem .5rem;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.quickpick-item:hover {
  background: #f0fdf4;
  color: var(--c-accent);
  text-decoration: none;
}

/* Tom Select overrides */
.ts-wrapper .ts-control {
  border: 1px solid var(--c-border) !important;
  border-radius: var(--radius-sm) !important;
  font-size: .9375rem !important;
  min-height: calc(1.5em + 1rem + 2px);
  box-shadow: none !important;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--c-accent) !important;
  box-shadow: 0 0 0 3px rgba(22,163,74,.12) !important;
}

/* === Pagination === */
.pagination { gap: .2rem; }
.pagination .page-link {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: .875rem;
  padding: .375rem .75rem;
}
.pagination .page-item.active .page-link {
  background: var(--c-accent);
  border-color: var(--c-accent);
}

/* === Alerts === */
.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
  border-radius: var(--radius-sm);
  font-size: .875rem;
}
.alert-danger {
  border-radius: var(--radius-sm);
  font-size: .875rem;
}

/* === Mobile bottom nav === */
.mobile-bottom-nav { display: none; }

@media (max-width: 767.98px) {
  body { padding-bottom: 5rem; }

  .page-content { padding: .75rem .75rem 1rem; }

  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1030;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
    height: 4rem;
    align-items: center;
    justify-content: space-around;
    padding: 0 .5rem;
  }
  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    color: var(--c-muted);
    text-decoration: none;
    font-size: .625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: .25rem .625rem;
    border-radius: var(--radius-sm);
    transition: color .15s;
    min-width: 3rem;
  }
  .mobile-nav-link i { font-size: 1.25rem; line-height: 1; }
  .mobile-nav-link:hover, .mobile-nav-link.active { color: var(--c-accent); }
  .mobile-nav-fab {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--c-accent);
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(22,163,74,.45);
    font-size: 0 !important;
    margin-bottom: 1rem;
    flex-direction: row !important;
    letter-spacing: 0;
    text-transform: none;
    min-width: unset;
    padding: 0;
  }
  .mobile-nav-fab i { font-size: 1.5rem !important; }
  .mobile-nav-fab:hover { background: var(--c-accent-dark); color: #fff !important; }

  .filter-pills-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-pills-scroll::-webkit-scrollbar { display: none; }
  .filter-pills-scroll .filter-pill { white-space: nowrap; }

  .page-toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-left { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .toolbar-right { width: 100%; justify-content: flex-end; }
}

/* === Bills table === */
.bills-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.bills-table th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-muted);
  padding: .625rem 1rem;
  border-bottom: 2px solid var(--c-border);
  white-space: nowrap;
  background: var(--c-surface);
}
.bills-table th.col-amount { text-align: right; }
.bills-table td {
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--c-border);
  font-size: .9rem;
  vertical-align: middle;
}
.bills-table td.col-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: .875rem;
}
.bills-table tbody tr { cursor: pointer; transition: background .1s; }
.bills-table tbody tr:hover { background: #f8fafc; }
.bills-table tfoot td {
  font-weight: 700;
  font-size: .875rem;
  border-top: 2px solid var(--c-border);
  border-bottom: none;
  padding: .75rem 1rem;
}
.bills-table tfoot td.col-amount { text-align: right; }

.bill-name { font-weight: 500; }
.bill-owner { font-size: .75rem; color: var(--c-muted); }
.amount-zero { color: var(--c-muted); }

/* === Detail card === */
.detail-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.detail-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.detail-amount {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
}
.detail-meta { font-size: .8125rem; color: var(--c-muted); margin-top: .35rem; }
.detail-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.detail-body { padding: 0; }
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: .625rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
  font-size: .9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-muted);
  flex: 0 0 6.5rem;
}
.detail-value { color: var(--c-text); }
.detail-value a { color: var(--c-accent); }
.detail-value a:hover { text-decoration: underline; }

/* === Split operation === */
.split-toggle-btn {
  font-size: .8125rem;
  font-weight: 600;
  padding: .3rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  background: transparent;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.4;
}
.split-toggle-btn:hover    { border-color: var(--c-accent); color: var(--c-accent); }
.split-toggle-btn.active   { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

.split-section {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: .875rem;
  margin-top: .25rem;
}
.split-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: .5rem;
}
.split-row select, .split-row input[type=number], .split-row input[type=text] {
  font-size: .875rem !important;
  padding: .4rem .65rem !important;
}
.split-row .split-cat  { flex: 1; min-width: 0; }
.split-row .split-amt  { width: 8rem; flex-shrink: 0; }
.split-row .split-rest { flex-shrink: 0; font-size: .75rem; color: var(--c-accent); cursor: pointer; white-space: nowrap; padding: .3rem .5rem; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: #fff; }
.split-row .split-rest:hover { background: #f0fdf4; }
.split-row .split-del  { flex-shrink: 0; color: var(--c-muted); cursor: pointer; font-size: 1rem; line-height: 1; background: none; border: none; padding: .2rem .35rem; border-radius: var(--radius-sm); }
.split-row .split-del:hover { color: var(--c-expense); background: #fef2f2; }

.split-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .8125rem;
  padding-top: .625rem;
  border-top: 1px solid var(--c-border);
  margin-top: .25rem;
}
.split-stats .stat-label { color: var(--c-muted); }
.split-stats .stat-val   { font-weight: 600; }
.split-stats .stat-ok    { color: var(--c-income); }
.split-stats .stat-warn  { color: #d97706; }
