/* ============================================
   ORGANIZZE-STYLE — Global CSS
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────── */
:root {
  --bg:           #0f1117;
  --bg2:          #161b27;
  --sidebar-bg:   #111827;
  --surface:      rgba(255,255,255,0.05);
  --surface-hover:rgba(255,255,255,0.08);
  --border:       rgba(255,255,255,0.08);
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,.15);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,.15);
  --blue:         #6366f1;
  --blue-dim:     rgba(99,102,241,.15);
  --yellow:       #f59e0b;
  --orange:       #f97316;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 4px 20px rgba(0,0,0,.4);
  --sidebar-w:    240px;
  --transition:   .2s ease;
}

/* ── Light theme ─────────────────────────────── */
body.light {
  --bg:           #f1f5f9;
  --bg2:          #e9eef5;
  --sidebar-bg:   #1e2840;
  --surface:      rgba(0,0,0,0.04);
  --surface-hover:rgba(0,0,0,0.07);
  --border:       rgba(0,0,0,0.1);
  --text:         #0f172a;
  --text-muted:   #475569;
  --text-dim:     #94a3b8;
  --shadow:       0 4px 20px rgba(0,0,0,.12);
}
body.light .sidebar { background: var(--sidebar-bg) }
body.light .topbar  { background: var(--bg); border-bottom-color: var(--border) }
body.light .chart-card, body.light .card { background: #fff; border-color: var(--border) }
body.light .tx-item { background: #fff; border-color: var(--border) }
body.light .summary-card { background: #fff }
body.light input, body.light select, body.light textarea { background: #fff; color: var(--text); border-color: var(--border) }

/* ── Theme toggle button ─────────────────────── */
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .3rem .75rem;
  font-size: .82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; gap: .4rem;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text) }

/* ── Reset ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Layout ──────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0; top: 0;
  z-index: 1000;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
}
.sidebar.mobile-open + .sidebar-overlay {
  display: block;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--blue), #818cf8);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.sidebar-logo .logo-sub {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .1rem;
}
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  padding: .5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}
.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: .75rem 1.25rem .25rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 500;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--blue);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  font-weight: 600;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--text-muted); }
.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: .85rem;
  padding: .25rem;
  transition: color var(--transition);
  flex-shrink: 0;
}
.sidebar-logout:hover { color: var(--red); }

/* ── Main ────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  padding: .25rem;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.page-body { padding: 1.75rem 2rem; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  border: none;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary  { background: var(--blue); color: #fff; }
.btn-green    { background: var(--green); color: #fff; }
.btn-red      { background: var(--red); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--surface-hover); color: var(--text); }
.btn-icon     { padding: .45rem .55rem; }
.btn-sm       { padding: .35rem .7rem; font-size: .8rem; }

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card-sm { padding: 1rem 1.25rem; }

/* ── Summary Row ─────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  position: relative;
  overflow: hidden;
}
.summary-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.summary-card.income::before  { background: var(--green); }
.summary-card.expense::before { background: var(--red); }
.summary-card.balance::before { background: var(--blue); }
.summary-card.neutral::before { background: var(--yellow); }
.summary-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.summary-value { font-size: 1.6rem; font-weight: 700; }
.summary-value.green  { color: var(--green); }
.summary-value.red    { color: var(--red); }
.summary-value.blue   { color: var(--blue); }
.summary-icon { font-size: 1.4rem; }

/* ── Transaction List ───────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: .5rem; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  transition: background var(--transition);
}
.tx-item:hover { background: var(--surface-hover); }
.tx-cat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-title { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta  { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.tx-amount { font-size: 1rem; font-weight: 700; }
.tx-amount.income   { color: var(--green); }
.tx-amount.expense  { color: var(--red); }
.tx-amount.transfer { color: var(--blue); }
.tx-actions { display: flex; gap: .35rem; }

/* Status badge */
.status-badge {
  font-size: .68rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 999px;
}
.status-badge.paid      { background: var(--green-dim); color: var(--green); }
.status-badge.pending   { background: rgba(245,158,11,.15); color: var(--yellow); }
.status-badge.cancelled { background: rgba(239,68,68,.12); color: var(--red); }

/* Pills / badges */
.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: .15rem .5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-income   { background: var(--green-dim);  color: var(--green); }
.badge-expense  { background: var(--red-dim);    color: var(--red); }
.badge-transfer { background: var(--blue-dim);   color: var(--blue); }
.badge-card     { background: rgba(239,68,68,.12); color: #fb7185; }

/* ── Month Navigator ─────────────────────────── */
.month-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .9rem;
}
.month-nav span { font-size: .9rem; font-weight: 600; min-width: 120px; text-align: center; }
.month-nav button { background: none; border: none; color: var(--text-muted); font-size: 1rem; transition: color var(--transition); padding: .2rem .4rem; border-radius: 4px; }
.month-nav button:hover { color: var(--text); background: var(--surface-hover); }

/* ── Forms / Modal ───────────────────────────── */
dialog {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  /* Force true centered positioning in viewport */
  position: fixed;
  inset: 0;
  margin: auto;
}
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
dialog.modal-lg { max-width: 650px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: color var(--transition);
  padding: .25rem;
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
label { font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .65rem .85rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: .9rem;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}
select option { background: #1e293b; }

/* Type selector tabs */
.type-tabs { display: flex; gap: .5rem; }
.type-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: .55rem;
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition);
  text-align: center;
}
.type-tab.active-income   { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.type-tab.active-expense  { background: var(--red-dim);   color: var(--red);   border-color: var(--red); }
.type-tab.active-transfer { background: var(--blue-dim);  color: var(--blue);  border-color: var(--blue); }

/* ── Auth Pages ──────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,.15) 0, transparent 60%),
              radial-gradient(ellipse at 80% 50%, rgba(34,197,94,.08) 0, transparent 60%),
              var(--bg);
}
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2rem;
}
.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--blue), #818cf8);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.auth-logo-name { font-size: 1.3rem; font-weight: 700; }
.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .4rem; }
.auth-sub { font-size: .88rem; color: var(--text-muted); margin-bottom: 2rem; }
.auth-card .form-group { margin-bottom: 1rem; }
.auth-card input {
  height: 44px;
}
.auth-submit {
  width: 100%;
  height: 44px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 700;
  margin-top: .5rem;
  transition: opacity var(--transition);
}
.auth-submit:hover { opacity: .88; }
.auth-link { text-align: center; font-size: .85rem; color: var(--text-muted); margin-top: 1.25rem; }
.auth-link a { color: var(--blue); font-weight: 600; }
.auth-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: .85rem;
  padding: .65rem 1rem;
  margin-bottom: 1rem;
}

/* ── Account / Card Grid ─────────────────────── */
.acc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.acc-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}
.acc-card:hover { border-color: rgba(255,255,255,.16); }
.acc-card-stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.acc-card-icon { font-size: 1.5rem; margin-bottom: .75rem; }
.acc-card-name { font-size: .9rem; font-weight: 700; margin-bottom: .25rem; }
.acc-card-type { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.acc-card-balance { font-size: 1.4rem; font-weight: 700; }
.acc-card-balance.negative { color: var(--red); }
.acc-card-balance.positive { color: var(--green); }
.acc-card-actions { margin-top: .75rem; display: flex; gap: .5rem; }

/* Credit card visual */
.credit-card-visual {
  border-radius: 16px;
  padding: 1.5rem;
  background: linear-gradient(135deg, #1e293b, #334155);
  position: relative;
  overflow: hidden;
  color: #fff;
  min-height: 160px;
  border: 1px solid var(--border);
}
.credit-card-visual::after {
  content: '◉';
  position: absolute;
  right: 1.5rem; top: 1.5rem;
  font-size: 2.5rem;
  opacity: .15;
}
.cc-chip { font-size: 1.5rem; margin-bottom: .75rem; }
.cc-name { font-size: 1.1rem; font-weight: 700; margin-bottom: .25rem; }
.cc-limit-row { display: flex; gap: 1.5rem; font-size: .8rem; color: rgba(255,255,255,.7); margin-top: auto; }
.cc-limit-row strong { color: #fff; display: block; font-size: .9rem; }
.cc-days { font-size: .75rem; background: rgba(255,255,255,.1); border-radius: 999px; padding: .2rem .6rem; display: inline-block; margin-top: .35rem; }

/* ── Charts ──────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.chart-card h3 { font-size: .9rem; font-weight: 700; margin-bottom: 1rem; }

/* ── Categories ──────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .75rem;
}
.cat-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.cat-icon { font-size: 1.4rem; width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cat-name { font-size: .88rem; font-weight: 600; flex: 1; }
.cat-type { font-size: .68rem; color: var(--text-muted); }
.cat-delete { background: none; border: none; color: var(--text-dim); font-size: .8rem; transition: color var(--transition); }
.cat-delete:hover { color: var(--red); }

/* ── Section Header ──────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.section-title { font-size: 1rem; font-weight: 700; }

/* ── Filter select ──────────────────────────── */
.filter-select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .25rem .6rem;
  font-size: .8rem;
  cursor: pointer;
}

/* ── Goals Grid ─────────────────────────────── */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 1rem; margin-bottom: 1rem; }
.goal-card { background: var(--surface); border-radius: var(--radius); padding: 1rem; }
.goal-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: .75rem; }
.btn-icon-sm { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .85rem; padding: 0; }
.goal-bar-bg { height: 8px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; margin-bottom: .5rem; }
.goal-bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.goal-footer { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-muted); }

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

/* ── Scrollbar ─────────────────────────────────*/
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 999px; }

/* ── Color picker row ─────────────────────────── */
.color-options { display: flex; gap: .5rem; flex-wrap: wrap; }
.color-opt {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.color-opt:hover, .color-opt.selected { border-color: #fff; transform: scale(1.15); }

/* ── Responsive ──────────────────────────────── */
/* ── Mobile Logic ───────────────────────────── */
.sidebar.mobile-open {
  transform: translateX(0) !important;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar-close, .menu-toggle { display: block; }
  .main-content { margin-left: 0; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { padding: .75rem 1rem; }
  .topbar-right { gap: .4rem; }
  .theme-label { display: none; }
  .page-body { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: 1fr; }
  .acc-grid { grid-template-columns: 1fr; }
  .summary-value { font-size: 1.4rem; }
  .section-header { flex-wrap: wrap; gap: .5rem; }
  /* Modal: evitar borda colada */
  dialog { width: calc(100% - 2rem); max-height: 85vh; }
  /* Ensure tables don't break layout */
  .card { overflow-x: auto; }
  table { min-width: 400px; }
}
