:root {
  color-scheme: light;
  --primary: #173c5b;
  --primary-strong: #102b43;
  --primary-soft: #eaf1f6;
  --surface: #ffffff;
  --background: #f4f6f8;
  --success: #167654;
  --success-soft: #e5f4eb;
  --warning: #96600a;
  --warning-soft: #fff3dc;
  --danger: #a33d43;
  --danger-soft: #fae9e9;
  --review: #7053a4;
  --review-soft: #f0eafb;
  --text: #1a2b3a;
  --text-muted: #617282;
  --border: #dfe6ec;
  --shadow: 0 12px 34px rgba(16, 43, 67, .045);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
}

/* Counter receipts: keep the received amount readable on phones and tablets. */
.user-receipts { max-width: 960px; margin: 0 auto; display: grid; gap: 1.3rem; }
.user-receipts .card { min-width: 0; }
.user-receipts .receipt-hero { text-align: center; padding: clamp(1.5rem, 5vw, 3.5rem) 1rem; }
.user-receipts .receipt-hero h1 { font-size: clamp(1.3rem, 3vw, 1.9rem); }
.user-receipts .receipt-latest { display: grid; justify-items: center; gap: .75rem; margin-top: 1.5rem; }
.user-receipts .receipt-latest[hidden] { display: none; }
.user-receipts .receipt-hero .receipt-amount { font-size: clamp(2rem, 6vw, 4.5rem); letter-spacing: -.04em; line-height: 1.15; }
.user-receipts .receipt-list { list-style: none; padding: 0; margin: 0; }
.user-receipts .receipt-row { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1.1fr) minmax(0, 1fr); align-items: center; gap: .75rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.user-receipts .receipt-amount { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.user-receipts .receipt-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.user-receipts .receipt-payer { overflow-wrap: anywhere; }
.user-receipts .receipt-date { display: flex; align-items: end; flex-wrap: wrap; gap: 1rem; }
.user-receipts .receipt-date label { flex: 1; max-width: 20rem; margin: 0; }
@media (max-width: 600px) {
  .user-receipts .receipt-row { grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
  .user-receipts .receipt-row .receipt-payer { text-align: right; }
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid #4c93c7; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.15rem); letter-spacing: -.035em; line-height: 1.2; margin-bottom: .55rem; }
h2 { font-size: 1.18rem; letter-spacing: -.02em; line-height: 1.3; margin-bottom: .7rem; }
h3 { font-size: 1rem; margin-bottom: .55rem; }
p { color: var(--text-muted); }
small, .help-text { color: var(--text-muted); font-size: .82rem; }
.muted { color: var(--text-muted); }
.eyebrow { display: block; color: #50708b; font-weight: 750; font-size: .73rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .55rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin: 1.65rem 0 .75rem; }
.section-heading h2, .section-heading p { margin: 0; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head p { margin: .3rem 0 0; }
.page-actions, .form-actions, .card-actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }

/* Shell */
.app-body { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 242px; display: flex; flex-direction: column; background: var(--primary-strong); color: #dce6ee; padding: 1.45rem .9rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; margin: 0 .65rem 1.7rem; color: white; font-size: 1.36rem; font-weight: 780; letter-spacing: -.04em; }
.brand:hover, .mobile-brand:hover { color: white; text-decoration: none; }
.brand-mark { display: block; width: 34px; height: 34px; object-fit: contain; }
.brand-mark svg { width: 22px; height: 22px; }
.side-nav { display: flex; flex-direction: column; gap: .12rem; overflow-y: auto; scrollbar-width: thin; padding: 0 .15rem .7rem; }
.nav-label { padding: 1.05rem .78rem .38rem; color: #91a9b8; font-size: .64rem; letter-spacing: .115em; font-weight: 760; }
.side-nav a { display: block; padding: .65rem .8rem; border-radius: 8px; color: #c5d5df; font-size: .9rem; font-weight: 550; }
.side-nav a:hover, .side-nav a.is-active { color: white; background: rgba(255, 255, 255, .11); text-decoration: none; }
.side-nav a.is-active { font-weight: 700; box-shadow: inset 3px 0 0 #7cc5db; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #ffffff20; padding: 1rem .8rem 0; font-size: .75rem; color: #a8c0cd; }
.sidebar-foot-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #68c99e; margin-right: .4rem; }
.app-shell { min-width: 0; margin-left: 242px; flex: 1; display: flex; flex-direction: column; }
.topbar { height: 70px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 3vw, 2.2rem); }
.topbar-leading, .topbar-actions { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.topbar-context { color: var(--text-muted); font-size: .89rem; font-weight: 600; white-space: nowrap; }
.topbar-quick { font-weight: 700; font-size: .85rem; white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: .55rem; font-weight: 650; font-size: .86rem; white-space: nowrap; }
.user-avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); font-size: .79rem; }
.topbar form { margin: 0; }
.text-button { border: 0; background: none; padding: .4rem .1rem; color: var(--text-muted); font-size: .86rem; }
.text-button:hover { color: var(--primary); }
.mobile-brand, .menu-toggle { display: none; }
.main-content { width: min(100%, 1260px); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.4rem); flex: 1; }
.app-footer { color: #80909c; font-size: .76rem; padding: 1rem clamp(1.25rem, 3vw, 2.4rem) 1.5rem; }
.app-footer span { padding: 0 .3rem; }

/* Surfaces and components */
.card, .panel, .empty-state { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card, .panel { padding: 1.35rem; }
.card + .card, .panel + .panel { margin-top: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.1rem; }
.card-header h2, .card-header p { margin-bottom: 0; }
.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--text-muted); }
.empty-state h2, .empty-state h3 { color: var(--text); }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 1rem; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 1.4rem; }
.badge { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; min-height: 25px; border-radius: 6px; padding: .18rem .52rem; font-size: .69rem; font-weight: 760; letter-spacing: .045em; text-transform: uppercase; line-height: 1.2; white-space: nowrap; background: #edf1f4; color: #526374; }
.badge.pago, .badge.ativa, .badge.ativo, .badge.online, .badge.associada { color: var(--success); background: var(--success-soft); }
.badge.aguardando, .badge.recebida, .badge.processada { color: var(--warning); background: var(--warning-soft); }
.badge.cancelado, .badge.revogado, .badge.erro_parse { color: var(--danger); background: var(--danger-soft); }
.badge.expirado, .badge.inativa, .badge.inativo, .badge.offline, .badge.ignorada, .badge.duplicada { color: #576778; background: #edf1f4; }
.badge.revisao_necessaria { color: var(--review); background: var(--review-soft); }
.flash-stack { position: fixed; z-index: 70; top: 1rem; right: 1rem; width: min(400px, calc(100vw - 2rem)); display: grid; gap: .5rem; }
.flash { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border: 1px solid #eed7b5; border-radius: 10px; color: #6a4a1e; background: #fff9ee; box-shadow: 0 14px 30px #102b431f; }
.flash-success { color: #165c43; border-color: #cce9d8; background: #f1fbf5; }
.flash-error { color: #943b41; border-color: #efcbd0; background: #fff4f4; }
.flash button { flex: none; border: 0; background: none; color: inherit; font-size: 1.3rem; line-height: 1; padding: 0; }
.pwa-notices { position: fixed; z-index: 80; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); width: min(400px, calc(100vw - 2rem)); display: grid; gap: .55rem; pointer-events: none; }
.pwa-notice { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .72rem .85rem; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); box-shadow: 0 14px 38px #102b4326; font-size: .82rem; pointer-events: auto; }
.pwa-notice button { min-height: 38px; padding: .4rem .65rem; font-size: .78rem; white-space: nowrap; }
.pwa-notice .pwa-dismiss { min-width: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; color: var(--text-muted); font-size: 1.2rem; }
.pwa-offline { border-color: #eed7b5; background: #fff9ee; color: #6a4a1e; }
@media (display-mode: standalone) {
  [data-pwa-install-card], [data-pwa-ios] { display: none !important; }
}
.alert { padding: .9rem 1rem; border: 1px solid #eed7b5; border-radius: 9px; background: #fff9ee; color: #6a4a1e; }
.alert.error { border-color: #efcbd0; color: #943b41; background: #fff4f4; }
.alert.success { border-color: #cce9d8; color: #165c43; background: #f1fbf5; }

/* Forms and actions */
label { display: block; color: var(--text); font-size: .85rem; font-weight: 660; margin-bottom: 1rem; }
input, select, textarea { display: block; width: 100%; min-width: 0; min-height: 44px; padding: .68rem .8rem; margin-top: .38rem; border: 1px solid #cbd5de; border-radius: 8px; background: white; color: var(--text); }
input::placeholder, textarea::placeholder { color: #8b99a5; }
textarea { min-height: 90px; resize: vertical; overflow-wrap: anywhere; }
input:focus, select:focus, textarea:focus { border-color: #4c93c7; outline: 3px solid #4c93c72f; }
input[readonly] { background: #f7f9fa; }
label small { display: block; margin-top: .35rem; font-weight: 400; }
button, .button, .action-link { display: inline-flex; justify-content: center; align-items: center; gap: .45rem; min-height: 44px; padding: .68rem 1rem; border: 1px solid var(--primary); border-radius: 8px; background: var(--primary); color: white; font-size: .86rem; font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none; }
button:hover, .button:hover, .action-link:hover { background: var(--primary-strong); color: white; text-decoration: none; }
button.secondary, .button.secondary { color: var(--primary); background: white; border-color: #b8c8d4; }
button.secondary:hover, .button.secondary:hover { background: var(--primary-soft); }
button.danger, .button.danger { color: var(--danger); border-color: #e7bdc0; background: white; }
button.danger:hover, .button.danger:hover { background: var(--danger-soft); }
button.ghost, .button.ghost { border-color: transparent; color: var(--primary); background: transparent; }
button.ghost:hover, .button.ghost:hover { background: var(--primary-soft); }
button.big { width: 100%; font-size: 1rem; min-height: 52px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; margin-top: .4rem; }
.inline { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; margin: .6rem 0; }
.inline label { flex: 1 1 170px; margin: 0; }
.inline input, .inline select { margin-top: 0; }
.inline > input, .inline > select { width: auto; flex: 1 1 160px; }
.field-error { min-height: 1.2em; margin: .5rem 0; color: var(--danger); font-size: .86rem; }
.filter-panel { margin: 1rem 0; }
.filter-panel summary { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; color: var(--primary); font-weight: 700; padding: .4rem 0; }
.filters { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; padding: 1rem; margin-top: .45rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.filters label { flex: 1 1 145px; margin: 0; }
.filters input, .filters select { margin-top: .25rem; }
.filters .filter-actions { display: flex; align-items: end; gap: .5rem; flex-wrap: wrap; }

/* Lists, data and metrics */
.list { display: grid; gap: .55rem; }
.row { display: flex; align-items: center; gap: 1rem; min-width: 0; padding: .78rem 0; border-bottom: 1px solid var(--border); color: var(--text); }
.row:last-child { border-bottom: 0; }
a.row:hover { color: var(--primary); text-decoration: none; }
.row > * { min-width: 0; }
.row .row-end { margin-left: auto; text-align: right; }
.row small { color: var(--text-muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: white; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .9rem; border-bottom: 1px solid #edf0f3; text-align: left; vertical-align: middle; font-size: .84rem; }
th { color: var(--text-muted); background: #fafbfd; font-size: .72rem; font-weight: 740; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
td a { font-weight: 700; }
.mono, code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82em; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.stat-card { padding: 1.1rem 1.2rem; }
.stat-card .stat-label { color: var(--text-muted); font-size: .78rem; font-weight: 650; }
.stat-card strong { display: block; margin-top: .55rem; font-size: clamp(1.35rem, 2.4vw, 1.8rem); line-height: 1.2; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-card small { display: block; margin-top: .38rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.dashboard-grid .card { min-width: 0; margin: 0; }
.bar-list { display: grid; gap: .85rem; }
.bar-item-top { display: flex; justify-content: space-between; gap: .8rem; font-size: .85rem; }
.bar-item-top strong { white-space: nowrap; }
.bar-track, .progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e8edf1; }
.bar-track span, .progress-track span { display: block; height: 100%; border-radius: inherit; background: #467791; }
.bar-track { margin-top: .38rem; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; padding: 1.15rem; border-radius: 10px; background: #f7f9fa; text-align: left; }
.facts span { display: block; color: var(--text-muted); font-size: .76rem; }
.facts strong { display: block; margin-top: .22rem; font-size: .9rem; font-weight: 670; overflow-wrap: anywhere; }
.item-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.item-grid .card { min-width: 0; margin: 0; }
.item-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; color: var(--text-muted); font-size: .81rem; }
.key-mask { display: block; margin: .9rem 0; padding: .65rem .75rem; border-radius: 7px; background: #f5f8fa; color: #4a5e6e; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--border); margin: 1.2rem 0; }
.block { display: block; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; color: var(--text-muted); font-size: .84rem; }
.notification-details { max-width: 400px; text-align: left; }
.notification-details summary { cursor: pointer; color: var(--primary); font-weight: 700; white-space: nowrap; }
.notification-details p { margin: .55rem 0 0; overflow-wrap: anywhere; }
.candidate-list { display: grid; gap: .55rem; margin: .8rem 0 1rem; }
.candidate-card { display: flex; align-items: start; gap: .65rem; padding: .75rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.candidate-card:has(input:checked) { border-color: #467791; background: #f1f7fa; }
.candidate-card input { width: auto; min-height: auto; margin: .25rem 0 0; accent-color: var(--primary); }
.candidate-card small { margin-top: .2rem; font-weight: 400; }
.package-row { padding: .65rem 0; border-bottom: 1px solid var(--border); }
.package-row .inline { margin: 0 0 .35rem; }
.narrow-card { max-width: 690px; }
.statement-form { margin-top: 1.3rem; }

/* Specific screens */
.auth-body { min-height: 100vh; background: linear-gradient(140deg, #f5f8fa 0%, #edf3f6 100%); }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { width: min(100%, 420px); padding: clamp(1.5rem, 5vw, 2.3rem); }
.auth-card .brand { margin: 0 0 2rem; color: var(--primary-strong); }
.auth-logo { display: block; height: 52px; width: auto; max-width: 100%; }
.mobile-brand-logo { display: block; height: 28px; width: auto; }
.auth-card h1 { font-size: 1.75rem; }
.auth-card p { margin-bottom: 1.7rem; }
.auth-card button { width: 100%; }
.create-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr); gap: 1.5rem; align-items: start; }
.create-layout-user { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
.create-card { padding: clamp(1.25rem, 4vw, 2rem); }
.money-field { padding: 1rem 1.1rem; min-height: 88px; border: 1px solid #b7c9d5; border-radius: 10px; background: #f9fbfc; font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 720; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.money-field:focus { background: white; }
.create-card .help-text { display: block; margin: .65rem 0 1.45rem; }
.recent-card { padding: 1.2rem; }
.recent-card .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .6rem; }
.recent-card .row small { grid-column: 1; }
.recent-card .row .badge { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.latest-card { padding: 1.2rem; }
.latest-card .card-header { flex-wrap: wrap; }
.latest-card .empty-state { border: 0; box-shadow: none; padding: 1.5rem .5rem .5rem; }
.latest-charge { display: grid; gap: .35rem; padding: .85rem 0 .15rem; border-top: 1px solid var(--border); color: var(--text); min-width: 0; }
.latest-charge-top { display: flex; align-items: center; justify-content: space-between; gap: .65rem; flex-wrap: wrap; }
.latest-charge-top strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.latest-charge-meta { color: var(--text-muted); overflow-wrap: anywhere; }
.latest-charge small { display: block; }
.payment-card { width: min(100%, 620px); margin: 0 auto; text-align: center; padding: clamp(1.25rem, 4vw, 2rem); }
.payment-card .payment-value { font-size: clamp(2rem, 5vw, 2.65rem); font-weight: 760; line-height: 1.15; letter-spacing: -.04em; color: var(--text); margin: .65rem 0 .8rem; }
.payment-card .badge { margin-bottom: .55rem; }
.payment-card .recipient-line { margin: .65rem 0 0; color: var(--text); font-weight: 660; }
.payment-card .bank-line { color: var(--text-muted); font-size: .87rem; }
.qr-frame { display: grid; place-items: center; width: min(100%, 286px); min-height: 286px; padding: 16px; margin: 1.25rem auto; border: 1px solid var(--border); border-radius: 12px; background: white; }
.qr-frame img { display: block; width: 100%; height: auto; }
.qr-loading { color: var(--text-muted); font-size: .83rem; }
.payment-card .copy-button { width: min(100%, 350px); }
.payment-card .payload-details { margin: .8rem 0 1rem; text-align: left; }
.payment-card .payload-details summary { color: var(--text-muted); font-size: .79rem; cursor: pointer; }
.payment-card .payload-details textarea { font-size: .73rem; line-height: 1.4; min-height: 72px; }
.timer-block { width: min(100%, 350px); margin: 1rem auto; }
.timer-block p { margin: 0 0 .48rem; font-size: .88rem; }
.timer-block strong { color: var(--text); font-variant-numeric: tabular-nums; }
.timer-block.is-urgent strong { color: var(--warning); }
.timer-block.is-urgent .progress-track span { background: var(--warning); }
.cancel-button { border: 0; background: none; color: var(--text-muted); margin-top: .4rem; }
.cancel-button:hover { color: var(--danger); background: none; text-decoration: underline; }
.result-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; margin: 0 auto .9rem; color: var(--success); background: var(--success-soft); }
.result-icon svg { width: 24px; height: 24px; }
.status-note { color: var(--text-muted); font-size: .88rem; }
.payment-card .facts { margin-top: 1.35rem; }
.payment-card .card-actions { justify-content: center; margin-top: 1.2rem; }
.account-form { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.account-form > summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.token-code { display: block; overflow-wrap: anywhere; padding: .7rem; margin: .6rem 0; border-radius: 7px; background: white; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.choice-card { position: relative; display: block; margin: 0; padding: .95rem; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: #467791; background: #f1f7fa; }
.choice-card input { display: inline; width: auto; min-height: 0; margin: 0 .45rem 0 0; accent-color: var(--primary); }
.choice-card strong { font-size: .88rem; }
.choice-card small { display: block; margin: .35rem 0 0 1.55rem; }
.confirm-dialog { width: min(420px, calc(100vw - 2rem)); border: 0; border-radius: 13px; padding: 1.3rem; box-shadow: 0 25px 80px #0b253e42; }
.confirm-dialog::backdrop { background: #0c1d2d80; }
.confirm-dialog .form-actions { justify-content: flex-end; }

@media (max-width: 1100px) {
  .sidebar { width: 216px; }
  .app-shell { margin-left: 216px; }
  .topbar-context { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: min(280px, calc(100vw - 50px)); }
  .sidebar.is-open { transform: translateX(0); }
  .nav-scrim:not([hidden]) { position: fixed; inset: 0; z-index: 20; background: #0b253e80; }
  .app-shell { margin-left: 0; }
  .topbar { height: 62px; }
  .menu-toggle { display: inline-flex; width: 40px; min-width: 40px; padding: 0; border: 0; background: none; flex-direction: column; gap: 4px; }
  .menu-toggle:hover { background: none; }
  .menu-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--primary); }
  .mobile-brand { display: inline; color: var(--primary-strong); font-size: 1.1rem; font-weight: 780; letter-spacing: -.04em; }
  .create-layout { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .main-content { padding: 1.2rem .85rem 2.2rem; }
  .topbar { padding: 0 .85rem; }
  .topbar-quick, .user-name { display: none; }
  .topbar-actions { gap: .55rem; }
  .card, .panel { padding: 1.1rem; }
  .page-head { align-items: start; }
  .form-grid, .choice-grid, .item-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat-card { padding: .95rem; }
  .stat-card strong { font-size: 1.35rem; }
  .responsive-table { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .responsive-table table, .responsive-table tbody { display: block; width: 100%; }
  .responsive-table thead { display: none; }
  .responsive-table tr { display: block; padding: .85rem 1rem; margin-bottom: .65rem; border: 1px solid var(--border); border-radius: 10px; background: white; box-shadow: var(--shadow); }
  .responsive-table td { display: flex; align-items: start; justify-content: space-between; gap: .8rem; padding: .24rem 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .responsive-table td::before { content: attr(data-label); color: var(--text-muted); font-size: .77rem; text-align: left; flex: none; }
  .responsive-table td[data-primary] { display: block; text-align: left; padding-bottom: .55rem; font-size: 1.12rem; font-weight: 750; }
  .responsive-table td[data-primary]::before { display: block; padding-bottom: .08rem; }
  .responsive-table td[data-empty] { display: block; text-align: center; }
  .responsive-table td[data-empty]::before { display: none; }
  .filter-panel .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label { min-width: 0; }
  .filter-actions { grid-column: 1 / -1; }
  .filter-actions button, .filter-actions .button { flex: 1; }
  .qr-frame { width: min(100%, 270px); min-height: 270px; }
  .payment-card { padding: 1.3rem 1rem; }
  .app-footer { padding: .8rem 1rem 1.4rem; }
}
@media (max-width: 370px) {
  .topbar-actions { gap: .25rem; }
  .user-chip { display: none; }
  .stats, .facts, .filter-panel .filters { grid-template-columns: 1fr; }
  .filter-actions { grid-column: 1; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1; }
}
@supports (padding: env(safe-area-inset-top)) {
  .sidebar { padding-top: calc(1.45rem + env(safe-area-inset-top)); padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
  .topbar { height: calc(70px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  .main-content { padding-bottom: calc(clamp(1.25rem, 3vw, 2.4rem) + env(safe-area-inset-bottom)); }
  .app-footer { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
  .auth-main { padding-top: calc(1.2rem + env(safe-area-inset-top)); padding-bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
  .flash-stack { top: calc(1rem + env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right)); }
  @media (max-width: 800px) {
    .topbar { height: calc(62px + env(safe-area-inset-top)); }
  }
  @media (max-width: 650px) {
    .topbar { padding-left: max(.85rem, env(safe-area-inset-left)); padding-right: max(.85rem, env(safe-area-inset-right)); }
    .main-content { padding-left: max(.85rem, env(safe-area-inset-left)); padding-right: max(.85rem, env(safe-area-inset-right)); padding-bottom: calc(2.2rem + env(safe-area-inset-bottom)); }
    .app-footer { padding-bottom: calc(1.4rem + env(safe-area-inset-bottom)); }
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Admin: fixed QR, receipts and connection status. */
.admin-overview, .admin-confrapix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.admin-overview > .card, .admin-confrapix .card { min-width: 0; margin: 0; }
.admin-overview > .card { height: 100%; }
.admin-payment-value { display: block; margin: .7rem 0; font-size: clamp(1.8rem, 4vw, 2.6rem); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.admin-latest p { margin: .8rem 0; }
.admin-status .card-header { flex-wrap: wrap; }
.admin-status .badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.admin-sync { display: grid; min-width: 0; gap: 1rem; }
.admin-balances { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.admin-balances dt { color: var(--text-muted); font-size: .82rem; }
.admin-balances dd { margin: .25rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.admin-sync-meta { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.admin-sync-meta p { margin-bottom: .5rem; }
.admin-qr > h2, .admin-qr > p { text-align: center; }
.admin-qr .page-actions { justify-content: center; }
.admin-qr .payload-details { margin: 1.2rem 0; }
.admin-qr .payload-details summary { color: var(--primary); cursor: pointer; }
.admin-receipt > span { overflow-wrap: anywhere; }
@media (max-width: 800px) {
  .admin-overview, .admin-confrapix { grid-template-columns: 1fr; }
}
@media (max-width: 370px) {
  .admin-balances { grid-template-columns: 1fr; }
  .admin-receipt { flex-wrap: wrap; }
  .admin-receipt .row-end { margin-left: 0; text-align: left; }
}
