/* Tesourix — light by default (what users expect), dark on request.
   Spacing scale: 4 · 8 · 12 · 16 · 24 · 32 px. */
:root {
  --bg: #f4f5f7; --fg: #111827; --fg-2: #374151; --muted: #4b5563; --card: #ffffff; --line: #e5e7eb; --line-strong: #d1d5db;
  --input-border: #8a919c;
  --grid: #e3e6ea; --head: #f3f4f6; --hover: #f3f6f9; --selected: #ecf7f5; --side: #fbfbfc;
  --accent: #0f766e; --accent-fg: #ffffff; --accent-soft: #e7f5f3; --accent-ring: rgba(15, 118, 110, .2);
  --danger: #c0352b; --danger-soft: #fdecea; --warn: #9a5b00; --warn-soft: #fff5e0; --ok: #15803d; --ok-soft: #e8f6ec;
  --info: #3b5bdb; --info-soft: #edf2ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05); --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --radius: 12px; --side-w: 236px;
  color-scheme: light;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #0e1116; --fg: #e5e7eb; --fg-2: #cbd5e1; --muted: #9ca3af; --card: #161a21; --line: #262b33; --line-strong: #353b45;
  --input-border: #6b7280;
  --grid: #2a3039; --head: #1b2028; --hover: #1d232c; --selected: #13302d; --side: #12161c;
  --accent: #2bb5a6; --accent-fg: #04201d; --accent-soft: #10302d; --accent-ring: rgba(43, 181, 166, .28);
  --danger: #f2756b; --danger-soft: #3a1714; --warn: #f0b04a; --warn-soft: #33270e; --ok: #4cc488; --ok-soft: #0f2c1e;
  --info: #8ea7ff; --info-soft: #1b2340;
  --shadow: none; --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-padding-top: 72px; scroll-padding-bottom: 150px; }
@media (min-width: 960px) { html { scroll-padding-bottom: 80px; } }
body { background: var(--bg); color: var(--fg); font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
h2 { margin: 0 0 12px; font-size: .95rem; }
p { margin: 0 0 8px; }
.ico { width: 17px; height: 17px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; min-height: 0; margin: 0; cursor: pointer; }

/* ---------- controls ---------- */
input, select, textarea, button, .button {
  font: inherit; width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card); color: var(--fg);
}
input, select, textarea { border-color: var(--input-border); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-ring); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
textarea { resize: vertical; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: auto; cursor: pointer;
  font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow); }
button:hover, .button:hover { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
.primary, .primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.primary:hover { filter: brightness(1.07); }
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.ghost:hover { color: var(--fg); }
.link { min-height: 0; padding: 2px 4px; border: 0; background: none; box-shadow: none; color: var(--accent); }
.icon-btn { width: 38px; height: 38px; min-height: 38px; padding: 0; display: grid; place-items: center; border-radius: 8px; }
.small-btn { min-height: 32px; padding: 4px 10px; font-size: .8rem; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .86rem; font-weight: 600; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

/* ---------- shell ---------- */
.shell { min-width: 0; }
main { max-width: 1440px; margin: 0 auto; padding: 16px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 16px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
/* Phones: the page's main action shows only its icon, so the title fits. */
@media (max-width: 599.98px) {
  .head-act .button:has(.ico) { padding-inline: 10px; }
  .head-act .button:has(.ico) > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.top-logo { border-radius: 7px; }
.head-act, .head-act .act-form, .head-act .pop { display: inline-flex; }
.dev-switch { padding: 4px 10px; border: 1px dashed var(--warn); border-radius: 999px; color: var(--warn); font-size: .75rem;
  font-weight: 700; text-decoration: none; white-space: nowrap; }
.count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--hover); color: var(--muted);
  font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.count.urgent { background: var(--accent); color: var(--accent-fg); }
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); font-size: .85rem; font-weight: 700; }

/* guest pages (login, signup): centered with the logo */
body.guest .top { position: static; justify-content: center; background: transparent; border: 0; }
body.guest .top h1 { flex: none; color: var(--muted); font-size: 1.05rem; font-weight: 600; }
body.guest main { max-width: 480px; }
body.guest main:has(.form-grid) { max-width: 760px; }
.guest-brand { display: flex; justify-content: center; padding: 8vh 16px 0; }
[data-theme="dark"] .guest-brand img { filter: brightness(1.6) saturate(.8); }

/* mobile: bottom tabs */
.sidebar { display: none; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; overflow-x: auto; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 56px;
  padding: 8px 4px; color: var(--muted); font-size: .68rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a .ico { width: 22px; height: 22px; }
.tabs a span:not(.count) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs .count { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; min-width: 18px; padding: 0 5px; line-height: 17px; }
.tabs .count:not(.urgent) { background: var(--line-strong); color: var(--fg); }
body.has-nav { padding-bottom: 72px; }

/* desktop: sidebar following the workflow path */
@media (min-width: 960px) {
  body.has-nav { padding-bottom: 0; padding-left: var(--side-w); }
  body.has-nav.sb-collapsed { padding-left: 72px; }
  .tabs, .hide-desktop { display: none !important; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 7; width: var(--side-w); display: flex; flex-direction: column; gap: 6px;
    padding: 14px 12px; background: var(--side); border-right: 1px solid var(--line); transition: width .15s; }
  .sb-collapsed .sidebar { width: 72px; }
  .sb-collapsed .sidebar .lbl, .sb-collapsed .side-nav .count, .sb-collapsed .side-sec { display: none; }
  .sb-collapsed .quick { padding: 0; }
  .sb-collapsed .collapse-btn .ico { transform: scaleX(-1); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 10px; color: var(--fg); font-size: 1.1rem; font-weight: 800;
    letter-spacing: -.02em; text-decoration: none; }
  .brand img { border-radius: 7px; }
  .quick { width: 100%; min-height: 40px; margin-bottom: 4px; }
  .side-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
  .side-sec { padding: 14px 10px 4px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
  .side-nav a, .side-link { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 38px; padding: 8px 10px;
    border: 0; border-radius: 8px; background: none; box-shadow: none; color: var(--fg); font: inherit; font-size: .9rem; font-weight: 500;
    text-align: left; text-decoration: none; cursor: pointer; }
  .side-nav a .ico, .side-link .ico { color: var(--muted); }
  .side-nav a:hover, .side-link:hover { background: var(--hover); }
  .side-nav a[aria-current="page"] { background: var(--card); box-shadow: var(--shadow), 0 0 0 1px var(--line); font-weight: 650; }
  .side-nav a[aria-current="page"] .ico { color: var(--accent); }
  .side-link.dev, .side-link.dev .ico { color: var(--warn); }
  .side-foot { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--line); }
  .who { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 6px; }
  .who .lbl { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .who form.lbl { flex: none; }
  .who strong, .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who small { color: var(--muted); font-size: .76rem; }
  .top { padding: 16px 28px 8px; background: var(--bg); border-bottom: 0; }
  .top h1 { font-size: 1.4rem; }
  main { padding: 4px 28px 32px; }
}
@media (max-width: 959.98px) { .hide-mobile { display: none !important; } }
.switch { position: relative; flex: none; width: 32px; height: 18px; margin-left: auto; border-radius: 999px; background: var(--muted);
  transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
[aria-checked="true"] .switch { background: var(--accent); }
[aria-checked="true"] .switch::after { transform: translateX(14px); }

/* ---------- messages ---------- */
.flash { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(560px, calc(100vw - 32px)); padding: 10px 10px 10px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 500;
  transition: opacity .35s, transform .35s, visibility 0s; }
.toast > .ico { color: var(--ok); }
.toast.error { border-color: var(--danger); background: var(--danger-soft); }
.toast.error > .ico { color: var(--danger); }
.toast.gone { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; visibility: hidden;
  transition: opacity .35s, transform .35s, visibility 0s .35s; }
@media (min-width: 960px) { .toast { bottom: 24px; left: calc(50% + var(--side-w) / 2); } }

/* ---------- status ---------- */
.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: var(--hover); color: var(--muted);
  font-size: .74rem; font-weight: 600; white-space: nowrap; }
.s-APPROVED { background: var(--info-soft); color: var(--info); }
.s-PAID, .s-ACTIVE { background: var(--ok-soft); color: var(--ok); }
.s-REJECTED, .s-CANCELLED, .s-DISABLED { background: var(--danger-soft); color: var(--danger); }
.s-PENDING_APPROVAL, .s-CHANGES_REQUESTED, .s-PENDING_REVIEW, .s-PENDING { background: var(--warn-soft); color: var(--warn); }
.paid { display: inline-block; min-width: 38px; padding: 1px 7px; border-radius: 6px; background: var(--hover); color: var(--muted);
  font-size: .74rem; font-weight: 600; text-align: center; }
.paid.yes { background: var(--ok-soft); color: var(--ok); }
.due-overdue { color: var(--danger); font-weight: 650; }
.due-soon { color: var(--warn); font-weight: 650; }
.warn-text { color: var(--warn); font-weight: 700; }

/* ---------- cards & blocks ---------- */
.card { display: block; margin: 0 0 12px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.big { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.lead { margin: 4px 0 14px; font-size: 1.05rem; }
.notes { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--head); white-space: pre-line; }
.block-title { margin: 20px 2px 10px; font-size: .95rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: .76rem; font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
code { font-size: .88em; overflow-wrap: anywhere; }
.plain { margin: 4px 0; padding: 0; list-style: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.att { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
.att img, .att .doc { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.att .doc { display: grid; place-items: center; background: var(--head); color: var(--muted); font-weight: 700; }
.steps, .timeline { margin: 0; padding: 0; list-style: none; }
.steps > li { position: relative; display: flex; gap: 10px; padding-bottom: 12px; }
.steps > li:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.step-dot { flex: none; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; background: var(--line-strong); }
.st-APPROVED .step-dot { background: var(--ok); }
.st-PENDING .step-dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.st-REJECTED .step-dot { background: var(--danger); }
.st-CHANGES_REQUESTED .step-dot { background: var(--warn); }
.timeline li { display: flex; flex-direction: column; padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
details.card > summary { display: flex; align-items: center; gap: 8px; min-height: 28px; cursor: pointer; font-weight: 600; }
details.card > summary .count { margin-left: 0; }
.empty { padding: 40px 16px; text-align: center; }
.empty p { margin: 0 0 14px; color: var(--muted); }

/* tiles: the numbers that matter on each list */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-strong); }
.tile.ok::before { background: var(--ok); } .tile.warn::before { background: var(--warn); } .tile.bad::before { background: var(--danger); }
.tile strong { font-size: 1.3rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .8rem; font-weight: 600; }
.tile-hint { color: var(--muted); font-size: .75rem; }

/* two-column page (requisition, profile) */
.detail { display: grid; gap: 0 16px; }
@media (min-width: 960px) {
  .detail { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .col-side { position: sticky; top: 72px; }
}
.action-card { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
@media (max-width: 959.98px) {
  .col-side { display: flex; flex-direction: column; }
  /* the requisition's "Próximo passo" becomes a fixed bar above the tabs */
  .col-side .sticky { position: fixed; left: 8px; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 6;
    margin: 0; padding: 10px; box-shadow: var(--shadow-lg); }
  .sticky > .card-head, .sticky > .notes { display: none; }
  .col-side .sticky .actionbar { flex-direction: row; margin-top: 0; }
  .col-side .sticky .actionbar > * { flex: 1 1 30%; }
  main:has(.sticky) { padding-bottom: 150px; }
}

/* action bar: at most three buttons, the rest under "Mais" */
.actionbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.card > .actionbar:first-child { margin-top: 0; }
.actionbar > *, .actionbar .act-form, .actionbar .pop > summary { flex: 1 1 auto; }
.actionbar .button, .actionbar summary.button { width: 100%; }
.action-card .actionbar { flex-direction: column; }
.act-form { display: inline-flex; margin: 0; }

/* popovers: action dialogs (bottom sheet on phones); anchored menus for filters and "Mais" */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-body { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  text-align: left; white-space: normal; }
.pop:not(.fdrop):not(.more)[open]::before { content: ""; position: fixed; inset: 0; z-index: 30; background: rgba(16, 24, 40, .38); }
.pop:not(.fdrop):not(.more) > .pop-body { position: fixed; z-index: 31; top: 16vh; left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px)); max-height: 72vh; overflow-y: auto; }
.fdrop > .pop-body, .more > .pop-body { position: absolute; z-index: 10; top: calc(100% + 6px); left: 0; min-width: 220px; max-height: 340px;
  overflow-y: auto; padding: 6px; }
.more > .pop-body { left: auto; right: 0; }
.menu .check { padding: 8px; border-radius: 6px; white-space: nowrap; }
.menu .check:hover { background: var(--hover); }
.menu-list { display: flex; flex-direction: column; gap: 2px; min-width: 250px; }
.menu-list .button, .menu-list summary.button { width: 100%; justify-content: flex-start; border-color: transparent; box-shadow: none; }
.menu-list .act-form, .menu-list .pop { display: block; width: 100%; }
@media (max-width: 959.98px) {
  .pop:not(.fdrop):not(.more) > .pop-body { top: auto; bottom: 0; left: 0; right: 0; transform: none; width: auto;
    border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .fdrop > .pop-body, .more > .pop-body { position: fixed; z-index: 31; top: auto; bottom: 0; left: 0; right: 0; max-height: 60vh;
    border-radius: 16px 16px 0 0; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
}

/* ---------- forms ---------- */
fieldset { min-width: 0; margin: 0; border: 1px solid var(--line); }
legend { padding: 0 6px; font-weight: 700; }
.form fieldset.card { padding-top: 10px; }
.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 960px) { .form-grid { grid-template-columns: 1fr 1fr; max-width: 1100px; } }
.form-grid .form-actions { grid-column: 1 / -1; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { min-width: 0; }
.field > span { display: block; }
.fields .wide, .pop-body .field, .pop-body .checks { grid-column: 1 / -1; }
.pop-body.stack { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 599.98px) { .fields { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; border-radius: 8px; }
.days { display: flex; flex-direction: column; gap: 8px; padding: 8px 12px 12px; border-radius: 8px; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.day-chips:empty::before { content: "Nenhum dia ainda."; color: var(--muted); font-size: .875rem; }
.day-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--fg); font-size: .875rem; }
.day-chip button { min-width: 28px; min-height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  font-size: 1rem; line-height: 1; cursor: pointer; }
.day-chip button:hover { background: var(--hover); color: var(--danger); }
.day-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.day-add label { display: flex; flex: 1 1 140px; flex-direction: column; gap: 2px; min-width: 0; }
.day-add .button { flex: 0 0 auto; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 4px 0 12px; }
.sticky-actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4; padding: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
@media (min-width: 960px) { .sticky-actions { bottom: 12px; } }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 50%; background: var(--accent);
  color: var(--accent-fg); font-size: .75rem; }
.pix-card { margin: 0; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.pix-card.ok { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--fg); }
.pix-card.bad { border-style: solid; border-color: var(--danger); color: var(--danger); }

/* segmented tabs (Admin, Listas) */
.segmented { display: flex; gap: 4px; width: fit-content; max-width: 100%; margin-bottom: 14px; padding: 4px; overflow-x: auto;
  background: var(--hover); border-radius: 10px; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; color: var(--muted);
  font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.segmented a[aria-current="page"] { background: var(--card); color: var(--fg); box-shadow: var(--shadow), 0 0 0 1px var(--line); }

/* ---------- list panel: filters, spreadsheet table, pager ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.fdrop > summary { min-height: 36px; padding: 6px 12px; }
.fdrop > summary .ico { width: 15px; height: 15px; color: var(--muted); }
.fdrop > summary.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; margin-left: auto; }
.search .ico { position: absolute; top: 50%; left: 11px; transform: translateY(-50%); color: var(--muted); }
.search input { min-height: 36px; padding-left: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.chip-filter { min-height: 28px; padding: 2px 10px; border-color: transparent; border-radius: 999px; background: var(--accent-soft);
  box-shadow: none; color: var(--accent); font-size: .78rem; font-weight: 500; }

/* spreadsheet look: gridlines, dense rows, fixed columns, no sideways scroll */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.panel.compact .table-wrap { border-top: 0; }
.sheet { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.sheet th, .sheet td { height: 34px; padding: 5px 9px; border: 1px solid var(--grid); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; text-align: left; vertical-align: middle; }
.sheet tr > :first-child { border-left: 0; }
.sheet tr > :last-child { border-right: 0; }
.sheet thead th { position: sticky; top: 0; z-index: 1; border-top: 0; background: var(--head); color: var(--fg-2); font-size: 12px; font-weight: 600; }
.sheet th[data-sort] { user-select: none; }
.sheet th[data-sort] > button { cursor: pointer; }
.sheet th[data-sort]:hover { color: var(--fg); }
.sheet th[data-sort] > button, .sheet th[data-sort] > button:hover { display: inline-block; width: auto; max-width: 100%; min-height: 0; padding: 0;
  border: 0; border-radius: 4px; background: none; box-shadow: none; color: inherit; font: inherit; text-align: inherit; overflow: hidden;
  text-overflow: ellipsis; vertical-align: middle; cursor: pointer; }
.sheet th[aria-sort="ascending"]::after { content: " ▲"; font-size: .75em; }
.sheet th[aria-sort="descending"]::after { content: " ▼"; font-size: .75em; }
.sheet tbody tr[data-href] { cursor: pointer; }
.sheet tbody tr:hover td { background: var(--hover); }
.sheet tbody tr.selected td { background: var(--selected); }
.sheet tbody tr:last-child td { border-bottom: 0; }
.sheet .num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.num { font-weight: 600; }
.sheet td a { font-weight: 600; text-decoration: none; }
.sheet td .muted { font-weight: 400; }
.sheet .group-row td { height: 30px; background: var(--head); font-size: 12px; font-weight: 700; overflow: visible; }
/* fixed column widths: Descrição and "wide" columns take the rest */
.sheet .sel { width: 38px; }
.c-competencia, .c-venc, .c-pagoem { width: 92px; }
.c-valor { width: 112px; }
.c-status { width: 140px; }
.c-pago { width: 58px; }
.c-codigo { width: 58px; }
.c-nf { width: 80px; }
.c-parcela { width: 66px; }
.c-estab, .c-categoria { width: 124px; }
.c-gestor { width: 112px; }
.c-fornecedor { width: 190px; }
.sheet th.acts { width: 220px; }
.sheet td.acts { text-align: right; white-space: normal; } /* row actions wrap instead of being clipped */
.sheet td.acts > * { margin-left: 4px; }
.sheet td.acts .act-form, .sheet td.acts .pop { display: inline-flex; }
.sheet td.acts .button, .sheet td.acts summary.button { min-height: 28px; padding: 2px 10px; box-shadow: none; font-size: .78rem; }
/* lower-priority columns give way so the table fits and Descrição keeps ~200px+ */
@media (max-width: 1439.98px) { .sheet .p3 { display: none; } }
@media (max-width: 1199.98px) { .sheet .p2 { display: none; } }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 12px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem; }
.pager b { color: var(--fg); font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.per { flex-direction: row; align-items: center; gap: 6px; font-size: .83rem; font-weight: 500; }
.per select { width: auto; min-height: 32px; padding: 3px 8px; }
.selinfo { display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border-radius: 8px; background: var(--accent-soft);
  color: var(--accent); }
.selinfo[hidden] { display: none; }
.selinfo b { color: var(--accent); }
.no-results { padding: 24px; }

/* cards: the same rows on phones and tablets */
.cards { display: flex; flex-direction: column; gap: 8px; }
.req { position: relative; display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px; }
.req .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.req .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.col-main, .col-side { min-width: 0; } /* truncated lines inside don't widen the page */
.req .row > .ellipsis { min-width: 0; } /* a long title shrinks with … instead of widening the page */
.req strong { font-variant-numeric: tabular-nums; }
.thumb { flex: none; width: 50px; height: 50px; border-radius: 8px; object-fit: cover; background: var(--hover); }
.thumb.none { display: grid; place-items: center; color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stretched { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-acts { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-acts .button, .card-acts summary.button { min-height: 34px; padding: 4px 12px; font-size: .82rem; }
.day { display: flex; justify-content: space-between; margin: 10px 2px 0; color: var(--muted); font-size: .85rem; }
.card .panel.compact, details.card .panel { margin: 10px -16px -16px; border: 0; border-radius: 0 0 var(--radius) var(--radius); box-shadow: none; }

@media (max-width: 959.98px) {
  main { padding: 12px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 8px 10px; }
  .tile strong { font-size: .95rem; }
  .tile-label { font-size: .7rem; }
  .tile-hint { display: none; }
  .panel { background: transparent; border: 0; box-shadow: none; }
  .filterbar, .chips { padding-left: 0; padding-right: 0; }
  .filters { order: 2; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .search { order: 1; max-width: none; margin: 0; }
  .pager { padding: 10px 0; border-top: 0; }
  .panel.compact .cards { padding: 0 8px 8px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Onboarding: optional form sections, Pix toggle, how-to, install hint */
details.optional > summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; }
details.optional > summary::-webkit-details-marker { display: none; }
details.optional[open] > summary { margin-bottom: 8px; }
.toggle { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); }
.field[hidden] { display: none; }

.howto { margin: 4px 0 0; padding-left: 22px; }
.howto li { margin: 6px 0; }
.install-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; padding: 12px 14px;
  background: var(--info-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.install-hint > span { flex: 1 1 200px; }

/* In-app guide (/ajuda) */
.guide { max-width: 860px; line-height: 1.55; }
.guide h2 { margin: 0 0 8px; font-size: 1.25rem; }
.guide h3 { margin: 18px 0 4px; font-size: 1rem; }
.guide p, .guide ol, .guide ul { margin: 6px 0 10px; }
.guide ol, .guide ul { padding-left: 22px; }
.guide li { margin: 4px 0; }
.shot { margin: 12px 0 16px; }
.shot img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.shot.phone img { max-width: 300px; }
.shot figcaption { margin-top: 6px; font-size: .85rem; color: var(--muted); }
.guide-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.guide-table th, .guide-table td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.guide-table th { background: var(--head); }
@media (max-width: 600px) { .guide-table th:first-child, .guide-table td:first-child { width: 38%; } }
