/* ============ TOKENS ============ */
:root {
    --bg: #F2F3F5; --panel: #FFFFFF; --panel-2: #F6F7F9; --hover: #EEF0F3;
    --ink: #0E1116; --ink-2: #5A6270; --ink-3: #7D8592; --line: #E4E7EB;
    --btn: #0E1116; --on-btn: #FFFFFF;
    --up: #D9480F; --up-soft: #FFF0E8; --down: #0B8A5E; --down-soft: #E6F6EF; --warn: #B45309; --warn-soft: #FEF3E2;
    --danger: #D92D33;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --c1: #3E63DD; --c2: #E5484D; --c3: #8E4EC6; --c4: #12A594; --c5: #E09A10;
    --c6: #DB2777; --c7: #0284C7; --c8: #65A30D; --c9: #C2410C; --c10: #64748B;
    --mono: 'Geist Mono', ui-monospace, monospace;
    --tabbar-h: 64px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0A0B0D; --panel: #131519; --panel-2: #191C21; --hover: #1F2329;
    --ink: #ECEEF1; --ink-2: #9BA3AE; --ink-3: #737B88; --line: #23272E;
    --btn: #ECEEF1; --on-btn: #0A0B0D;
    --up: #FF8B4D; --up-soft: rgba(255,139,77,.12); --down: #3DD69B; --down-soft: rgba(61,214,155,.12); --warn: #F5B544; --warn-soft: rgba(245,181,68,.12);
    --danger: #F2555A;
    --shadow: none;
    --c1: #5B7FFF; --c2: #F2555A; --c3: #A875E0; --c4: #1FC2AC; --c5: #F5B544;
    --c6: #F472B6; --c7: #38BDF8; --c8: #A3E635; --c9: #FB923C; --c10: #94A3B8;
    color-scheme: dark;
}

/* ============ BASE ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Geist', system-ui, -apple-system, sans-serif; font-size: 14px; line-height: 1.45; background: var(--bg); color: var(--ink); overflow-x: clip; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
input { font: inherit; font-size: 16px; color: inherit; }
:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.muted { color: var(--ink-2); }

/* Modo privado: borra os valores */
body.privacy .num, body.privacy .big, body.privacy .cell-val { filter: blur(7px); user-select: none; }

/* ============ BOTÕES ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.btn-sm { height: 34px; padding: 0 12px; }
.btn-block { width: 100%; height: 46px; }
.btn-ink { background: var(--btn); color: var(--on-btn); }
.btn-ink:hover:not(:disabled) { opacity: .88; }
.btn-line { border: 1px solid var(--line); background: var(--panel); }
.btn-line:hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-danger-line { border: 1px solid var(--line); color: var(--danger); }
.btn-danger-line:hover { background: color-mix(in oklab, var(--danger) 12%, transparent); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.link { color: var(--ink-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link:hover { color: var(--ink); }
.mini-btn { height: 32px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--panel); flex-shrink: 0; }
.mini-btn:hover { background: var(--hover); }
.mini-btn.danger { color: var(--danger); }

/* ============ LOGO ============ */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; display: grid; grid-template-columns: 3fr 2fr; grid-template-rows: 3fr 2fr; gap: 2px; overflow: hidden; flex-shrink: 0; }
.logo-mark span:nth-child(1) { background: var(--c1); grid-row: span 2; }
.logo-mark span:nth-child(2) { background: var(--c2); }
.logo-mark span:nth-child(3) { background: var(--c4); }

/* ============ CARREGANDO ============ */
#loading-overlay { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--ink-2); }
.big-mark { width: 44px; height: 44px; border-radius: 12px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.88); opacity: .6; } }

/* ============ LOGIN ============ */
#login-screen { display: none; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px 22px; box-shadow: var(--shadow); }
.login-logo { margin-bottom: 26px; }
.login-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.03em; }
.login-sub { margin: 4px 0 20px; }
.auth-error { background: color-mix(in oklab, var(--danger) 12%, transparent); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.pass-wrap { position: relative; }
.pass-wrap .inp { padding-right: 48px; }
.pass-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.login-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; }

/* ============ SHELL ============ */
#app-screen { display: none; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--line); }
.sidebar > .logo { padding: 4px 8px 22px; }
.nav-btn { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; width: 100%; text-align: left; border: 1px solid transparent; }
.nav-btn i { width: 16px; text-align: center; font-size: 14px; }
.nav-btn:hover { background: var(--hover); color: var(--ink); }
.nav-btn[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); border-color: var(--line); }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--warn-soft); color: var(--warn); padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 0 0 10px; }
.me-edit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 0; border-radius: 8px; text-align: left; }
.me-edit:hover .me-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.me-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: var(--ink); flex-shrink: 0; }

.main { min-width: 0; padding: 20px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.topbar .sub { color: var(--ink-2); font-size: 13px; }
.cmd { margin-left: auto; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink-3); min-width: 280px; box-shadow: var(--shadow); }
.cmd:hover { color: var(--ink-2); border-color: var(--ink-3); }
.cmd kbd { margin-left: auto; font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--ink-2); }

/* ============ VISÃO GERAL (BENTO) ============ */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.tile-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-height: 24px; }
.tile-title { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tile-head .right { margin-left: auto; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

.setup-tile { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; border-style: dashed; }
.setup-tile > div:first-child { flex: 1; min-width: 220px; }
.setup-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.total-tile { display: flex; flex-direction: column; }
.big { font-family: var(--mono); font-size: clamp(32px, 4.2vw, 46px); font-weight: 500; letter-spacing: -0.05em; line-height: 1; margin: 6px 0 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.big small { font-size: .45em; color: var(--ink-3); letter-spacing: -0.02em; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.kv-first { margin-top: auto; }
.kv > span:last-child { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; font-family: var(--mono); white-space: nowrap; }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.warn { background: var(--warn-soft); color: var(--warn); font-family: inherit; }
.pill.neutral { background: var(--panel-2); color: var(--ink-2); font-family: inherit; border: 1px solid var(--line); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.ldot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.ldot.down { background: var(--down); }
.ldot.up { background: var(--up); margin-left: 6px; }

/* Treemap — o mapa do mês */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.crumbs button { color: var(--ink-2); font-weight: 600; }
.crumbs button:hover { color: var(--ink); }
.crumbs strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.treemap { position: relative; height: 330px; border-radius: 10px; overflow: hidden; }
.cell { position: absolute; padding: 3px; transition: left .45s cubic-bezier(.2,.8,.2,1), top .45s cubic-bezier(.2,.8,.2,1), width .45s cubic-bezier(.2,.8,.2,1), height .45s cubic-bezier(.2,.8,.2,1); }
.cell-in { width: 100%; height: 100%; border-radius: 8px; background: var(--col); color: #fff; padding: 10px 12px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; overflow: hidden; position: relative; transition: filter .15s; }
.cell-in:hover { filter: brightness(1.08); }
.cell-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0,0,0,.2); padding-right: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cell-val { font-family: var(--mono); font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.15); }
.cell-pct { font-family: var(--mono); font-size: 11.5px; opacity: .8; }
.cell.tiny .cell-name, .cell.tiny .cell-pct, .cell.tiny .cell-flag { display: none; }
.cell.tiny .cell-val { font-size: 11px; }
.cell.micro .cell-in > * { display: none; }
.cell-flag { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 600; background: rgba(0,0,0,.28); padding: 2px 6px; border-radius: 99px; color: #fff; }
.empty { display: grid; place-items: center; text-align: center; gap: 10px; height: 100%; min-height: 160px; color: var(--ink-2); padding: 24px; border: 1px dashed var(--line); border-radius: 12px; }
.empty i { font-size: 22px; color: var(--ink-3); }

/* Precisa de você */
.inbox-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.inbox-item:first-child { border-top: 0; padding-top: 0; }
.inbox-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; }
.ico-down { background: var(--down-soft); color: var(--down); }
.ico-up { background: var(--up-soft); color: var(--up); }
.ico-warn { background: var(--warn-soft); color: var(--warn); }
.ico-danger { background: color-mix(in oklab, var(--danger) 14%, transparent); color: var(--danger); }
.inbox-main { flex: 1; min-width: 0; }
.inbox-main strong { display: block; font-weight: 600; font-size: 13.5px; }
.inbox-main span { color: var(--ink-2); font-size: 12.5px; }
.inbox-done { display: flex; align-items: center; gap: 10px; padding: 18px 0 6px; color: var(--ink-2); }
.inbox-done i { color: var(--down); font-size: 18px; }
.inbox-more { margin-top: 10px; font-size: 13px; }

/* Próximos 12 meses */
.horizon { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 176px; }
.hz-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; padding: 0; }
.hz-bar { width: 100%; max-width: 34px; border-radius: 6px 6px 3px 3px; background: var(--panel-2); border: 1px solid var(--line); position: relative; transition: height .4s cubic-bezier(.2,.8,.2,1); }
.hz-col.now .hz-bar { background: var(--btn); border-color: var(--btn); }
.hz-col.has-down .hz-bar::after, .hz-col.has-up .hz-bar::after { content: ''; position: absolute; top: -11px; left: 50%; width: 7px; height: 7px; border-radius: 50%; transform: translateX(-50%); }
.hz-col.has-down .hz-bar::after { background: var(--down); }
.hz-col.has-up .hz-bar::after { background: var(--up); }
.hz-col.has-down.has-up .hz-bar::after { background: linear-gradient(90deg, var(--down) 50%, var(--up) 50%); }
.hz-m { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.hz-col.now .hz-m { color: var(--ink); font-weight: 600; }
.hz-col:hover .hz-bar { border-color: var(--ink-3); }
.hz-col.sel .hz-bar { outline: 2px solid var(--c1); outline-offset: 2px; }
.hz-detail { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--panel-2); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; min-height: 46px; }
.hz-ev { display: inline-flex; align-items: center; gap: 6px; }

/* Assinaturas */
.subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.sub { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--panel-2); text-align: left; width: 100%; min-width: 0; }
.sub:hover { border-color: var(--ink-3); }
.sub-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mono { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0; background: var(--col); }
.sub-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.subs-empty { color: var(--ink-2); font-size: 13px; }

/* ============ GASTOS ============ */
.quick { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); }
.quick:focus-within { border-color: var(--ink-3); }
.quick input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 40px; }
.quick-preview { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; margin: 8px 4px 16px; font-size: 12.5px; color: var(--ink-3); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); color: var(--ink); font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 3px; background: var(--col); flex-shrink: 0; display: inline-block; }

.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink-3); flex: 1 1 220px; min-width: 0; }
.search:focus-within { border-color: var(--ink-3); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; height: 100%; }
.tools-right { display: flex; gap: 8px; margin-left: auto; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; flex-basis: 100%; }
.fchip { height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.fchip span { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); margin-left: 2px; }
.fchip:hover { color: var(--ink); }
.fchip[aria-pressed="true"] { background: var(--btn); color: var(--on-btn); border-color: var(--btn); }
.fchip[aria-pressed="true"] span { color: inherit; opacity: .7; }
.filter-note { font-size: 13px; color: var(--ink-2); margin: -2px 2px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

.table { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.t-head, .t-row { display: grid; grid-template-columns: 22px minmax(0, 2fr) minmax(0, 2fr) 116px 52px 112px; gap: 12px; align-items: center; padding: 11px 16px 11px 10px; }
.t-head { font-size: 12px; color: var(--ink-3); font-weight: 600; padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.t-group { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; background: var(--panel-2); border-top: 1px solid var(--line); font-weight: 600; }
.t-group:first-child, .t-head + .t-group { border-top: 0; }
.t-toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; padding: 6px 4px; border-radius: 8px; }
.t-toggle .chev { font-size: 11px; color: var(--ink-3); width: 14px; transition: transform .2s; }
.t-group.collapsed .chev { transform: rotate(-90deg); }
.t-group.collapsed + .t-list { display: none; }
.t-gname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-gcount { color: var(--ink-3); font-weight: 400; white-space: nowrap; }
.t-group .num { margin-left: auto; white-space: nowrap; }
.t-group .icon-btn { width: 34px; height: 34px; font-size: 13px; }
.t-row { border-top: 1px solid var(--line); cursor: pointer; background: var(--panel); }
.t-list > .t-row:first-child { border-top: 1px solid var(--line); }
.t-row:hover { background: var(--panel-2); }
.t-row:hover .t-actions, .t-row:focus-within .t-actions { opacity: 1; }
.t-row.is-ended .t-name, .t-row.is-ended .t-val { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.grip { color: var(--ink-3); cursor: grab; display: grid; place-items: center; height: 32px; touch-action: none; font-size: 13px; }
.grip:active { cursor: grabbing; }
.no-drag .grip { visibility: hidden; }
.t-name { font-weight: 500; overflow-wrap: anywhere; }
.t-meta { color: var(--ink-2); font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.t-val { text-align: right; white-space: nowrap; }
.t-pct { text-align: right; color: var(--ink-3); font-size: 12px; }
.t-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.t-actions .icon-btn { width: 34px; height: 34px; font-size: 12.5px; }
.t-actions .del:hover { color: var(--danger); }
.t-empty { padding: 14px 16px 14px 44px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.t-list:has(.t-row) .t-empty { display: none; }
.sortable-ghost { opacity: .35; background: var(--hover); }
.sortable-chosen { background: var(--panel-2); }
.list-empty { padding: 40px 20px; text-align: center; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.list-empty i { font-size: 22px; color: var(--ink-3); }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: color-mix(in oklab, var(--c1) 18%, var(--panel-2)); } }

/* ============ AGENDA ============ */
.agenda-month { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-top: 1px solid var(--line); }
.agenda-month:first-child { border-top: 0; padding-top: 0; }
.agenda-month:last-child { padding-bottom: 0; }
.agenda-label strong { display: block; font-size: 16px; letter-spacing: -0.02em; }
.ev { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); margin-bottom: 8px; }
.ev:last-child { margin-bottom: 0; }
.ev-main { flex: 1; min-width: 0; }
.ev-main strong { display: block; font-weight: 600; }
.ev-main span { color: var(--ink-2); font-size: 12.5px; }
.agenda-quiet { color: var(--ink-3); font-size: 13px; padding: 8px 0; }

/* ============ RELATÓRIOS ============ */
.export-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.export-card { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; }
.export-card:hover { border-color: var(--ink-3); }
.export-card i { font-size: 22px; }
.report-table { margin-top: 14px; }
.report-table .t-head, .report-table .t-row { grid-template-columns: minmax(0, 1fr) 46px 116px 52px; padding-left: 16px; cursor: default; }
.report-table .t-row:hover { background: var(--panel); }
.report-table .t-foot { font-weight: 600; background: var(--panel-2); }

/* ============ PALETA DE COMANDOS ============ */
.overlay { position: fixed; inset: 0; background: rgba(5,6,8,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: none; align-items: flex-start; justify-content: center; padding: max(12vh, env(safe-area-inset-top)) 16px 16px; z-index: 70; }
.overlay.show { display: flex; }
.palette { width: 100%; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.palette input { width: 100%; border: 0; outline: none; background: none; padding: 18px; border-bottom: 1px solid var(--line); }
#palBody { max-height: 60vh; overflow-y: auto; }
.pal-sec { padding: 8px; }
.pal-label { font-size: 11.5px; color: var(--ink-3); font-weight: 600; padding: 6px 10px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; width: 100%; text-align: left; min-width: 0; }
.pal-item > .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item:hover, .pal-item.active { background: var(--hover); }
.pal-item .chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.pal-empty { padding: 10px; color: var(--ink-2); }

/* ============ PAINEL LATERAL ============ */
.scrim { position: fixed; inset: 0; background: rgba(5,6,8,.5); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--line); z-index: 61; display: flex; flex-direction: column; transform: translateX(100%); visibility: hidden; transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s .28s; }
.drawer.show { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.drawer-foot .btn { flex: 1; }
.drawer-foot .btn.square { flex: 0 0 44px; padding: 0; }
.drawer-note { font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.review-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; margin-bottom: 16px; }
.review-box span { flex: 1; }

.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.inp { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--ink); outline: none; font-size: 16px; }
.inp:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px color-mix(in oklab, var(--c1) 20%, transparent); }
.inp.money { font-family: var(--mono); font-size: 18px; }
.field-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.field-hint.ok { color: var(--down); }
.cat-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-opt { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; font-weight: 500; color: var(--ink-2); max-width: 100%; }
.cat-opt:hover { color: var(--ink); background: var(--hover); }
.cat-opt[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--ink); }
.cat-opt.new { border-style: dashed; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.toggle-row small { display: block; color: var(--ink-3); font-size: 12px; }
.sw { width: 42px; height: 26px; border-radius: 99px; background: var(--line); position: relative; flex-shrink: 0; transition: background .2s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
input:checked + .sw { background: var(--down); }
input:checked + .sw::after { transform: translateX(16px); }
input:focus-visible + .sw { outline: 2px solid var(--c1); outline-offset: 2px; }

.cat-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 4px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--panel-2); }
.cat-row .grip { width: 28px; }
.cat-row input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-weight: 500; height: 36px; padding: 0 6px; border-radius: 6px; }
.cat-row input:focus { background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.cat-row .count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.cat-row .icon-btn { width: 36px; height: 36px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; background: var(--col); flex-shrink: 0; border: 0; }
.add-cat { display: flex; gap: 8px; margin-top: 14px; }
.add-cat .inp { flex: 1; min-width: 0; }
.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-list .nav-btn { padding: 12px 10px; font-size: 15px; }

/* ============ PARCELAS E CARTÕES ============ */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); max-width: 100%; }
.seg button { height: 36px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.seg-sm { padding: 2px; border-radius: 9px; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-row > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; }
.opt-label { font-weight: 400; color: var(--ink-3); }
#editorForm:not(.is-inst) .inst-only, #editorForm.is-inst .monthly-only { display: none; }
.inst-summary { margin: -6px 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); line-height: 1.5; }
.inst-summary.ok { background: var(--down-soft); }
.hint-note { display: block; color: var(--ink-2); margin-top: 2px; }
.card-ico { color: var(--col); font-size: 12px; }
.card-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.card-chip i { color: var(--col); font-size: 11px; }
.inst-prog { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); }
.inst-bar { width: 46px; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; flex-shrink: 0; }
.inst-bar i { display: block; height: 100%; border-radius: inherit; background: var(--down); }
.inst-left { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.card-filters:empty { display: none; }
.card-filters .fchip { display: inline-flex; align-items: center; gap: 6px; }
.card-row { padding: 6px 6px 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--panel-2); }
.card-row-top { display: flex; align-items: center; gap: 8px; padding-left: 6px; }
.card-row-top input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-weight: 500; height: 36px; padding: 0 6px; border-radius: 6px; }
.card-row-top input:focus { background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.card-row-top .icon-btn { width: 36px; height: 36px; }
.card-row-days { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 2px 8px 0 46px; font-size: 12.5px; color: var(--ink-2); }
.card-row-days label { display: inline-flex; align-items: center; gap: 6px; }
.card-row-days .day { width: 52px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: center; font-family: var(--mono); font-size: 14px; outline: none; }
.card-row-days .day:focus { border-color: var(--ink-3); }
.card-row-days .count { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.add-card { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.add-card .field { margin-bottom: 12px; }
.day-inp { flex: 0 0 96px !important; }

.card-logo { display: inline-grid; place-items: center; width: 16px; height: 16px; flex-shrink: 0; }
.card-logo > * { grid-area: 1 / 1; }
.card-logo img { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; }
.card-logo i { color: var(--col); font-size: 11px; }
.card-logo img ~ i, .card-badge img ~ i { display: none; }
.card-badge { width: 32px; height: 32px; border-radius: 9px; background: var(--col); display: grid; place-items: center; flex-shrink: 0; color: #fff; font-size: 13px; }
.card-badge > * { grid-area: 1 / 1; }
.card-badge img { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; background: #fff; }
.card-badge[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 4px var(--ink-3); }
.color-pop { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 8px 6px 46px; }
.color-pop .swatch { width: 28px; height: 28px; border-radius: 8px; }
.color-pop .swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 4px var(--ink); }
.brand-hint { display: flex; align-items: center; gap: 6px; min-height: 0; }
.brand-hint img { width: 18px; height: 18px; border-radius: 5px; }

/* ============ AVISOS E MODAL ============ */
.toast-stack { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 120; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--btn); color: var(--on-btn); padding: 10px 14px; border-radius: 12px; font-weight: 500; opacity: 0; transform: translateY(16px); transition: opacity .25s, transform .25s; pointer-events: auto; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 100%; }
.toast.show { opacity: 1; transform: none; }
.toast i { flex-shrink: 0; }
.toast.error i { color: var(--danger); }
.toast-action { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; margin-left: 4px; color: inherit; }

.modal-overlay { position: fixed; inset: 0; z-index: 110; background: rgba(5,6,8,.55); display: none; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .2s; }
.modal-overlay.show { opacity: 1; }
.modal-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-box h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 6px; }
.modal-box p { color: var(--ink-2); margin-bottom: 18px; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

/* ============ MOBILE ============ */
.tabbar, .mobile-head { display: none; }

@media (max-width: 1100px) {
    .span-4, .span-5 { grid-column: span 5; } .span-7, .span-8 { grid-column: span 7; }
    .t-head, .t-row { grid-template-columns: 22px minmax(0, 2fr) minmax(0, 1.4fr) 110px 48px 112px; }
}
@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar, .topbar { display: none; }
    .main { padding: 0 16px calc(var(--tabbar-h) + 36px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
    .mobile-head { display: flex; align-items: center; gap: 4px; padding: max(12px, env(safe-area-inset-top)) 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 20; }
    .mobile-head .logo-mark { margin-right: 6px; }
    .mobile-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .avatar.sm { width: 30px; height: 30px; }
    .bento { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .span-4, .span-5, .span-7, .span-8, .span-12 { grid-column: auto; }
    .tile { padding: 16px; }
    .treemap { height: 280px; }
    .horizon { height: 140px; gap: 4px; }
    .hz-m { font-size: 10px; }
    .crumbs > span { display: none; }
    .crumbs { font-size: 12.5px; }
    .subs { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); height: var(--tabbar-h); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 40; align-items: center; padding: 0 6px; }
    .tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--ink-3); font-weight: 500; padding: 6px 0; position: relative; min-height: 48px; justify-content: center; }
    .tab i { font-size: 17px; }
    .tab[aria-current="page"] { color: var(--ink); }
    .tab-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
    .tab-add { justify-self: center; width: 48px; height: 48px; border-radius: 15px; background: var(--btn); color: var(--on-btn); display: grid; place-items: center; font-size: 18px; }

    .quick { position: sticky; top: calc(max(12px, env(safe-area-inset-top)) + 52px); z-index: 10; }
    .tools-right { margin-left: 0; }
    .hide-sm { display: none; }
    .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
    .filters::-webkit-scrollbar { display: none; }
    .t-head { display: none; }
    .t-row { grid-template-columns: 22px minmax(0, 1fr) auto; gap: 2px 10px; padding: 11px 12px 11px 6px; }
    .t-row .grip { grid-row: span 2; }
    .t-name { grid-column: 2; grid-row: 1; }
    .t-meta { grid-column: 2; grid-row: 2; font-size: 12.5px; }
    .t-meta:empty { display: none; }
    .t-val { grid-column: 3; grid-row: 1; }
    .t-pct { grid-column: 3; grid-row: 2; }
    .t-actions { display: none; }
    .t-empty { padding-left: 34px; }

    .agenda-month { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .agenda-label { display: flex; align-items: baseline; justify-content: space-between; }
    .export-row { grid-template-columns: minmax(0, 1fr); }
    .report-table .t-head { display: grid; }
    .report-table .t-head, .report-table .t-row { grid-template-columns: minmax(0, 1fr) 30px auto 44px; gap: 8px; padding: 11px 14px; }

    .drawer { top: auto; left: 0; width: 100%; max-height: 90vh; max-height: 90dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; transform: translateY(100%); }
    .drawer::before { content: ''; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; flex-shrink: 0; }
    .drawer-body { padding: 16px; }
    .drawer-foot { padding-left: 16px; padding-right: 16px; }
    .toast-stack { bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
    .cat-money { display: none; }
    .card-row-days .count .num { display: none; }
    .overlay { padding-top: max(16px, env(safe-area-inset-top)); }
}
@media (max-width: 380px) {
    .main { padding-left: 12px; padding-right: 12px; }
    .tile { padding: 14px; }
    .mobile-head .icon-btn { width: 36px; }
    .tab { font-size: 10px; }
    .big { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
