:root {
  --accent: #0E7C66;
  --accent-2: #16a085;
  --accent-soft: rgba(14,124,102,.10);
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #17202a;
  --muted: #667085;
  --border: #e4e8ee;
  --danger: #d64545;
  --ok: #2e9e5b;
  --warn: #e08a00;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.05);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.08);
  --sidebar-w: 256px;
}
[data-theme="dark"] {
  --accent-soft: rgba(255,255,255,.07);
  --bg: #0d0f12;
  --surface: #16191d;
  --surface-2: #1c2025;
  --text: #e7eaee;
  --muted: #98a2b3;
  --border: #262b31;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Inter, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }
img { max-width: 100%; }
::selection { background: var(--accent); color: #fff; }

/* ===== Shell ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 860px; width: 100%; margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--shadow-sm);
}
.topbar .title { font-weight: 700; font-size: 19px; flex: 1; letter-spacing: -.2px; }
.topbar .tb-btn { background: rgba(255,255,255,.16); color: #fff; border-radius: 12px; width: 42px; height: 42px; font-size: 18px; position: relative; display: grid; place-items: center; transition: background .15s; }
.topbar .tb-btn:hover { background: rgba(255,255,255,.28); }
.badge { position: absolute; top: -5px; right: -5px; background: #ff4d4f; color: #fff; font-size: 10px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--accent); }

/* ===== Sidebar (desktop) ===== */
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; }
.brand .logo { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #fff; font-size: 20px; overflow: hidden; }
.brand .name { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); font-weight: 600; font-size: 15px; transition: .15s; }
.navlink .ic { font-size: 19px; width: 22px; text-align: center; }
.navlink:hover { background: var(--surface-2); color: var(--text); }
.navlink.active { background: var(--accent-soft); color: var(--accent); }
.side-account { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); }
.side-account .email { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Bottom nav (mobile) ===== */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 12px rgba(16,24,40,.05); }
.bottomnav button { flex: 1; color: var(--muted); padding: 9px 0 11px; font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.bottomnav button .ic { font-size: 21px; line-height: 1; }
.bottomnav button.active { color: var(--accent); }
.bottomnav button.active::before { content: ''; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 3px; background: var(--accent); }

@media (min-width: 960px) {
  .sidebar { display: flex; flex-direction: column; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; }
  .bottomnav { display: none; }
  .topbar { padding-top: 16px; }
  .topbar .title { font-size: 20px; }
  .content { padding: 26px 28px 40px; max-width: 940px; }
}

/* ===== Cards / layout ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section-title { font-weight: 700; font-size: 16px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; letter-spacing: -.2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }

/* Tiles grid (responsivo) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { border-radius: var(--radius); padding: 15px 16px; }
.tile .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile .value { font-size: 21px; font-weight: 800; margin-top: 5px; letter-spacing: -.4px; }
.tile .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Buttons */
.btn { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; border-radius: 13px; padding: 13px 18px; font-size: 15px; font-weight: 700; width: 100%; box-shadow: var(--shadow-sm); transition: transform .06s, filter .15s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.outline { background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13.5px; border-radius: 11px; }
.chip { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 22px; padding: 9px 15px; font-size: 13.5px; font-weight: 600; transition: .12s; }
.chip:hover { border-color: var(--accent); }
.chip.sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.plain { background: var(--surface); }

/* List item */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 21px; flex-shrink: 0; }
.item .main { flex: 1; min-width: 0; }
.item .main .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-weight: 800; white-space: nowrap; letter-spacing: -.3px; }
.iconbtn { color: var(--muted); font-size: 18px; padding: 7px; border-radius: 9px; transition: .12s; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

/* Progress */
.progress { height: 9px; background: var(--border); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; transition: width .3s; }

/* Alert banner */
.alert { border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px; display: flex; gap: 11px; align-items: flex-start; border: 1px solid transparent; }
.alert .ai { font-size: 18px; line-height: 1.4; }
.alert .x { margin-left: auto; }
.alert.INFO { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.alert.WARNING { background: rgba(224,138,0,.10); border-color: rgba(224,138,0,.28); }
.alert.CRITICAL { background: rgba(214,69,69,.10); border-color: rgba(214,69,69,.30); }
.alert.SUCCESS { background: rgba(46,158,91,.10); border-color: rgba(46,158,91,.28); }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; background: var(--surface); padding: 6px; border-radius: 14px; border: 1px solid var(--border); }
.tabs button { flex: 1; color: var(--muted); border-radius: 10px; padding: 10px; font-size: 13.5px; font-weight: 700; transition: .12s; }
.tabs button.active { background: var(--accent); color: #fff; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.5); backdrop-filter: blur(2px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; box-shadow: 0 -8px 40px rgba(0,0,0,.2); }
@media (min-width: 560px) { .overlay { align-items: center; } .modal { border-radius: 22px; } }
.modal h3 { margin: 0 0 16px; font-size: 20px; letter-spacing: -.3px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); transition: .12s; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: var(--shadow-sm); }
.swatch.sel { border-color: var(--text); }
.emoji-pick { display: flex; gap: 7px; flex-wrap: wrap; }
.emoji-pick button { font-size: 20px; width: 42px; height: 42px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); }
.emoji-pick button.sel { background: var(--accent-soft); border-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 12px; }
.toggle { width: 48px; height: 28px; border-radius: 14px; background: var(--border); position: relative; transition: .2s; flex-shrink: 0; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: var(--shadow-sm); }
.toggle.on::after { left: 23px; }

/* Empty / misc */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 46px; }
canvas { display: block; }
.legend { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; }
.toast { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; box-shadow: var(--shadow); pointer-events: none; max-width: 90%; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
@media (min-width: 960px) { .toast { bottom: 28px; } }

/* ===== Auth (tela cheia) ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(150deg, var(--accent), var(--accent-2) 55%, #0b5f4f); }
.auth-card { background: var(--surface); width: 100%; max-width: 400px; border-radius: 24px; padding: 30px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-logo { width: 62px; height: 62px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 30px; margin: 0 auto 16px; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; font-size: 24px; margin: 0 0 4px; letter-spacing: -.4px; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-tabs { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: 5px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); font-size: 14px; }
.auth-tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.auth-err { color: var(--danger); font-size: 13px; margin: -4px 0 12px; min-height: 16px; text-align: center; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--muted); }
