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

:root{
  --bg:#faf7f2; --surface:#ffffff; --surface-2:#f3ede4;
  --ink:#211c16; --ink-2:#6b6156; --ink-muted:#9c9284;
  --border:rgba(33,28,22,0.10); --border-strong:rgba(33,28,22,0.16);
  --primary:#c1622f; --primary-soft:#f3e2d4; --primary-deep:#96491f;
  --expense:#c23b2c; --income:#1f7a53;
  --cat-1:#2a78d6; --cat-2:#eb6834; --cat-3:#1baf7a; --cat-4:#eda100;
  --cat-5:#e87ba4; --cat-6:#008300; --cat-7:#4a3aa7; --cat-8:#e34948;
  --radius-s:10px; --radius-m:16px; --radius-l:24px; --radius-full:999px;
  --shadow-card: 0 1px 2px rgba(33,28,22,0.04), 0 6px 16px -8px rgba(33,28,22,0.12);
}
*{box-sizing:border-box;scrollbar-width:none;-ms-overflow-style:none;}
*::-webkit-scrollbar{display:none;width:0;height:0;}
html,body{height:100%;}
body{
  margin:0 auto;background:var(--bg);color:var(--ink);
  font-family:"Manrope",system-ui,sans-serif;-webkit-font-smoothing:antialiased;
  max-width:480px;position:fixed;left:0;right:0;top:0;
  height:var(--app-vh,100vh);overflow:hidden;
}
h1,h2,.amt{font-family:"Sora",system-ui,sans-serif;}
button,input,select{font-family:inherit;}
[hidden]{display:none !important;}
.scroll{overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none;}
.scroll::-webkit-scrollbar{display:none;width:0;height:0;}

/* ---- shared bits ---- */
.icon{stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.btn{font-weight:700;font-size:15px;border:none;border-radius:var(--radius-full);padding:14px 22px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;}
.btn-primary{background:var(--primary);color:#fff;}
.btn-primary:disabled{opacity:.5;}
.btn-secondary{background:var(--surface-2);color:var(--ink);}
.field{background:var(--surface);border:1.5px solid var(--border-strong);border-radius:var(--radius-m);padding:12px 14px;width:100%;margin-bottom:12px;}
.field label{font-size:11.5px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--ink-muted);display:block;margin-bottom:4px;}
.field input, .field select{border:none;background:transparent;font-size:16px;color:var(--ink);width:100%;outline:none;padding:0;-webkit-appearance:none;appearance:none;}
.field:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft);}
.seg{display:flex;background:var(--surface-2);border-radius:var(--radius-full);padding:4px;gap:2px;margin-bottom:16px;}
.seg button{flex:1;padding:10px;border:none;background:transparent;border-radius:var(--radius-full);font-size:13.5px;font-weight:700;color:var(--ink-2);cursor:pointer;}
.seg button.on{background:var(--surface);color:var(--ink);box-shadow:0 1px 2px rgba(33,28,22,.08);}
.error{color:var(--expense);font-size:13px;margin:-4px 0 12px;min-height:16px;}

/* ---- boot loader ---- */
.boot-loader{position:fixed;inset:0;background:var(--bg);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;z-index:50;}
.boot-mark{width:52px;height:52px;border-radius:var(--radius-m);background:var(--primary);color:#fff;display:flex;align-items:center;justify-content:center;font-family:"Sora";font-size:24px;font-weight:700;}
.boot-spin{width:22px;height:22px;border-radius:50%;border:3px solid var(--border-strong);border-top-color:var(--primary);animation:boot-spin .7s linear infinite;}
@keyframes boot-spin{to{transform:rotate(360deg);}}

/* ---- screens ---- */
.screen{position:absolute;inset:0;background:var(--bg);display:flex;flex-direction:column;}
.screen.top{padding:24px 20px;justify-content:center;height:100%;position:static;overflow-y:auto;}

/* ---- login ---- */
.login-card{max-width:340px;margin:0 auto;width:100%;}
.login-card h1{font-size:24px;margin:0 0 2px;}
.login-card p{color:var(--ink-2);font-size:14px;margin:0 0 28px;}

/* ---- dashboard ---- */
.top-bar{padding:20px 20px 0;flex-shrink:0;}
.top-bar-row{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px;}
.greet{font-size:13px;color:var(--ink-2);margin:0;}
.name{font-size:19px;font-weight:700;font-family:"Sora";margin:2px 0 0;}
.dash-avatar{width:44px;height:44px;border-radius:50%;object-fit:cover;background:var(--surface-2);flex-shrink:0;cursor:pointer;}
.hero{background:var(--ink);color:#fff;border-radius:var(--radius-l);padding:20px;margin:0 20px;box-shadow:var(--shadow-card);flex-shrink:0;}
.hero .lbl{font-size:12px;color:rgba(255,255,255,.6);font-weight:600;text-transform:uppercase;letter-spacing:.06em;}
.hero .val{font-family:"Sora";font-weight:700;font-size:30px;margin:6px 0 14px;}
.hero .split{display:flex;gap:18px;}
.hero .split div{font-size:12px;color:rgba(255,255,255,.75);}
.hero .split b{display:block;color:#fff;font-family:"Sora";font-size:14px;font-weight:600;margin-top:2px;}
.accts{display:flex;gap:10px;overflow-x:auto;padding:16px 20px 4px;flex-shrink:0;}
.acct{flex:0 0 auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-m);padding:10px 14px;display:flex;align-items:center;gap:8px;}
.dot{width:9px;height:9px;border-radius:50%;flex-shrink:0;}
.acct span{font-size:12px;font-weight:600;}
.acct b{font-family:"Sora";font-size:13px;font-weight:600;margin-left:2px;}
.acct-add{color:var(--primary);border:1px dashed var(--border-strong);background:transparent;}
.content{flex:1;overflow-y:auto;padding:0 20px 100px;}
h2.sec{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--ink-muted);margin:18px 0 12px;display:flex;justify-content:space-between;align-items:center;}
h2.sec button{background:none;border:none;color:var(--primary);font-size:12px;font-weight:700;cursor:pointer;padding:0;}
.empty{color:var(--ink-muted);font-size:13px;padding:16px 0;text-align:center;}
.cat-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;}
.cat-ic{width:32px;height:32px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;}
.cat-ic svg{width:16px;height:16px;stroke:#fff;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.cat-mid{flex:1;min-width:0;}
.cat-name{font-size:13px;font-weight:600;margin:0 0 5px;}
.bar-track{background:var(--surface-2);border-radius:99px;height:6px;overflow:hidden;}
.bar-fill{height:100%;border-radius:99px;}
.cat-amt{font-family:"Sora";font-size:13px;font-weight:600;font-variant-numeric:tabular-nums;flex-shrink:0;}
.tx{display:flex;align-items:center;gap:12px;background:var(--surface);border-radius:var(--radius-m);padding:12px;margin-bottom:8px;box-shadow:var(--shadow-card);}
.tx-ic{width:38px;height:38px;border-radius:50%;flex-shrink:0;display:flex;align-items:center;justify-content:center;}
.tx-ic svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.tx-mid{flex:1;min-width:0;}
.tx-title{font-size:13.5px;font-weight:600;margin:0 0 2px;}
.tx-sub{font-size:11.5px;color:var(--ink-muted);margin:0;}
.tx-amt{font-family:"Sora";font-weight:600;font-size:14px;font-variant-numeric:tabular-nums;flex-shrink:0;}
.tx-amt.expense{color:var(--expense);}
.tx-amt.income{color:var(--income);}

/* ---- nav + fab ---- */
.navbar{position:fixed;left:0;right:0;bottom:0;display:flex;background:var(--surface);border-top:1px solid var(--border);padding:10px 8px min(max(env(safe-area-inset-bottom,0px),10px),14px);z-index:5;}
.nb{flex:1;display:flex;flex-direction:column;align-items:center;gap:4px;color:var(--ink-muted);background:none;border:none;cursor:pointer;}
.nb svg{width:21px;height:21px;}
.nb span{font-size:10px;font-weight:700;}
.nb.on{color:var(--primary);}
.nav-brand{display:none;}
.fab{position:absolute;right:20px;bottom:78px;width:52px;height:52px;border-radius:50%;background:var(--primary);box-shadow:0 6px 18px -4px rgba(193,98,47,.5);display:flex;align-items:center;justify-content:center;border:none;cursor:pointer;z-index:6;}
.fab svg{width:22px;height:22px;stroke:#fff;fill:none;stroke-width:2.2;stroke-linecap:round;}

/* ---- add / form screen ---- */
.form-header{display:flex;align-items:center;gap:12px;padding:18px 20px;flex-shrink:0;}
.form-header button{background:var(--surface-2);border:none;width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;}
.form-header h1{font-size:18px;margin:0;}
.form-body{flex:1;overflow-y:auto;padding:0 20px 24px;}
.form-footer{padding:12px 20px calc(env(safe-area-inset-bottom,0px) + 16px);flex-shrink:0;}
.cat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:16px;}
.cat-pick{border:1.5px solid var(--border);background:var(--surface);border-radius:var(--radius-m);padding:10px 4px;display:flex;flex-direction:column;align-items:center;gap:6px;cursor:pointer;}
.cat-pick .dot{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;}
.cat-pick .dot svg{width:14px;height:14px;stroke:#fff;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.cat-pick span{font-size:10.5px;font-weight:600;text-align:center;line-height:1.2;}
.cat-pick.on{border-color:var(--primary);background:var(--primary-soft);}
.check-row{display:flex;align-items:center;gap:10px;padding:12px 0;font-size:14px;font-weight:600;}

/* ---- history ---- */
.month-nav{display:flex;align-items:center;justify-content:space-between;padding:18px 20px 4px;flex-shrink:0;}
.month-nav button{background:var(--surface-2);border:none;width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;}
.month-nav h1{font-size:16px;margin:0;text-transform:capitalize;}

/* ---- settings ---- */
.settings-row{display:flex;align-items:center;justify-content:space-between;background:var(--surface);border-radius:var(--radius-m);padding:12px 14px;margin-bottom:8px;box-shadow:var(--shadow-card);}
.settings-row .meta{font-size:13.5px;font-weight:600;}
.settings-row .sub{font-size:11.5px;color:var(--ink-muted);margin-top:2px;}
.settings-row button{background:none;border:none;color:var(--ink-muted);font-size:12px;font-weight:700;cursor:pointer;padding:4px;}
.inline-form{display:flex;flex-direction:column;gap:8px;margin:8px 0 4px;}
.inline-form input{background:var(--surface);border:1.5px solid var(--border-strong);border-radius:var(--radius-m);padding:11px 14px;font-size:14px;color:var(--ink);}
.hint{font-size:12.5px;color:var(--ink-2);margin:0 0 16px;line-height:1.5;}
textarea{width:100%;background:var(--surface);border:none;font-size:13px;color:var(--ink);resize:vertical;outline:none;font-family:inherit;}
.import-table{width:100%;border-collapse:collapse;margin:12px 0;font-size:12px;}
.import-table th{text-align:left;color:var(--ink-muted);font-weight:700;text-transform:uppercase;font-size:10px;padding:4px 6px;}
.import-table td{padding:6px;border-top:1px solid var(--border);}
.import-count{font-size:12.5px;color:var(--ink-2);margin:4px 0;}

/* ---- action sheet ---- */
.sheet-overlay{position:absolute;inset:0;background:rgba(33,28,22,.45);z-index:20;display:flex;align-items:flex-end;}
.sheet{background:var(--surface);border-radius:var(--radius-l) var(--radius-l) 0 0;padding:10px 16px calc(env(safe-area-inset-bottom,0px) + 16px);width:100%;}
.sheet-title{font-size:13px;font-weight:700;color:var(--ink-muted);padding:10px 4px;}
.sheet button{width:100%;text-align:left;background:none;border:none;border-top:1px solid var(--border);padding:14px 4px;font-size:15px;font-weight:600;color:var(--ink);cursor:pointer;}
.sheet button.danger{color:var(--expense);}
.sheet .btn{background:var(--primary);color:#fff;border-top:none;text-align:center;width:100%;padding:14px 22px;border-radius:var(--radius-full);margin-top:6px;font-weight:700;}
.sheet form{padding-top:4px;}
.sheet .avatar-pick{display:flex;justify-content:center;margin:6px 0 14px;}
.sheet .avatar-pick img{width:72px;height:72px;border-radius:50%;object-fit:cover;border:2px solid var(--border-strong);cursor:pointer;background:var(--surface-2);}
.sheet .form-hint{font-size:11.5px;color:var(--ink-muted);margin:-8px 0 12px;line-height:1.4;}

/* ---- profile row ---- */
.profile-row{display:flex;align-items:center;gap:12px;width:100%;background:var(--surface);border:none;border-radius:var(--radius-m);padding:12px 14px;margin-bottom:4px;box-shadow:var(--shadow-card);cursor:pointer;text-align:left;}
.profile-avatar{width:44px;height:44px;border-radius:50%;object-fit:cover;background:var(--surface-2);flex-shrink:0;}
.profile-meta{flex:1;min-width:0;}
.profile-meta .meta{font-size:14px;font-weight:700;}
.profile-meta .sub{font-size:12px;color:var(--ink-muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.profile-row .chev{color:var(--ink-muted);font-size:20px;}

/* ---- category cards & charts ---- */
#screen-categories h2.sec{margin:12px 0 8px;}
.cat-grid-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-bottom:4px;}
.cat-card{position:relative;background:var(--surface);border-radius:var(--radius-m);padding:9px 6px 8px;box-shadow:var(--shadow-card);border:2px solid transparent;cursor:pointer;text-align:left;}
.cat-card.on{border-color:var(--primary);}
.cat-card .cat-ic{width:24px;height:24px;margin-bottom:5px;}
.cat-card .cc-name{font-size:10.5px;font-weight:700;margin:0 0 1px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cat-card .cc-sub{font-size:9.5px;color:var(--ink-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cat-card .cc-archive{position:absolute;top:4px;right:4px;width:16px;height:16px;border-radius:50%;background:var(--surface-2);border:none;display:flex;align-items:center;justify-content:center;color:var(--ink-muted);cursor:pointer;padding:0;}
.cat-card .cc-archive svg{width:9px;height:9px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;}

.donut-wrap{display:flex;align-items:center;gap:18px;background:var(--surface);border-radius:var(--radius-m);padding:16px;box-shadow:var(--shadow-card);margin-bottom:4px;}
.donut-wrap svg{flex-shrink:0;}
.donut-legend{flex:1;min-width:0;display:flex;flex-direction:column;gap:7px;}
.donut-legend-row{display:flex;align-items:center;gap:8px;font-size:12.5px;}
.donut-legend-row .dot{width:9px;height:9px;border-radius:50%;flex-shrink:0;}
.donut-legend-row .dl-name{flex:1;min-width:0;color:var(--ink);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.donut-legend-row .dl-amt{color:var(--ink-muted);font-weight:700;}
.donut-center-total{font-size:11px;font-weight:700;fill:var(--ink-muted);}
.donut-center-val{font-size:15px;font-weight:800;fill:var(--ink);}

.bars-chart{display:flex;align-items:flex-end;gap:8px;background:var(--surface);border-radius:var(--radius-m);padding:12px 14px 8px;box-shadow:var(--shadow-card);margin-bottom:4px;height:104px;}
.bars-chart .bar-col{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;gap:6px;}
.bars-chart .bar-val{font-size:10.5px;font-weight:700;color:var(--ink-muted);}
.bars-chart .bar-fill{width:100%;max-width:26px;border-radius:6px 6px 3px 3px;background:var(--surface-2);}
.bars-chart .bar-col.on .bar-fill{background:var(--primary);}
.bars-chart .bar-col.on .bar-val{color:var(--ink);}
.bars-chart .bar-lbl{font-size:10px;color:var(--ink-muted);text-transform:capitalize;}

/* ---- history summary & filters ---- */
.hist-summary{display:flex;gap:8px;margin-bottom:16px;}
.hist-stat{flex:1;background:var(--surface);border-radius:var(--radius-m);padding:10px 12px;box-shadow:var(--shadow-card);}
.hist-stat .lbl{display:block;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--ink-muted);margin-bottom:4px;}
.hist-stat .val{display:block;font-family:"Sora";font-size:14px;font-weight:700;color:var(--ink);}
.hist-stat .val.income{color:var(--income);}
.hist-stat .val.expense{color:var(--expense);}
.hist-filters{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;margin-bottom:4px;}
.hist-chip{flex:0 0 auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-full);padding:7px 14px;font-size:12.5px;font-weight:600;color:var(--ink);cursor:pointer;white-space:nowrap;}
.hist-chip.on{background:var(--primary);border-color:var(--primary);color:#fff;}

/* ---- bills (contas fixas) ---- */
.bill-row{display:flex;align-items:center;gap:12px;background:var(--surface);border-radius:var(--radius-m);padding:12px 14px;margin-bottom:8px;box-shadow:var(--shadow-card);cursor:pointer;}
.bill-check{flex-shrink:0;width:24px;height:24px;border-radius:50%;border:2px solid var(--border-strong);background:none;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;}
.bill-check.on{background:var(--income);border-color:var(--income);}
.bill-check svg{width:14px;height:14px;stroke:#fff;fill:none;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;}
.bill-mid{flex:1;min-width:0;}
.bill-title{font-size:13.5px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.bill-planned{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--ink-muted);background:var(--surface-2);border-radius:4px;padding:1px 5px;margin-left:4px;}
.bill-sub{font-size:11.5px;color:var(--ink-muted);margin-top:2px;}
.bill-amt{font-family:"Sora";font-size:13px;font-weight:700;flex-shrink:0;}

/* ---- desktop layout (sidebar nav, wide content, real dialogs) ---- */
@media (min-width:900px){
  body{max-width:none;width:100%;box-shadow:none;}

  .screen{left:0;right:0;width:min(1100px,100%);margin:0 auto;}
  body.has-nav .screen{left:224px;right:0;width:min(1100px,calc(100% - 224px));margin:0 auto;}

  .navbar{
    position:fixed;left:0;top:0;bottom:0;right:auto;width:224px;height:100%;
    flex-direction:column;justify-content:flex-start;align-items:stretch;gap:2px;
    padding:22px 14px;border-top:none;border-right:1px solid var(--border);
    background:var(--surface);
  }
  .nav-brand{
    display:flex !important;align-items:center;gap:10px;font-family:"Sora";font-weight:700;font-size:16px;
    color:var(--ink);padding:8px 10px 22px;
  }
  .nav-brand-mark{
    display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;
    background:var(--primary);color:#fff;border-radius:var(--radius-m);font-family:"Sora";font-size:15px;font-weight:700;
  }
  .nb{
    flex-direction:row;justify-content:flex-start;gap:12px;padding:11px 12px;
    border-radius:var(--radius-m);font-weight:600;transition:background .12s ease;
  }
  .nb svg{width:19px;height:19px;flex-shrink:0;}
  .nb span{font-size:13.5px;}
  .nb:hover{background:var(--surface-2);}
  .nb.on{background:var(--primary);color:#fff;}
  .nb.on:hover{background:var(--primary);}

  .fab{position:fixed;left:auto;bottom:32px;right:40px;}

  /* modals become real centered dialogs, not a mobile bottom sheet */
  .sheet-overlay{align-items:center;justify-content:center;padding:20px;}
  .sheet{border-radius:var(--radius-l);max-width:460px;width:100%;max-height:86vh;overflow-y:auto;box-shadow:0 24px 60px -20px rgba(33,28,22,.35);}
}
