/* ============================================================
   Budget App – Main Stylesheet
   ============================================================ */

/* ---- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --primary:     #3b82f6;
  --primary-dk:  #2563eb;
  --danger:      #ef4444;
  --success:     #22c55e;
  --warning:     #f59e0b;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --nav-h:       58px;
}

html { font-size: 16px; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

.navbar-brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; }

.navbar-nav {
  display: flex;
  gap: .25rem;
  list-style: none;
  flex-wrap: wrap;
}

.navbar-nav a {
  display: block;
  padding: .4rem .85rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .925rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.navbar-nav a:hover,
.navbar-nav a.active {
  background: #eff6ff;
  color: var(--primary);
  text-decoration: none;
}

.navbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}

.navbar-username {
  font-size: .875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Layout ----------------------------------------------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ---- Cards ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: .8rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Stat card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.stat-card .stat-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .35rem;
}
.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
.stat-card .stat-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ---- Tables ----------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

thead th {
  background: #f8fafc;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: .7rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: .93rem;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.col-amount { text-align: right; font-variant-numeric: tabular-nums; }
.col-date   { white-space: nowrap; }
.col-actions { text-align: center; white-space: nowrap; }

/* ---- Badges ----------------------------------------------- */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  white-space: nowrap;
}

/* ---- Forms ------------------------------------------------ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .925rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { opacity: .88; text-decoration: none; }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm       { padding: .3rem .75rem; font-size: .8rem; }

/* ---- Alerts ----------------------------------------------- */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .925rem;
  font-weight: 500;
}
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

/* ---- Category color dot ----------------------------------- */
.cat-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: .4rem;
  flex-shrink: 0;
}

/* ---- Progress bar ----------------------------------------- */
.progress {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width .3s;
}

/* ---- Category breakdown list ------------------------------ */
.category-list { list-style: none; }
.category-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: .925rem;
}
.category-list li:last-child { border-bottom: none; }
.category-list .cat-name { flex: 1; }
.category-list .cat-total { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Filter bar ------------------------------------------- */
.filter-bar {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 150px; }

/* ---- Upload zone ------------------------------------------ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  background: #f8fafc;
  transition: border-color .2s, background .2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}
.upload-zone input[type="file"] {
  display: none;
}
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-zone p { margin-top: .4rem; font-size: .9rem; }

/* ---- Footer ----------------------------------------------- */
.site-footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---- Utilities -------------------------------------------- */
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.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; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 640px) {
  .navbar { gap: 1rem; }
  .navbar-nav a { padding: .35rem .6rem; font-size: .85rem; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value { font-size: 1.3rem; }
}
