/* Cash Day — design system */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #f0f3f1; --line: #e3e8e5;
  --ink: #0f1d17; --ink-2: #4b5d55; --ink-3: #85958e;
  --brand: #047857; --brand-2: #059669; --brand-soft: #e3f4ec; --brand-ink: #ffffff;
  --gold: #c58a12;
  --good: #0a8f4a; --good-soft: #e4f6ec; --bad: #d93a3a; --bad-soft: #fde9e9; --warn: #c27c00; --warn-soft: #fff4dc;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600; --s5: #ee7fac; --s6: #8a948f;
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 29, 23, .04), 0 6px 24px rgba(15, 29, 23, .06);
  --nav-h: 68px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1210; --surface: #121c18; --surface-2: #18241f; --line: #233129;
  --ink: #ecf3ef; --ink-2: #a8b7b0; --ink-3: #6f8078;
  --brand: #10b981; --brand-2: #34d399; --brand-soft: #0f2c22; --brand-ink: #04140d;
  --good: #22c55e; --good-soft: #0f2a1b; --bad: #f26363; --bad-soft: #321616; --warn: #f2b233; --warn-soft: #2e2410;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05; --s5: #e24d8b; --s6: #6c7772;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 15px; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); }
.pos { color: var(--good); } .neg { color: var(--bad); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.login-art { display: none; background: #06251a center/cover no-repeat; position: relative; }
.login-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4, 30, 21, .1), rgba(4, 30, 21, .85)); }
.login-art .quote { position: absolute; left: 48px; right: 48px; bottom: 48px; z-index: 1; color: #fff; }
.login-art .quote h2 { font-size: 34px; line-height: 1.1; margin: 0 0 10px; letter-spacing: -.02em; }
.login-art .quote p { margin: 0; opacity: .8; font-size: 16px; }
.login-box { display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; max-width: 420px; width: 100%; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.logo-mark { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #059669, #047857 60%, #065f46); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 18px rgba(4, 120, 87, .35); }
.logo-mark svg { width: 22px; height: 22px; }
.login-box h1 { font-size: 28px; letter-spacing: -.02em; margin: 36px 0 6px; }
.login-box .sub { color: var(--ink-2); margin: 0 0 28px; }
@media (min-width: 900px) { .login { grid-template-columns: 1.1fr 1fr; } .login-art { display: block; } }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; height: 48px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); padding: 0 14px; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 16px; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent); }
textarea.input { height: auto; min-height: 76px; padding: 12px 14px; resize: vertical; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .eye { position: absolute; right: 6px; top: 6px; width: 36px; height: 36px; border: 0; background: none; border-radius: 10px; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; }
.money { position: relative; }
.money .pre { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; pointer-events: none; }
.money .input { padding-left: 44px; font-weight: 700; font-size: 18px; }
.money.big .input { height: 60px; font-size: 26px; }
.money.big .pre { font-size: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { height: 48px; border-radius: var(--radius-sm); border: 0; padding: 0 18px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s, filter .15s, background .15s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-sm { height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 40px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: none; height: 34px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Shell ---------- */
.app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 14px 18px; display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 4px 18px 20px; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-in { max-width: 560px; margin: 0 auto; height: var(--nav-h); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 6px 0; }
.nav a.on { color: var(--brand); }
.nav a.fab span.b { width: 52px; height: 52px; border-radius: 18px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 40%, transparent); }
.nav a.fab span.b svg { width: 26px; height: 26px; }
.side { display: none; }
@media (min-width: 1024px) {
  .app { padding-bottom: 24px; padding-left: 240px; }
  .nav { display: none; }
  .side { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: 240px; background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px; gap: 4px; z-index: 30; }
  .side .logo { padding: 0 8px 22px; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; font-weight: 600; color: var(--ink-2); }
  .side a.on { background: var(--brand-soft); color: var(--brand); }
  .side a.cta { background: var(--brand); color: var(--brand-ink); margin-bottom: 12px; justify-content: center; }
  .side .sp { flex: 1; }
}

/* ---------- Cards / KPIs ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 2px; font-size: 15px; letter-spacing: -.01em; }
.card .hint { font-size: 12.5px; color: var(--ink-3); margin: 0 0 14px; }
.grid { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
.kpi .lb { font-size: 12.5px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .lb svg { width: 16px; height: 16px; }
.kpi .v { font-weight: 800; letter-spacing: -.03em; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
.kpi .d { font-size: 12px; font-weight: 700; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px; }
.kpi .d.up { color: var(--good); } .kpi .d.down { color: var(--bad); } .kpi .d.eq { color: var(--ink-3); }
.hero { background: linear-gradient(135deg, #065f46, #047857 55%, #059669); color: #fff; border-radius: 22px; padding: 20px; position: relative; overflow: hidden; box-shadow: 0 14px 34px rgba(4, 120, 87, .28); }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 70%); }
.hero .lb { opacity: .85; font-size: 13px; font-weight: 600; }
.hero .v { font-size: clamp(30px, 8vw, 44px); font-weight: 800; letter-spacing: -.03em; margin: 4px 0 2px; }
.hero .mini { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.hero .mini b { display: block; font-size: 16px; }
.hero .pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, .16); border-radius: 99px; padding: 3px 9px; font-size: 12px; font-weight: 700; }
.dash-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .dash-grid { grid-template-columns: 1fr 1fr; } .dash-grid .span2 { grid-column: span 2; } }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; align-items: center; }
.filters::-webkit-scrollbar { display: none; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--ink-3); font-size: 11px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 10px; border-radius: 10px; font-size: 12px; line-height: 1.45; white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); opacity: 0; transition: opacity .1s; box-shadow: var(--shadow); }
.tip b { font-weight: 700; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars-h { display: flex; flex-direction: column; gap: 12px; }
.bh .top-l { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; gap: 8px; }
.bh .top-l b { font-weight: 700; }
.bh .track { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; display: flex; }
.bh .fill { height: 100%; border-radius: 6px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.list-top { display: flex; flex-direction: column; }
.list-top .it { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-top .it:last-child { border-bottom: 0; }
.rank { width: 28px; height: 28px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }

/* ---------- Planilha ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { flex: 1; min-width: 200px; position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.search .input { padding-left: 40px; height: 44px; }
.select { height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); padding: 0 10px; font-weight: 600; font-size: 14px; outline: none; }
.totbar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
@media (min-width: 760px) { .totbar { grid-template-columns: repeat(5, 1fr); } }
.totbar div { background: var(--surface); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
.totbar small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.totbar b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sheet { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100dvh - 300px); display: none; }
.sheet table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.sheet th { position: sticky; top: 0; background: var(--surface-2); text-align: right; padding: 11px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; cursor: pointer; user-select: none; z-index: 1; border-bottom: 1px solid var(--line); }
.sheet th.l, .sheet td.l { text-align: left; }
.sheet td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sheet tr:hover td { background: var(--surface-2); cursor: pointer; }
.sheet th .ar { opacity: .5; margin-left: 4px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11px; font-weight: 800; letter-spacing: .03em; background: var(--surface-2); color: var(--ink-2); }
.tag .dot { width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.op { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; cursor: pointer; }
.op .t { font-weight: 700; font-size: 15px; }
.op .s { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.op .r { text-align: right; }
.op .l { font-weight: 800; color: var(--good); font-size: 15px; }
.day-h { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin: 10px 2px 2px; display: flex; justify-content: space-between; }
@media (min-width: 900px) { .sheet { display: block; } .cards-list { display: none; } }
.more { display: flex; justify-content: center; padding: 16px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-3); }
.empty svg { width: 44px; height: 44px; margin-bottom: 8px; }

/* ---------- Nova operação ---------- */
.nova-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .nova-grid { grid-template-columns: 1.3fr 1fr; align-items: start; } .resumo-sticky { position: sticky; top: 80px; } }
.resumo { background: linear-gradient(160deg, #0b2a1f, #0d3b2b); color: #eafff5; border-radius: 22px; padding: 20px; box-shadow: 0 14px 34px rgba(6, 60, 42, .3); }
.resumo .ln { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed rgba(255, 255, 255, .14); font-size: 14px; gap: 10px; }
.resumo .ln span:first-child { opacity: .75; }
.resumo .ln b { font-weight: 700; }
.resumo .lucro { margin-top: 14px; }
.resumo .lucro small { opacity: .75; font-size: 13px; }
.resumo .lucro .v { font-size: clamp(30px, 8vw, 40px); font-weight: 800; letter-spacing: -.03em; color: #5ef0a8; }
.resumo .lucro .v.neg { color: #ff8b8b; }
.resumo .margem { display: inline-flex; background: rgba(94, 240, 168, .14); color: #8af5c0; padding: 3px 10px; border-radius: 99px; font-weight: 700; font-size: 12.5px; margin-top: 4px; }
.section-t { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 4px 0 8px; }
.mode { margin-bottom: 14px; }

/* ---------- Sheet modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(5, 15, 11, .5); z-index: 50; opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px); }
.backdrop.on { opacity: 1; }
.modal { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--surface); border-radius: 22px 22px 0 0; max-height: 92dvh; overflow: auto; transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.modal.on { transform: none; }
.modal .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.modal h2 { margin: 0 0 14px; font-size: 19px; letter-spacing: -.02em; display: flex; justify-content: space-between; align-items: center; }
@media (min-width: 760px) { .modal { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; border-radius: 22px; transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; } .modal.on { transform: translate(-50%, -50%); opacity: 1; } .modal .grab { display: none; } }
.det { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.det div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.det small { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.det b { font-size: 15px; }

/* ---------- Taxas ---------- */
.tx-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tx-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 8px 4px; text-align: center; }
.tx-table td { padding: 4px; text-align: center; }
.tx-table td:first-child { font-weight: 700; color: var(--ink-2); }
.tx-table input { width: 100%; min-width: 64px; height: 38px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); text-align: center; font-weight: 600; outline: none; }
.tx-table input:focus { border-color: var(--brand); }
.scroll-x { overflow-x: auto; }

/* ---------- Mais ---------- */
.menu-list { display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 14px; padding: 15px 4px; border: 0; background: none; border-bottom: 1px solid var(--line); text-align: left; font-weight: 600; cursor: pointer; width: 100%; }
.menu-list .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.menu-list small { display: block; color: var(--ink-3); font-weight: 500; font-size: 12.5px; }

/* ---------- Toast / loading ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 80; opacity: 0; transition: all .25s; display: flex; gap: 8px; align-items: center; max-width: 92vw; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { .toast { bottom: 24px; } }
.sk { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.fade-in { animation: fi .25s ease-out; }
@keyframes fi { from { opacity: 0; transform: translateY(6px); } }

/* ajustes mobile */
.row2 > * { min-width: 0; }
.mode .seg { display: flex; width: 100%; }
.mode .seg button { flex: 1; padding: 0 6px; font-size: 12.5px; }
.money .auto { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; height: 20px; background: var(--brand-soft); color: var(--brand); }
.money.big .input { padding-right: 10px; }
@media (max-width: 520px) { .money.big .input { font-size: 20px; height: 56px; padding-left: 38px; } .money.big .pre { font-size: 15px; left: 12px; } .money .auto { top: -9px; transform: none; right: 8px; } }
.nova-grid > * { min-width: 0; }
@media (max-width: 759px) { .totbar div:last-child { grid-column: span 2; } }
