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

:root {
  --brand:        #0284c7;
  --brand-dark:   #0369a1;
  --brand-light:  #e0f2fe;
  --brand-50:     #f0f9ff;

  --bg:           #f8fafc;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-light: #f1f5f9;

  --text-1:  #0f172a;
  --text-2:  #475569;
  --text-3:  #94a3b8;

  --green:   #22c55e; --green-bg:  #f0fdf4; --green-text:  #166534;
  --orange:  #f97316; --orange-bg: #fff7ed; --orange-text: #9a3412;
  --purple:  #a855f7; --purple-bg: #fdf4ff; --purple-text: #7e22ce;
  --rose:    #f43f5e; --rose-bg:   #fff1f2; --rose-text:   #9f1239;
  --yellow:  #eab308; --yellow-bg: #fefce8; --yellow-text: #713f12;
  --red:     #ef4444; --red-bg:    #fef2f2; --red-text:    #991b1b;
  --slate:   #64748b; --slate-bg:  #f8fafc; --slate-text:  #334155;
  --blue:    #3b82f6; --blue-bg:   #eff6ff; --blue-text:   #1e40af;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --transition: .15s ease;

  --sidebar-w: 240px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ─── Layout ─────────────────────────────────────────────── */
.app-shell { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-light);
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.logo-text { font-weight: 800; font-size: 15px; color: var(--text-1); line-height: 1.2; }
.logo-sub  { font-size: 11px; color: var(--text-3); }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--bg); color: var(--text-1); }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.nav-item .icon  { font-size: 17px; width: 20px; text-align: center; }

.sidebar-user {
  padding: 12px 8px;
  border-top: 1px solid var(--border-light);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand);
  flex-shrink: 0;
}
.user-name  { font-weight: 600; font-size: 13px; color: var(--text-1); }
.user-email { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.btn-signout {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: none; background: none;
  color: var(--text-3); font-size: 13px;
  transition: var(--transition);
  margin-top: 2px;
}
.btn-signout:hover { background: var(--red-bg); color: var(--red-text); }

.main-content { flex: 1; overflow-y: auto; }
.page { padding: 28px; max-width: 960px; margin: 0 auto; }

/* ─── Mobile header ──────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.hamburger {
  border: none; background: none;
  font-size: 20px; padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
}
.mobile-logo { font-weight: 800; font-size: 15px; }
.mobile-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.45);
}
.sidebar-drawer {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w); z-index: 50;
  background: var(--surface);
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-drawer.open { transform: translateX(0); }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .page { padding: 16px; }
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 18px 20px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-weight: 700; font-size: 15px; color: var(--text-1); }
.card-body  { padding: 18px 20px; }

/* ─── Stat cards ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.stat-value { font-size: 22px; font-weight: 800; color: var(--text-1); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.stat-sub   { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.trend      { font-size: 11px; font-weight: 600; }
.trend.up   { color: var(--red-text); }
.trend.down { color: var(--green-text); }

/* ─── Charts grid ────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 720px) { .charts-grid { grid-template-columns: 2fr 1fr; } }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 600; font-size: 13.5px;
  border: none; transition: var(--transition);
  white-space: nowrap;
}
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { background: var(--red-bg); color: var(--red-text); }
.btn-danger:hover { background: #fecaca; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text-1);
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(2,132,199,.1);
}
.form-input::placeholder { color: var(--text-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.prefix-wrap { position: relative; }
.prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-weight: 600;
}
.prefix-wrap .form-input { padding-left: 28px; }

/* ─── Category selector ──────────────────────────────────── */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 500px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }

.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--bg);
  cursor: pointer; transition: var(--transition);
}
.cat-btn:hover { background: var(--border-light); }
.cat-btn.active { border-color: var(--brand); background: var(--brand-50); }
.cat-btn .cat-emoji { font-size: 20px; }
.cat-btn .cat-label { font-size: 10px; font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.2; }
.cat-btn.active .cat-label { color: var(--brand-dark); }

/* ─── Image upload ───────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.upload-zone:hover { border-color: var(--brand); background: var(--brand-50); }
.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-text { font-size: 13px; font-weight: 500; color: var(--text-2); }
.upload-hint { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.preview-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.preview-item { position: relative; width: 72px; height: 72px; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.preview-remove {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px;
  background: var(--red-text); color: #fff;
  border-radius: 50%; border: none;
  font-size: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ─── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
}

/* ─── Expense list ───────────────────────────────────────── */
.expense-list { display: flex; flex-direction: column; }
.expense-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  cursor: pointer;
}
.expense-item:last-child { border-bottom: none; }
.expense-item:hover { background: var(--bg); }

.exp-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.exp-info { flex: 1; min-width: 0; }
.exp-title  { font-weight: 600; font-size: 13.5px; color: var(--text-1); }
.exp-sub    { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.exp-amount { font-weight: 700; font-size: 14px; text-align: right; flex-shrink: 0; }
.exp-odo    { font-size: 11px; color: var(--text-3); text-align: right; }

/* ─── Expanded detail ────────────────────────────────────── */
.exp-detail {
  padding: 14px 20px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  display: none;
}
.exp-detail.open { display: block; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.detail-label { font-size: 11px; color: var(--text-3); }
.detail-value { font-size: 13px; font-weight: 600; color: var(--text-1); margin-top: 2px; }
.detail-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.detail-images img {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: opacity var(--transition);
}
.detail-images img:hover { opacity: .8; }

/* ─── Filters bar ────────────────────────────────────────── */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text-3); }
.search-input { padding-left: 34px !important; }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 24px; color: var(--text-3); text-align: center;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Lightbox ───────────────────────────────────────────── */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.85);
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img  { max-width: 92vw; max-height: 88vh; border-radius: var(--radius); object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 50%;
  width: 36px; height: 36px;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Success toast ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: var(--text-1); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(12px);
  transition: all .3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ─── Page header ────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 12px; }
.page-title  { font-size: 22px; font-weight: 800; color: var(--text-1); }
.page-sub    { font-size: 13px; color: var(--text-3); margin-top: 3px; }

/* ─── Section spacing ────────────────────────────────────── */
.section { margin-bottom: 22px; }

/* ─── Table ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 11px 16px;
  background: var(--bg);
  color: var(--text-3); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table tfoot td { font-weight: 700; background: var(--bg); }

/* ─── Progress bar ───────────────────────────────────────── */
.progress-bar { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }

/* ─── Spinner ────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { display: flex; justify-content: center; padding: 48px; }

/* ─── Login page ─────────────────────────────────────────── */
.login-shell {
  min-height: 100dvh;
  background: linear-gradient(135deg, #0c4a6e 0%, #0284c7 60%, #1e3a5f 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  overflow: hidden;
  width: 100%; max-width: 880px;
  display: grid; grid-template-columns: 1fr 1fr;
}
@media (max-width: 640px) { .login-card { grid-template-columns: 1fr; } }

.login-left {
  background: linear-gradient(160deg, #0284c7, #0369a1);
  padding: 40px 36px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff;
}
.login-right { padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
@media (max-width: 640px) { .login-left { display: none; } }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-brand-icon { width: 44px; height: 44px; background: rgba(255,255,255,.2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.login-brand-name { font-size: 22px; font-weight: 800; }

.login-title { font-size: 28px; font-weight: 800; line-height: 1.25; margin-bottom: 10px; }
.login-desc  { font-size: 14px; opacity: .8; line-height: 1.6; }

.feature-list { margin-top: 32px; display: flex; flex-direction: column; gap: 14px; }
.feature-item { display: flex; align-items: flex-start; gap: 12px; }
.feature-icon { width: 32px; height: 32px; background: rgba(255,255,255,.15); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; }
.feature-text .f-title { font-weight: 600; font-size: 13px; }
.feature-text .f-desc  { font-size: 12px; opacity: .75; margin-top: 1px; }

.login-form-title { font-size: 24px; font-weight: 800; color: var(--text-1); margin-bottom: 6px; }
.login-form-sub   { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }

.btn-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  background: var(--surface); color: var(--text-1);
  cursor: pointer; transition: var(--transition);
}
.btn-google:hover { background: var(--bg); }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.btn-email { width: 100%; }
.login-terms { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 20px; }
