.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { font-size: 1rem; }
.card.highlight { border-color: var(--primary-border); background: var(--primary-soft); }
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.big { font-size: 2.1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-danger { color: var(--expense); border-color: #f1b5ae; }
.btn-danger:hover { background: var(--expense-soft); }
.btn-small { min-height: 36px; padding: .25rem .7rem; font-size: .85rem; }
.btn-link { border: 0; background: none; color: var(--primary); padding: .25rem; min-height: 36px; }
.btn svg { width: 18px; height: 18px; }

label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; min-width: 0; }
.field .hint { font-size: .8rem; color: var(--muted); font-weight: 400; margin-top: .2rem; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .7rem; border: 1px solid #c9cfc8; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; min-height: 44px; }
.input-error { border-color: var(--expense); }
.form-error { color: var(--expense); font-size: .9rem; margin: .5rem 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .9rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented button {
  border: 0; background: none; padding: .45rem .9rem; min-height: 40px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: #fff; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .7rem 0;
  border-bottom: 1px solid var(--border); min-height: 52px;
}
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); margin: 0 -.5rem; padding: .7rem .5rem; border-radius: var(--radius-sm); }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-income, .badge-ok { background: var(--income-soft); color: var(--income); }
.badge-expense, .badge-danger { background: var(--expense-soft); color: var(--expense); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warning > span { background: #d98a00; }
.progress.danger > span { background: var(--expense); }

.banner { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .92rem; }
.banner-warning { background: var(--warning-soft); color: #6b4000; }
.banner-info { background: var(--primary-soft); color: var(--primary-strong); }
.banner-danger { background: var(--expense-soft); color: var(--expense); }
#offline-banner { margin: 0; border-radius: 0; text-align: center; padding-top: calc(var(--safe-top) + .6rem); }

.state { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.state-error { color: var(--expense); }
.spinner {
  display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 84px); z-index: 60;
  display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px);
}
@media (min-width: 761px) { .toasts { bottom: 1.5rem; } }
.toast { background: #1c2420; color: #fff; padding: .75rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .92rem; }
.toast.error { background: var(--expense); }

.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(560px, 94vw); max-height: 90vh;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal::backdrop { background: rgba(16, 24, 20, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.1rem .5rem; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .5rem 1.1rem 1.1rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding-top: .5rem; }
@media (max-width: 560px) {
  .modal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: var(--safe-bottom); }
}

.chat { display: flex; flex-direction: column; gap: .75rem; }
.bubble { max-width: 85%; padding: .65rem .9rem; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.qr { display: block; width: min(280px, 80vw); height: auto; margin: 1rem auto; image-rendering: pixelated; border: 8px solid #fff; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; vertical-align: 0; }

/* Gráfico de contas fixas por mês */
.fx-chart { margin-top: .5rem; }
.fx-legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--muted); margin-bottom: .5rem; }
.fx-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.fx-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }
.fx-paid { background: var(--primary-strong); }
.fx-open { background: hsl(348 70% 80%); }
.fx-plot { position: relative; height: 200px; margin: 0 0 1.6rem 3.6rem; }
.fx-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.fx-grid span { position: absolute; right: calc(100% + .4rem); top: -.55rem; font-size: .72rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.fx-bars { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 4px; }
.fx-col { flex: 1; min-width: 0; display: flex; flex-direction: column; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; border-radius: 6px; }
.fx-col:hover, .fx-col:focus-visible { background: var(--surface-2); }
.fx-col:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fx-bar { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.fx-seg { width: min(70%, 28px); display: block; }
.fx-seg:first-of-type { border-radius: 4px 4px 0 0; }
.fx-seg[style*="height:0%"] { display: none; }
.fx-col.selected .fx-seg.fx-paid { background: var(--primary); }
.fx-col.selected .fx-label { color: var(--text); font-weight: 700; }
.fx-value { position: absolute; font-size: .72rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.fx-label { position: absolute; bottom: -1.4rem; font-size: .72rem; color: var(--muted); text-transform: capitalize; width: 100%; text-align: center; }
.fx-col { position: relative; }
.fx-label.now { text-decoration: underline; }
.fx-tip {
  position: absolute; top: 0; right: 0; z-index: 2; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem .7rem; font-size: .8rem; box-shadow: 0 4px 16px rgba(0,0,0,.08); pointer-events: none;
  display: grid; gap: .15rem; text-transform: none;
}
.fx-tip strong { text-transform: capitalize; }
@media (max-width: 560px) { .fx-label { font-size: .62rem; } .fx-plot { margin-left: 3rem; } }

/* Quadro (kanban) */
.kb-board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; min-height: 220px; scroll-snap-align: start; transition: background .15s; }
.kb-col.over { background: var(--primary-soft); border-color: var(--primary-border); }
.kb-col-late .kb-head strong { color: var(--expense); }
.kb-col-done .kb-head strong { color: var(--income); }
.kb-head { display: grid; gap: .1rem; padding: .2rem .25rem .6rem; }
.kb-head > div:first-child { display: flex; align-items: center; gap: .4rem; }
.kb-count { font-size: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 .45rem; color: var(--muted); }
.kb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--expense); border-radius: var(--radius-sm); padding: .55rem .65rem; display: grid; gap: .3rem; cursor: grab; }
.kb-card.kb-income { border-left-color: var(--income); }
.kb-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.kb-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.kb-card.dragging { opacity: .5; }
.kb-top, .kb-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kb-date { font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kb-tag { font-size: .72rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; white-space: nowrap; }
.kb-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-action { justify-self: start; }
.kb-empty { color: var(--muted); font-size: .85rem; text-align: center; padding: 1.5rem .5rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
@media (max-width: 760px) { .kb-board { grid-template-columns: repeat(4, 82%); } }

/* Relatórios: cartão expansível */
.rp-card summary { list-style: none; cursor: pointer; }
.rp-card summary::-webkit-details-marker { display: none; }
.rp-card summary .spread > span:first-child::after { content: ' ▸'; color: var(--muted); }
.rp-card[open] summary .spread > span:first-child::after { content: ' ▾'; }
.rp-detail { margin: .5rem 0 0 1rem; padding-left: .75rem; border-left: 2px solid var(--border); display: grid; gap: .4rem; }
.rp-invoice { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .8rem; display: grid; gap: .4rem; }
