/* ==========================================================================
   Bilhete Único Corporativo — estilos
   ========================================================================== */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e2e7ef;
  --text: #1b2433;
  --muted: #5f6b7d;
  --primary: #1e4e8c;
  --primary-600: #173f73;
  --primary-50: #e8eff9;
  --accent: #0b8a5f;
  --accent-50: #e3f6ee;
  --warn: #8a5a12;
  --warn-50: #fdf3e1;
  --danger: #c53030;
  --danger-50: #fdeaea;
  --info: #2b6cb0;
  --info-50: #e6f0fb;
  --on-primary: #ffffff;
  --on-accent: #ffffff;
  --hero-from: #1e4e8c;
  --hero-to: #173f73;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --surface: #171e29; --surface-2: #1c2431; --border: #2a3444; --text: #e6ebf2; --muted: #9aa6b8;
    --primary: #5b9bef; --primary-600: #7fb1f3; --primary-50: #1b2a40; --accent: #34c38f; --accent-50: #13302a;
    --warn: #e0a84a; --warn-50: #33291a; --danger: #f07171; --danger-50: #3a1f22; --info: #6aa7ea; --info-50: #182a40;
    --on-primary: #0b1220; --on-accent: #07140f; --hero-from: #1d3f6e; --hero-to: #12294a; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --surface: #171e29; --surface-2: #1c2431; --border: #2a3444; --text: #e6ebf2; --muted: #9aa6b8;
  --primary: #5b9bef; --primary-600: #7fb1f3; --primary-50: #1b2a40; --accent: #34c38f; --accent-50: #13302a;
  --warn: #e0a84a; --warn-50: #33291a; --danger: #f07171; --danger-50: #3a1f22; --info: #6aa7ea; --info-50: #182a40;
  --on-primary: #0b1220; --on-accent: #07140f; --hero-from: #1d3f6e; --hero-to: #12294a; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.1rem; font-weight: 700; color: var(--primary); border-bottom: 1px solid var(--border); min-height: var(--topbar-h); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: .8rem; font-weight: 800; letter-spacing: .5px; flex-shrink: 0; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; }
.nav { padding: .6rem .5rem 1rem; flex: 1; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .9rem .75rem .3rem; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; font-size: .93rem; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-50); color: var(--primary); }
.nav a .count { margin-left: auto; background: var(--danger); color: var(--on-primary); border-radius: 999px; font-size: .7rem; padding: 0 .45rem; font-weight: 700; }
.nav svg, .icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; }
.search-box { position: relative; flex: 1; max-width: 460px; }
.search-box input { width: 100%; padding-left: 2.2rem; }
.search-box .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 60vh; overflow: auto; z-index: 60; }
.search-results .group { padding: .4rem .75rem; font-size: .72rem; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.search-results a { display: block; padding: .5rem .75rem; color: var(--text); border-bottom: 1px solid var(--border); }
.search-results a:hover { background: var(--primary-50); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn { position: relative; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); padding: .45rem; cursor: pointer; color: var(--text); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; background: var(--danger); color: #fff; border-radius: 999px; font-size: .65rem; display: grid; place-items: center; font-weight: 700; padding: 0 4px; }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem; border-radius: 999px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.user-chip .who { text-align: left; line-height: 1.15; }
.user-chip .who small { display: block; color: var(--muted); font-size: .72rem; }
.dropdown { position: absolute; right: 1rem; top: calc(var(--topbar-h) - 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 220px; z-index: 70; overflow: hidden; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: .65rem 1rem; background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.bottom-nav { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 35; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 1.6rem; font-weight: 750; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8rem; color: var(--muted); }
.kpi.highlight { background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; border: 0; }
.kpi.highlight .label, .kpi.highlight .hint { color: rgba(255,255,255,.85); }
.kpi.warn { border-left: 4px solid var(--warn); }
.kpi.danger { border-left: 4px solid var(--danger); }

.hero { background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%); color: #fff; border-radius: var(--radius); padding: 1.4rem 1.5rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.hero h1 { font-size: 1.35rem; margin-bottom: .75rem; }
.hero .meta { display: flex; gap: 1.75rem; flex-wrap: wrap; opacity: .95; }
.hero .meta div small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.hero .meta div strong { font-size: 1.05rem; }
.hero .balance { font-size: 2.2rem; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.quick-actions { display: grid; gap: .75rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1rem; }
.quick-actions a { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; align-items: center; gap: .4rem; color: var(--text); font-weight: 600; box-shadow: var(--shadow); text-align: center; }
.quick-actions a:hover { border-color: var(--primary); text-decoration: none; }
.quick-actions a.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.quick-actions .icon { width: 26px; height: 26px; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.field .error { font-size: .82rem; color: var(--danger); margin-top: .25rem; }
.req::after { content: " *"; color: var(--danger); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .75rem; min-height: 42px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
input[readonly], input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.form-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.input-prefix input { padding-left: 2.4rem; }

/* Chips de valor (registro de utilização) */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.chip { position: relative; }
.chip input { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.chip span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .5rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 650; cursor: pointer; text-align: center; font-variant-numeric: tabular-nums; transition: all .12s; font-size: .95rem; }
.chip input:checked + span { border-color: var(--primary); background: var(--primary-50); color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.chip.wide span { font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600; border-radius: var(--radius-sm); padding: .55rem 1rem; min-height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-success:hover { filter: brightness(.95); background: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-primary); }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: .85rem; }
.btn-lg { padding: .8rem 1.4rem; min-height: 52px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--primary-50); }
td.money, th.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: var(--surface-2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.pager .btns { display: flex; gap: .4rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; margin-bottom: .5rem; opacity: .6; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.filters .field.grow { max-width: none; flex: 2 1 220px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: .5rem .85rem; font: inherit; font-size: .88rem; cursor: pointer; color: var(--text); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--primary); color: var(--on-primary); }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 650; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.green { background: var(--accent-50); color: var(--accent); border-color: transparent; }
.badge.yellow { background: var(--warn-50); color: var(--warn); border-color: transparent; }
.badge.red { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.badge.blue { background: var(--info-50); color: var(--info); border-color: transparent; }
.notice { border-radius: var(--radius-sm); padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid transparent; font-size: .92rem; }
.notice.warn { background: var(--warn-50); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice.danger { background: var(--danger-50); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice.info { background: var(--info-50); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.notice.success { background: var(--accent-50); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.notice strong { display: block; margin-bottom: .15rem; }

/* Resumo de cálculo */
.calc { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.calc-row { display: flex; justify-content: space-between; padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.calc-row:last-child { border-bottom: 0; }
.calc-row.minus span:last-child { color: var(--danger); }
.calc-row.total { background: var(--primary-50); font-weight: 800; font-size: 1.1rem; color: var(--primary); }
.success-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-50); color: var(--accent); display: grid; place-items: center; margin: 0 auto 1rem; }
.success-mark .icon { width: 34px; height: 34px; stroke-width: 2.5; }

.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; font-weight: 550; word-break: break-word; }

/* Lista em cartões (mobile) */
.list { display: flex; flex-direction: column; gap: .6rem; }
.list-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; display: flex; justify-content: space-between; gap: .75rem; cursor: pointer; }
.list-item:hover { border-color: var(--primary); }
.list-item .route { font-weight: 600; font-size: .92rem; }
.list-item .meta { font-size: .8rem; color: var(--muted); }
.list-item .amount { text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; animation: pop .15s ease-out; }
.modal.lg { max-width: 860px; }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--surface); padding: .75rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .92rem; animation: pop .15s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--accent); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.chart-box { position: relative; height: 280px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(circle at 20% 0%, var(--primary-50), transparent 55%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { border: 0; justify-content: center; font-size: 1.1rem; padding: 0 0 1rem; }
.auth-card .brand-mark { width: 42px; height: 42px; font-size: .95rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: .9rem; flex-wrap: wrap; gap: .5rem; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3rem; }
.pw-wrap button { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: .35rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .55rem 0; border-bottom: 1px dashed var(--border); display: flex; justify-content: space-between; gap: 1rem; }
.timeline li:last-child { border-bottom: 0; }
pre.json { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem; font-size: .78rem; overflow: auto; max-height: 220px; margin: 0; white-space: pre-wrap; word-break: break-word; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .6rem .9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 85vw); transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 0 .75rem; }
  .topbar .menu-btn { display: inline-grid; }
  .user-chip .who { display: none; }
  .content { padding: 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .search-box { display: none; }
  .search-box.mobile-open { display: block; position: absolute; left: .5rem; right: .5rem; top: 10px; max-width: none; }
  .has-bottom-nav .content { padding-bottom: 88px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .68rem; color: var(--muted); padding: .3rem 0; font-weight: 600; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.fab .icon { background: var(--accent); color: var(--on-accent); width: 44px; height: 44px; padding: 10px; border-radius: 50%; margin-top: -18px; box-shadow: var(--shadow-lg); }
  .hero .balance { font-size: 1.9rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .8rem; }
  .kpi .value { font-size: 1.2rem; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; }
  .toasts { left: 1rem; right: 1rem; bottom: 90px; }
  .page-head h1 { font-size: 1.25rem; }
  .filters .field { max-width: none; }
  .hide-mobile { display: none !important; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
}
@media (min-width: 641px) { .show-mobile { display: none !important; } }
@media print {
  .sidebar, .topbar, .bottom-nav, .actions, .filters, .pager { display: none !important; }
  .layout { display: block; }
  .card { box-shadow: none; }
}

/* ---------- Imagem do Bilhete Único Corporativo ---------- */
.bu-card {
  container-type: inline-size; position: relative; width: 100%; max-width: 420px; aspect-ratio: 85.6 / 54;
  border-radius: 4.5cqw; overflow: hidden; color: #1d1d1b; font-family: Arial, "Helvetica Neue", sans-serif;
  background:
    linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .22) 52%, transparent 64%),
    linear-gradient(160deg, #fbe62d 0%, #f6dc12 55%, #efd10b 100%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.bu-card .bu-logo { position: absolute; left: 7%; top: 8%; display: flex; flex-direction: column; align-items: flex-start; }
.bu-card .bu-logo svg { width: 17cqw; height: auto; }
.bu-card .bu-logo b { font-style: italic; font-weight: 900; font-size: 5.2cqw; line-height: .95; letter-spacing: -.02em; text-transform: uppercase; }
.bu-card .bu-type { position: absolute; left: 7%; top: 47%; font-weight: 700; font-size: 7.4cqw; letter-spacing: .01em; }
.bu-card .bu-holder { position: absolute; right: 6%; bottom: 10%; text-align: right; font-weight: 700; line-height: 1.2; }
.bu-card .bu-holder .n1 { font-size: 4.3cqw; text-transform: uppercase; }
.bu-card .bu-holder .n2 { font-size: 4.3cqw; }
.bu-card .bu-holder .num { font-size: 5.4cqw; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.bu-card .bu-holder .num.empty { opacity: .45; font-weight: 700; }
.bu-card .bu-status { position: absolute; right: 6%; top: 9%; background: #1d1d1b; color: #fbe62d; font-size: 3.4cqw; font-weight: 700; padding: .4cqw 2cqw; border-radius: 99px; text-transform: uppercase; }
.bu-card.muted-card { filter: grayscale(.7); opacity: .8; }
.card-figure { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.card-figure figcaption { font-size: .8rem; color: var(--muted); }

/* ---------- Atalhos de endereço ---------- */
.addr-shortcuts { margin-top: .5rem; display: flex; flex-direction: column; gap: .35rem; }
.addr-shortcuts .lbl { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.addr-shortcuts .row { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.addr-chip { flex-shrink: 0; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: .4rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.addr-chip:hover { border-color: var(--primary); }
.addr-chip.unit { background: var(--primary-50); border-color: color-mix(in srgb, var(--primary) 35%, transparent); color: var(--primary); font-weight: 600; }
.addr-chip.unit small { font-weight: 500; opacity: .85; }
.swap-btn { margin: -.35rem 0 .6rem; }
.steps { display: flex; gap: .5rem; margin-bottom: 1rem; font-size: .8rem; color: var(--muted); }
.steps span { flex: 1; border-top: 3px solid var(--border); padding-top: .3rem; }
.steps span.on { border-color: var(--primary); color: var(--primary); font-weight: 700; }

/* Faixa "Instale o aplicativo" */
.install-banner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: 1rem 1.5rem 0; }
@media (max-width: 900px) { .install-banner { margin: .75rem 1rem 0; } }
/* App instalado (tela cheia): respeita a área do relógio/notch */
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); } }

/* ---------- Marcas (POT e Rede Cidadã) ---------- */
.brand-icon { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.auth-card .brand-icon { width: 44px; height: 44px; border-radius: 12px; }
/* Faixa de logos: sempre em fundo claro, para as cores oficiais funcionarem nos dois temas */
.partners { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1rem; padding: .7rem 1rem; background: #ffffff; border: 1px solid #e2e7ef; border-radius: var(--radius); }
.partners .logo-pot { height: 42px; width: auto; }
.partners-sep { width: 1px; align-self: stretch; background: #e2e7ef; }
.partners-mgmt { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; }
.partners-mgmt small, .sidebar-mgmt small { font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: #5f6b7d; font-weight: 700; }
.partners .logo-rc { height: 18px; width: auto; }
.sidebar-mgmt { display: inline-flex; flex-direction: column; gap: .2rem; background: #ffffff; border: 1px solid #e2e7ef; border-radius: 8px; padding: .45rem .6rem; margin-bottom: .5rem; }
.sidebar-mgmt .logo-rc { height: 14px; width: auto; }

/* Termo de troca assinado */
.signed-toggle { font-size: .85rem; white-space: nowrap; justify-content: flex-end; }
.signed-toggle input:checked + span { color: var(--accent); font-weight: 700; }

/* Trajeto rápido (ida/volta e frequentes) */
.trips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.trip-btn { display: flex; flex-direction: column; gap: .2rem; text-align: left; padding: .7rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.trip-btn:hover { border-color: var(--primary); }
.trip-btn.suggested { border-color: color-mix(in srgb, var(--primary) 55%, transparent); background: var(--primary-50); }
.trip-btn.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.trip-btn .trip-title { font-weight: 700; font-size: .92rem; }
.trip-btn .trip-route { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-btn.small .trip-title { font-weight: 600; font-size: .85rem; }
.addr-chip.home { background: var(--accent-50); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); font-weight: 600; }
.addr-chip.home small { font-weight: 500; opacity: .85; }

/* ---------- Recarga do colaborador e edição de registro */
.calc-row.plus span:last-child { color: var(--accent); }
.recharge-balance { display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap; padding: 1rem; margin-bottom: 1rem; border-radius: var(--radius-sm); background: var(--primary-50); }
.recharge-balance small { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.recharge-balance strong { font-size: 1.25rem; }
.rc-steps { margin: 0 0 1rem; padding-left: 1.2rem; }
.rc-steps li { margin-bottom: .25rem; }
.edit-usage { padding: .15rem .5rem; min-height: 0; font-size: .8rem; }
.edit-usage svg { width: 14px; height: 14px; }

/* ---------- Sem internet, conferência de saldo, previsão e notificações */
.offline-bar { position: fixed; left: 0; right: 0; top: 0; z-index: 90; padding: .45rem 1rem; background: #7a4b00; color: #fff; font-size: .85rem; text-align: center; }
body.is-offline .topbar { margin-top: 2.1rem; }
.check-result { margin-top: 1rem; }
.forecast-tile .value { font-size: 1.15rem !important; }
.forecast-tile .bar { height: 6px; border-radius: 99px; background: var(--border); margin-top: .5rem; overflow: hidden; }
.forecast-tile .bar span { display: block; height: 100%; background: var(--accent); }
.forecast-tile.warn .bar span { background: #d97706; }
.forecast-tile.danger .bar span { background: var(--danger); }
.offline-queue .list-item { align-items: center; }
.push-card { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ---------- Login único em outros sistemas */
.sso-card { max-width: 480px; margin: 2rem auto; }
.sso-head { display: flex; align-items: center; gap: .75rem; font-size: 1.05rem; }
.sso-head img { border-radius: 12px; }
.sso-arrow { color: var(--muted); font-size: 1.4rem; }
.sso-wait { text-align: center; padding: 1.5rem 0; }
.sso-wait svg { width: 32px; height: 32px; color: var(--primary); }

/* ---------- Segurança: verificação em 2 etapas e backups */
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.qr-box { display: flex; justify-content: center; margin: 1rem 0 .5rem; }
.qr-box img { background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--border); }
.secret-key { word-break: break-all; letter-spacing: .05em; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-top: .75rem; }
.recovery-codes span { padding: .55rem; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 1.05rem; }

/* Avisos da coordenação */
.aud-mode { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-bottom: .75rem; }
.aud-pick { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: .75rem; }
.aud-pick > p { grid-column: 1 / -1; margin: 0; }
.aud-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; margin: 0; max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: .35rem; }
.aud-group legend { font-weight: 700; font-size: .85rem; padding: 0 .3rem; }
.ann-item { color: inherit; text-decoration: none; align-items: center; }
.ann-item.unread { border-left: 4px solid var(--primary); }
.ann-item.important.unread { border-left-color: var(--danger); }
.ann-snippet { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; overflow-wrap: anywhere; }
.ann-stats { min-width: 140px; text-align: right; }
.ann-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 1rem; }
.ann-important { border-left: 4px solid var(--danger); }
.ann-banner { display: block; text-decoration: none; }
.ann-banner:hover { filter: brightness(.97); }
.read-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: .25rem 0; }
.read-bar span { display: block; height: 100%; background: var(--accent); }
@media (max-width: 600px) { .ann-item { flex-direction: column; align-items: stretch; } .ann-stats { text-align: left; } }