/* ====================== Hermes Finance — Design System ====================== */
:root {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --surface: #161b27;
  --surface-2: #1c2230;
  --surface-3: #232a3a;
  --border: #28304180;
  --border-solid: #2a3344;
  --text: #e6e9f0;
  --text-dim: #9aa4b8;
  --text-faint: #6b7689;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #d946ef 120%);
  --income: #34d399;
  --income-bg: #34d39918;
  --expense: #fb7185;
  --expense-bg: #fb718518;
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, #6366f120, transparent),
    radial-gradient(900px 500px at -10% 20%, #8b5cf615, transparent),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-solid);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #6366f130; }
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid var(--bg); }
::placeholder { color: var(--text-faint); }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: linear-gradient(180deg, #11151fcc, #0d111a);
  border-right: 1px solid var(--border); padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 20px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand-grad);
  display: grid; place-items: center; font-weight: 800; color: white; font-size: 19px;
  box-shadow: 0 8px 20px -6px #6366f1aa;
}
.brand b { font-size: 16px; letter-spacing: -.2px; }
.brand small { color: var(--text-faint); font-size: 11px; display: block; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-faint); padding: 14px 12px 6px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; transition: all .14s; font-size: 13.5px;
}
.nav-item .ic { font-size: 17px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); }
.nav-item.active .ic { filter: drop-shadow(0 0 8px #8b5cf6aa); }
.sidebar .spacer { flex: 1; }
.scope-pill {
  margin: 4px 8px; padding: 4px; background: var(--surface-2); border-radius: 12px; display: flex; gap: 3px;
  border: 1px solid var(--border);
}
.scope-pill button { flex: 1; padding: 7px; border-radius: 9px; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.scope-pill button.on { background: var(--brand-grad); color: white; }
.scope-pill button:disabled { opacity: .5; cursor: not-allowed; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #0b0e14cc; backdrop-filter: blur(14px); z-index: 30;
}
.topbar h1 { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.topbar .grow { flex: 1; }
.ticker { display: flex; gap: 16px; align-items: center; }
.ticker .q { display: flex; flex-direction: column; line-height: 1.15; }
.ticker .q b { font-size: 13px; }
.ticker .q span { font-size: 10.5px; color: var(--text-faint); }
.ticker .up { color: var(--income); } .ticker .down { color: var(--expense); }
.month-nav { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 4px; border: 1px solid var(--border); }
.month-nav button { width: 30px; height: 30px; border-radius: 7px; color: var(--text-dim); font-size: 16px; }
.month-nav button:hover { background: var(--surface-3); color: var(--text); }
.month-nav b { min-width: 130px; text-align: center; font-size: 13px; text-transform: capitalize; }

.content { padding: 26px 28px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px; transition: all .15s; border: 1px solid transparent; }
.btn-primary { background: var(--brand-grad); color: white; box-shadow: 0 8px 20px -8px #6366f1cc; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); border-color: var(--border-solid); color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; }
.btn-danger { color: var(--expense); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.card .sub { font-size: 12px; color: var(--text-faint); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.kpi { position: relative; overflow: hidden; }
.kpi .ic { position: absolute; right: 16px; top: 16px; font-size: 30px; opacity: .25; }
.kpi .lbl { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.kpi .val { font-size: 27px; font-weight: 750; letter-spacing: -.5px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; margin-top: 6px; color: var(--text-faint); }
.kpi.income .val { color: var(--income); } .kpi.expense .val { color: var(--expense); }
.kpi-bar { height: 3px; border-radius: 3px; margin-top: 14px; background: var(--surface-3); overflow: hidden; }
.kpi-bar i { display: block; height: 100%; border-radius: 3px; }

/* ---------- Table ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.amt-in { color: var(--income); } .amt-out { color: var(--expense); }
.tag-pill { font-size: 10.5px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: #05070bcc; backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border-solid); border-radius: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2,.9,.3,1.2); }
.modal.lg { max-width: 920px; }
@keyframes pop { from { transform: scale(.96) translateY(10px); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
.close-x { width: 32px; height: 32px; border-radius: 9px; color: var(--text-dim); font-size: 20px; }
.close-x:hover { background: var(--surface-3); color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.one { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.seg { display: flex; gap: 0; background: var(--surface-2); border-radius: 10px; padding: 4px; border: 1px solid var(--border-solid); }
.seg button { flex: 1; padding: 9px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-dim); }
.seg button.on { color: white; }
.seg button.on.exp { background: var(--expense); } .seg button.on.inc { background: var(--income); color: #06281d; } .seg button.on.tr { background: var(--brand); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; width: 100%; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card .logo { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 20px; background: var(--brand-grad); display: grid; place-items: center; font-size: 30px; font-weight: 800; color: white; box-shadow: 0 16px 40px -10px #6366f1aa; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card p { color: var(--text-dim); margin-bottom: 26px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 8px; }
.err { color: var(--expense); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-faint); }
.empty .big { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.legend { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.legend .row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.legend .row .nm { color: var(--text-dim); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend .row b { font-variant-numeric: tabular-nums; }
.progress { height: 7px; background: var(--surface-3); border-radius: 5px; overflow: hidden; margin-top: 7px; }
.progress i { display: block; height: 100%; border-radius: 5px; transition: width .4s; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--text-faint); }
.right { text-align: right; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-3); border: 1px solid var(--border-solid); padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 200; font-weight: 500; animation: pop .25s; }
.toast.ok { border-color: #34d39955; } .toast.bad { border-color: #fb718555; }
.spin { width: 34px; height: 34px; border: 3px solid var(--surface-3); border-top-color: var(--brand); border-radius: 50%; animation: rot 0.8s linear infinite; margin: 40px auto; }
@keyframes rot { to { transform: rotate(360deg); } }
.badge-soon { font-size: 9px; background: var(--surface-3); padding: 2px 6px; border-radius: 5px; color: var(--text-faint); }
canvas { max-width: 100%; }
.conf-hi { color: var(--income); } .conf-lo { color: var(--warn); }
.mobile-menu { display: none; }

/* ---------- Dropdown custom (bandeira) ---------- */
.dropdown { position: relative; }
.dd-toggle { width: 100%; display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); padding: 8px 12px; min-height: 42px; color: var(--text); transition: border-color .15s; }
.dd-toggle:hover { border-color: var(--brand); }
.dd-caret { margin-left: auto; color: var(--text-faint); font-size: 11px; }
.dd-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface-3); border: 1px solid var(--border-solid); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 20; max-height: 260px; overflow: auto; padding: 5px; }
.dd-opt { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 500; }
.dd-opt:hover { background: var(--surface-2); }
.dd-opt svg, .dd-toggle svg { flex-shrink: 0; border-radius: 3px; }
.brand-badge { display: inline-flex; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2,1fr); } .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .mobile-menu { display: grid; }
  .ticker { display: none; }
  .cols-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 60px; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
}
