/* assets/css/app.css — Home Budget App */

:root {
  --green:      #1D9E75;
  --green-dark: #0F6E56;
  --green-lt:   #E1F5EE;
  --blue:       #185FA5;
  --blue-lt:    #E6F1FB;
  --red:        #A32D2D;
  --red-lt:     #FCEBEB;
  --amber:      #BA7517;
  --amber-lt:   #FAEEDA;
  --gray-50:    #F7F6F3;
  --gray-100:   #EDEDEA;
  --gray-200:   #D3D1C7;
  --gray-400:   #888780;
  --gray-700:   #444441;
  --gray-900:   #1A1A18;
  --text:       #1A1A18;
  --text-muted: #666662;
  --border:     rgba(0,0,0,0.09);
  --radius:     10px;
  --radius-lg:  14px;
  --shadow:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --font:       'Sora', sans-serif;
  --mono:       'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--gray-50);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Navbar ---- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  font-size: 1rem; font-weight: 600;
  color: var(--green-dark);
  white-space: nowrap;
  text-decoration: none;
}

.nav-month {
  display: flex; align-items: center; gap: 6px;
  margin: 0 auto;
}
.month-arrow {
  font-size: 1.4rem; line-height: 1;
  color: var(--gray-400); padding: 0 4px;
  text-decoration: none;
  transition: color .15s;
}
.month-arrow:hover { color: var(--green); text-decoration: none; }
.month-label {
  font-size: 0.875rem; font-weight: 500;
  color: var(--text); min-width: 110px; text-align: center;
}

.nav-links {
  display: flex; list-style: none; gap: 2px;
}
.nav-links a {
  display: block; padding: 5px 11px;
  font-size: 0.8125rem; font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-links a:hover  { background: var(--gray-50); color: var(--text); }
.nav-links a.active { background: var(--green-lt); color: var(--green-dark); }

.nav-user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.logout-link {
  font-size: 0.8125rem; color: var(--text-muted);
  text-decoration: none; white-space: nowrap;
}
.logout-link:hover { color: var(--red); text-decoration: none; }

.nav-toggle {
  display: none; background: none; border: none;
  font-size: 1.25rem; cursor: pointer; color: var(--text);
  padding: 4px;
}

/* Mobile nav */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-user { display: none; }
  .nav-toggle { display: flex; align-items: center; justify-content: center; margin-left: auto; flex-shrink: 0; width: 36px; height: 36px; }
  .nav-month { margin-left: 0; }
  .navbar { gap: 0.5rem; padding: 0 1rem; justify-content: space-between; }
  body.nav-open .nav-links {
    display: flex; flex-direction: column;
    position: fixed; top: 56px; left: 0; right: 0;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    z-index: 99;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
  }
  body.nav-open .nav-links li { width: 100%; }
  body.nav-open .nav-links a { padding: 12px 14px; border-radius: var(--radius); font-size: 1rem; }
  body.nav-open .nav-links a.active { background: var(--green-lt); color: var(--green-dark); }
}

/* ---- Layout ---- */
.content-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}
@media (max-width: 480px) {
  .content-wrap { padding: 1rem 0.75rem; }
}

/* ---- Flash ---- */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 1.25rem; font-size: 0.875rem; font-weight: 500;
}
.flash button { background: none; border: none; cursor: pointer; font-size: 0.875rem; opacity: .6; }
.flash-success { background: var(--green-lt); color: var(--green-dark); }
.flash-error   { background: var(--red-lt);   color: var(--red); }
.flash-info    { background: var(--blue-lt);   color: var(--blue); }

/* ---- Cards ---- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-size: 0.875rem; font-weight: 600;
  color: var(--text); letter-spacing: .01em;
}

/* ---- Metric cards ---- */
.metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 1.5rem; }
.metrics-3 { grid-template-columns: repeat(3,1fr); }
.metric {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.metric-label { font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.metric-value { font-size: 1.625rem; font-weight: 600; font-family: var(--mono); }
.metric-value.green { color: var(--green-dark); }
.metric-value.red   { color: var(--red); }
.metric-value.blue  { color: var(--blue); }
.metric-sub  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 600px) {
  .metrics, .metrics-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .metrics, .metrics-3 { grid-template-columns: 1fr; }
}

/* ---- Two col grid ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
@media (max-width: 768px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

/* ---- Transaction rows ---- */
.tx-list { display: flex; flex-direction: column; gap: 0; }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.tx-row:last-child { border-bottom: none; }
.tx-icon {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.tx-meta { font-size: 0.75rem; color: var(--text-muted); }
.tx-amount { font-family: var(--mono); font-size: 0.9375rem; font-weight: 500; white-space: nowrap; }
.tx-amount.neg { color: var(--red); }
.tx-amount.pos { color: var(--green-dark); }

/* ---- Badges ---- */
.badge {
  display: inline-block; font-size: 0.6875rem; font-weight: 500;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-income  { background: #EAF3DE; color: #3B6D11; }
.badge-expense { background: #FCEBEB; color: #791F1F; }

/* ---- Budget bars ---- */
.bbar { margin-bottom: 14px; }
.bbar-top { display: flex; justify-content: space-between; font-size: 0.8125rem; margin-bottom: 5px; }
.bbar-label { font-weight: 500; }
.bbar-amounts { color: var(--text-muted); font-family: var(--mono); font-size: 0.75rem; }
.bbar-track { height: 7px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.bbar-fill  { height: 100%; border-radius: 4px; transition: width .4s ease; }
.bbar-over  .bbar-fill { background: var(--red) !important; }

/* ---- Savings goals ---- */
.goal-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow);
}
.goal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.goal-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.goal-name { font-size: 0.9375rem; font-weight: 600; }
.goal-amounts { font-size: 0.8125rem; color: var(--text-muted); }
.goal-pct { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; color: var(--blue); }
.goal-bar-track { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.goal-bar-fill  { height: 100%; border-radius: 4px; transition: width .5s ease; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text); margin-bottom: 5px; }
.form-control {
  display: block; width: 100%;
  padding: 9px 12px;
  font-family: var(--font); font-size: 0.9375rem; color: var(--text);
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29,158,117,.15);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 70px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; font-family: var(--font); font-size: 0.875rem;
  font-weight: 500; border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--green); color: #fff; border-color: var(--green-dark); }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger   { background: var(--red-lt); color: var(--red); border-color: #f7c1c1; }
.btn-danger:hover { background: #f7c1c1; }
.btn-sm       { padding: 5px 12px; font-size: 0.8125rem; }
.btn-icon     { padding: 6px 8px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; padding: 10px 12px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.data-table td.mono { font-family: var(--mono); }

/* ---- Page title ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title { font-size: 1.25rem; font-weight: 600; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }
.filter-bar label { font-size: 0.75rem; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  padding: 1.5rem; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  position: relative;
}
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.25rem;
  cursor: pointer; color: var(--text-muted);
}
.modal-close:hover { color: var(--red); }

/* ---- Receipt preview ---- */
.receipt-thumb {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer;
}

/* ---- Login page ---- */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--gray-50);
}
.login-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
}
.login-title { font-size: 1.375rem; font-weight: 600; margin-bottom: 0.25rem; }
.login-sub   { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ---- Utility ---- */
.text-muted  { color: var(--text-muted); }
.text-green  { color: var(--green-dark); }
.text-red    { color: var(--red); }
.text-right  { text-align: right; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: .5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---- Charts canvas ---- */
canvas { max-width: 100%; }

/* ---- Colour dot ---- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ---- Mobile FAB ---- */
.fab {
  display: none;
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 1.75rem; line-height: 1;
  align-items: center; justify-content: center;
  text-decoration: none; z-index: 90;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  transition: background .15s, transform .1s;
}
.fab:hover { background: var(--green-dark); transform: scale(1.06); text-decoration: none; }
@media (max-width: 768px) { .fab { display: flex; } }

/* ---- Empty state ---- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ---- Print ---- */
@media print {
  .navbar, .fab, .btn, .filter-bar { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---- Focus ---- */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- type-btn active states ---- */
.type-btn.active.btn-danger    { background: var(--red-lt); color: var(--red); border-color: #f7c1c1; }
.type-btn.active.btn-primary   { background: var(--green-lt); color: var(--green-dark); border-color: var(--green); }

/* ---- Transactions table: hide less critical columns on mobile ---- */
@media (max-width: 600px) {
  .data-table .col-user,
  .data-table .col-receipt,
  .data-table .col-note { display: none; }
}
@media (max-width: 480px) {
  .data-table .col-type { display: none; }
}
