/* Paleta do app Android (ui/theme/Color.kt). */
:root {
  --primary: #8B4A00;
  --on-primary: #FFFFFF;
  --primary-container: #FFE4BC;
  --on-primary-container: #2E1500;
  --secondary: #1F5E99;
  --secondary-container: #E2EAF5;
  --tertiary: #5D5F00;
  --error: #B3261E;
  --error-container: #F9DEDC;
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --surface-2: #F3F2EF;
  --surface-3: #EBEDF0;
  --text: #1A1C1E;
  --muted: #43474E;
  --outline: #C3C7CF;
  --ok: #1E6B35;
  --ok-container: #DDF3E2;
  --warn: #7A4F00;
  --warn-container: #FFEFC8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --nav-w: 232px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #FFB870;
    --on-primary: #4A2800;
    --primary-container: #6A3B00;
    --on-primary-container: #FFDCBE;
    --secondary: #A3C9FF;
    --secondary-container: #004A81;
    --tertiary: #E0E26B;
    --error: #FFB4AB;
    --error-container: #93000A;
    --bg: #0C1119;
    --surface: #141B24;
    --surface-2: #1A222D;
    --surface-3: #202D3A;
    --text: #E3E3E3;
    --muted: #C4C7CF;
    --outline: #43474E;
    --ok: #9AD8A9;
    --ok-container: #17402A;
    --warn: #FFD27A;
    --warn-container: #4A3500;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0; }
p { margin: .35rem 0; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.center { text-align: center; }
.prewrap { white-space: pre-wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.pad { padding: 16px 18px; }
.noscript { padding: 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* Carregando e login */
.loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, var(--primary-container), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; display: grid; gap: 10px; }
.login-logo { justify-self: center; border-radius: 50%; }
.login-card .btn-lg { margin-top: 8px; }
.login-foot { margin-top: 12px; }
.check { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.notice { background: var(--warn-container); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: .92rem; }

/* Botões */
.btn { appearance: none; border: 1px solid var(--outline); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--error); }
.btn-lg { padding: 13px 20px; font-size: 1rem; }
.btn-small { padding: 5px 12px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* Casca */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--surface-3); padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.02rem; padding: 6px 8px 16px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 50%; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--primary-container); color: var(--on-primary-container); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.topbar-spacer { flex: 1; }
.brand-compact { display: none; padding: 0; }
.sync-pill { display: inline-flex; align-items: center; gap: 8px; max-width: 70vw; border: 1px solid var(--outline); background: var(--surface); color: var(--muted); padding: 6px 12px; border-radius: 999px; font: inherit; font-size: .85rem; cursor: pointer; }
.sync-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.sync-running .icon { animation: spin 1.2s linear infinite; }
.sync-offline, .sync-needsLogin { color: var(--warn); background: var(--warn-container); border-color: transparent; }
.sync-error { color: var(--error); background: var(--error-container); border-color: transparent; }
.banners { display: grid; gap: 8px; padding: 0 24px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; font-size: .92rem; }
.banner-warn { background: var(--warn-container); }
.banner-bad { background: var(--error-container); }
.banner-info { background: var(--secondary-container); }
.content { padding: 8px 24px 40px; outline: none; }
.view { max-width: 1120px; margin: 0 auto; display: grid; gap: 14px; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 8px; }
.section-title { margin-top: 6px; }
.hero { padding: 10px 0 2px; }

/* Cartões e painéis */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card { display: grid; gap: 6px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.card:hover { text-decoration: none; }
a.card:hover { outline: 2px solid var(--surface-3); }
.card-label { color: var(--muted); font-size: .9rem; }
.card-value { font-size: 1.6rem; letter-spacing: -.01em; }
.tone-warn { background: var(--secondary-container); }
.tone-primary { background: var(--primary-container); }
.tone-info { background: var(--warn-container); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 8px; }
.panel h2 + p { margin-top: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--surface-3); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: var(--text); min-height: 58px; }
a.row:hover { background: var(--surface-2); text-decoration: none; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-side { display: grid; justify-items: end; gap: 4px; text-align: right; flex: none; }
.row-meta { display: flex; gap: 8px; align-items: center; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--secondary-container); color: var(--secondary); font-weight: 700; font-size: .9rem; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-container); color: var(--ok); }
.badge-bad { background: var(--error-container); color: var(--error); }
.badge-warn { background: var(--warn-container); color: var(--warn); }
.badge-neutral { background: var(--surface-3); color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; background: var(--surface); border-radius: var(--radius); }
.empty p:first-child { font-weight: 600; }

/* Busca e filtros */
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--outline); border-radius: 999px; padding: 0 16px; color: var(--muted); }
.search:focus-within { border-color: var(--secondary); }
.search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; padding: 11px 0; outline: none; min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--outline); background: var(--surface); color: var(--muted); border-radius: 10px; padding: 6px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip-on { background: var(--secondary-container); color: var(--text); border-color: transparent; font-weight: 600; }

/* Detalhes */
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; padding-top: 6px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.detail-head > div:first-child { display: flex; align-items: center; gap: 14px; }
.detail-head h1 a { color: inherit; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700; color: var(--primary); margin: 0 0 2px; }
.lead { font-size: 1.05rem; margin: 0; white-space: pre-wrap; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; margin: 0; }
.field dt { color: var(--muted); font-size: .82rem; }
.field dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table.items { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.items th, .items td { padding: 10px 18px; text-align: left; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
.items th { color: var(--muted); font-size: .82rem; font-weight: 600; }
.items .num { text-align: right; white-space: nowrap; }
.items tfoot td { border-bottom: 0; }
.items tr.excluded td { color: var(--muted); }
.kind { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 6px; padding: 1px 6px; }
details summary { cursor: pointer; font-weight: 600; }

/* Celular e janelas estreitas: navegação embaixo. */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--surface-3); z-index: 5; }
  .nav .brand { display: none; }
  .nav { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: 1 0 auto; flex-direction: column; gap: 2px; padding: 6px 8px; font-size: .72rem; border-radius: 14px; }
  .brand-compact { display: flex; }
  .topbar { padding: 10px 16px; }
  .banners { padding: 0 16px; }
  .content { padding: 8px 16px 96px; }
  .columns { grid-template-columns: 1fr; }
  .sync-pill { max-width: 52vw; }
  .row-meta .small { display: none; }
  h1 { font-size: 1.35rem; }
}

@media (max-width: 480px) {
  .brand-compact span { display: none; }
  .sync-pill { max-width: 74vw; }
}

/* Barra de título integrada no app instalado (Windows/MSIX). */
@media (display-mode: window-controls-overlay) {
  .topbar { padding-left: max(24px, env(titlebar-area-x, 0px)); padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 16px); -webkit-app-region: drag; app-region: drag; min-height: env(titlebar-area-height, 40px); }
  .topbar a, .topbar button { -webkit-app-region: no-drag; app-region: no-drag; }
}
