/* Bibá Finance — versão 2: menu lateral, cartões com sombra suave, página inteira.
   Títulos em Source Serif 4; texto e valores em Inter. */

:root {
    --bg: #F6F3EE;
    --card: #FFFFFF;
    --panel: #FFFFFF;
    --soft: #F3EEE6;
    --soft-2: #FAF8F4;
    --line: #EFEAE1;
    --line-soft: #F1ECE4;
    --border: #EFEAE1;
    --control: #E2DACC;
    --text: #23211E;
    --text-2: #4A453E;
    --muted: #6B655C;
    --accent: #9A5B13;
    --accent-dark: #7E4A0F;
    --accent-tint: #FBF1DD;
    --success: #2E6B4F;
    --success-tint: #E4F1E9;
    --warning: #7A5200;
    --warning-text: #6E4A00;
    --warning-tint: #FFF3D3;
    --danger: #B3261E;
    --danger-text: #8F1F18;
    --danger-tint: #FBE9E6;
    --danger-soft: #FCF6F4;
    --info: #2F5E8C;
    --info-tint: #E6EEF7;
    --radius: 20px;
    --radius-lg: 24px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(35, 33, 30, 0.04), 0 8px 24px rgba(35, 33, 30, 0.06);
    --shadow-sm: 0 1px 2px rgba(35, 33, 30, 0.04), 0 6px 18px rgba(35, 33, 30, 0.05);
    --gap: 12px;
    --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --sans: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-variant-numeric: tabular-nums;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text);
    font-variant-numeric: lining-nums;
}

:focus-visible {
    outline: 3px solid rgba(154, 91, 19, 0.35);
    outline-offset: 2px;
}

.icon {
    flex: none;
}

/* ---------- Estrutura: menu lateral + área principal ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    flex: 0 0 248px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    color: var(--text);
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #FFFFFF;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 21px;
    flex: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 19px;
}

.brand-sub {
    font-size: 12px;
    color: var(--muted);
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
}

.side-link:hover {
    background: var(--soft-2);
    color: var(--text);
    text-decoration: none;
}

.side-link.active {
    background: var(--accent-tint);
    color: var(--accent-dark);
    font-weight: 600;
}

.side-foot {
    margin-top: auto;
    padding: 0 4px;
}

.side-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    cursor: pointer;
}

.side-logout:hover {
    color: var(--text);
    background: var(--soft-2);
}

.main-area {
    flex: 1 1 auto;
    min-width: 0;
    padding: 20px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px 16px;
    padding: 2px 2px 4px;
}

.page-eyebrow {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 2px;
}

.page-title {
    font-size: 32px;
    line-height: 1.15;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.content {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 32px 16px;
}

.auth-shell > div:last-child {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.auth-shell .content {
    width: 100%;
    align-items: center;
}

.login-panel {
    width: 100%;
    max-width: 420px;
}

/* ---------- Mensagens ---------- */

.message {
    padding: 12px 16px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.message.success {
    background: var(--success-tint);
    border-color: #CFE4D7;
    color: #1F4D38;
}

.message.error {
    background: var(--danger-tint);
    border-color: #F1D2CD;
    color: var(--danger-text);
}

.message.warning {
    background: var(--warning-tint);
    border-color: #F2E2B4;
    color: var(--warning-text);
}

/* ---------- Botões ---------- */

.primary-btn, .ghost-btn, .soft-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #FFFFFF;
    box-shadow: 0 1px 2px rgba(122, 74, 15, 0.25), 0 4px 12px rgba(154, 91, 19, 0.2);
}

.primary-btn:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #FFFFFF;
    text-decoration: none;
}

.ghost-btn {
    background: var(--card);
    border: 1px solid var(--control);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(35, 33, 30, 0.05);
}

.ghost-btn:hover {
    background: var(--soft-2);
    color: var(--text);
    text-decoration: none;
}

.soft-btn {
    background: var(--soft);
    border: 1px solid transparent;
    color: var(--text);
}

.soft-btn:hover {
    background: #EBE4D8;
    color: var(--text);
    text-decoration: none;
}

.primary-btn.small, .ghost-btn.small, .soft-btn.small {
    padding: 7px 13px;
    font-size: 14px;
    border-radius: 10px;
}

.ghost-btn.danger {
    border-color: #F1D2CD;
    color: var(--danger-text);
}

.ghost-btn.danger:hover {
    background: var(--danger-tint);
}

/* ---------- Cartões ---------- */

.card,
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    min-width: 0;
}

.card-head,
.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 14px;
}

.card h2,
.panel h2 {
    font-size: 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.card-head p,
.panel-header p {
    margin-top: 4px;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.small {
    font-size: 13px;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.sub-block {
    margin-top: 18px;
}

.plain-list {
    list-style: none;
    display: grid;
    gap: 8px;
}

.split {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: stretch;
}

.split-wide {
    flex: 999 1 560px;
}

.split-narrow {
    flex: 1 1 320px;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: var(--gap);
    align-items: start;
}

/* ---------- Destaque do Teto do dia ---------- */

.hero-status {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px;
}

.hero-status-main {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: stretch;
}

.hero-status-copy {
    flex: 999 1 420px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-status-copy h2 {
    font-size: 30px;
}

.lede {
    font-size: 16px;
    color: var(--text-2);
    max-width: 680px;
}

.status-pill {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
}

.status-pill.status-ok {
    background: var(--success-tint);
    color: var(--success);
}

.status-pill.status-danger {
    background: var(--danger-tint);
    color: var(--danger-text);
}

.free-box {
    flex: 1 1 300px;
    min-width: 0;
    background: var(--soft-2);
    border-radius: 18px;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.free-box.is-negative {
    background: var(--danger-soft);
}

.free-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.free-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.kv {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.free-box .kv:first-of-type {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

.free-box.is-negative .kv:first-of-type {
    border-top-color: #F1DDD8;
}

.kv > span:first-child {
    color: var(--muted);
}

.kv.small {
    font-size: 13px;
    margin-bottom: 6px;
}

.kv.small > span:first-child {
    color: var(--text);
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 14px;
}

.alert .icon {
    margin-top: 1px;
}

.alert-danger {
    background: var(--danger-tint);
    color: var(--danger-text);
}

.alert-warning {
    background: var(--warning-tint);
    color: var(--warning-text);
}

.alert-info {
    background: var(--info-tint);
    color: #24486C;
}

/* ---------- Indicadores ---------- */

.kpi-grid,
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--gap);
}

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.kpi-icon,
.empty-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--soft);
    color: var(--text-2);
}

.tone-honey { background: var(--accent-tint); color: var(--accent); }
.tone-blue { background: var(--info-tint); color: var(--info); }
.tone-red { background: var(--danger-tint); color: var(--danger); }
.tone-amber { background: var(--warning-tint); color: var(--warning); }
.tone-green { background: var(--success-tint); color: var(--success); }

.kpi-label,
.metric-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.kpi-value,
.metric-value {
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.kpi-sub,
.metric-sub {
    font-size: 13px;
    color: var(--muted);
}

.metrics-grid.compact {
    margin-top: 14px;
}

.metric-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.metric-card::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--control);
    margin-bottom: 8px;
}

.accent-emerald::before { background: var(--success); }
.accent-ocean::before { background: var(--info); }
.accent-sand::before { background: #C98A2B; }
.accent-ink::before { background: var(--text-2); }
.accent-danger::before { background: var(--danger); }
.accent-danger .metric-value { color: var(--danger); }

.inline-card {
    min-width: 0;
}

.unit {
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0;
}

/* ---------- Listas ---------- */

.list {
    display: flex;
    flex-direction: column;
}

.list-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 0;
    border-top: 1px solid var(--line-soft);
}

.list-row:first-child {
    border-top: 0;
    padding-top: 2px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--text-2);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    flex: none;
}

.list-main {
    flex: 1 1 240px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.list-title {
    font-weight: 600;
}

.list-sub {
    font-size: 13px;
    color: var(--muted);
}

.list-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.list-end {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.list-end strong {
    font-size: 16px;
    white-space: nowrap;
}

.list-more {
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
    font-weight: 600;
    font-size: 14px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 24px 14px;
    border-radius: 18px;
    background: var(--soft-2);
}

.empty-icon {
    width: 48px;
    height: 48px;
    border-radius: 999px;
}

/* listas antigas (contas, dashboard) */

.bill-list,
.budget-list,
.upcoming-list,
.top-expense-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bill-list {
    gap: 0;
}

.bill-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 0;
    border-top: 1px solid var(--line-soft);
}

.bill-row:first-child {
    border-top: 0;
    padding-top: 2px;
}

.bill-row > div:first-child {
    flex: 1 1 220px;
    min-width: 0;
}

.bill-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.budget-row {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--soft-2);
    display: grid;
    grid-template-columns: 1.2fr 1fr auto;
    gap: 12px;
    align-items: center;
}

.budget-row.over-limit {
    background: var(--danger-soft);
}

.budget-name {
    font-weight: 600;
}

.budget-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.budget-amount {
    font-size: 14px;
}

.upcoming-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--soft-2);
}

.upcoming-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.expense-row {
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--soft-2);
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 8px;
    align-items: center;
}

.expense-name {
    font-weight: 600;
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--gap);
}

.account-card {
    background: var(--soft-2);
    border-radius: 16px;
    padding: 14px 16px;
}

.account-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-name {
    font-weight: 600;
    margin: 6px 0 4px;
}

.account-balance {
    font-size: 18px;
    font-weight: 600;
}

.cash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--gap);
    margin-bottom: 16px;
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--gap);
}

.method-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.method-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 12px;
    background: var(--soft-2);
    border-radius: 14px;
    padding: 10px 14px;
}

/* ---------- Etiquetas, pílulas, chips ---------- */

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--soft);
    color: var(--text-2);
    white-space: nowrap;
}

.tag + .tag {
    margin-left: 2px;
}

.tag-ok { background: var(--success-tint); color: var(--success); }
.tag-warn { background: var(--warning-tint); color: var(--warning); }
.tag-danger { background: var(--danger-tint); color: var(--danger-text); }
.tag-essential { background: var(--soft); color: var(--text); }
.tag-negotiable { background: var(--info-tint); color: var(--info); }

.count-pill,
.pill-outline {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.count-pill.tone-amber {
    background: var(--warning-tint);
    color: var(--warning);
}

.pill {
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: var(--soft);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
}

.chip:hover {
    text-decoration: none;
    background: #EBE4D8;
}

.chip-soft { color: var(--text-2); }
.chip-success { background: var(--success-tint); color: #1F4D38; }
.chip-warning { background: var(--warning-tint); color: var(--warning-text); }
.chip-danger { background: var(--danger-tint); color: var(--danger-text); }

.hint {
    font-size: 13px;
    color: var(--warning);
}

/* ---------- Telas antigas: hero e cartão de destaque ---------- */

.hero {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: stretch;
}

.hero-copy {
    flex: 999 1 480px;
    min-width: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 26px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-copy h1 {
    font-size: 30px;
    line-height: 1.2;
}

.hero-copy .lede {
    font-size: 16px;
}

.hero-card {
    flex: 1 1 340px;
    min-width: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hero-card-label {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.hero-card-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.hero-card-sub {
    color: var(--muted);
    font-size: 14px;
}

.hero-card-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.hero-card.compact {
    flex: 0 1 300px;
    box-shadow: none;
    background: var(--soft-2);
    border-color: transparent;
    padding: 16px 20px;
}

.hero-card.compact .hero-card-value {
    font-size: 26px;
}

.alert-text {
    margin-top: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--danger-tint);
    color: var(--danger-text);
    font-size: 14px;
}

/* ---------- Barras ---------- */

.progress-track {
    background: var(--line-soft);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
}

.progress-track.big {
    height: 10px;
    margin-top: 6px;
    max-width: 680px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.progress-bar.warn { background: #C98A2B; }
.progress-bar.over { background: var(--danger); }

.bar-track {
    height: 6px;
    background: var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--accent);
}

.stack-bar {
    display: flex;
    height: 20px;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 18px;
    background: var(--line-soft);
}

.stack-seg {
    height: 100%;
}

.stack-seg.budget,
.swatch.budget {
    background: repeating-linear-gradient(45deg, #C98A2B, #C98A2B 6px, #B07620 6px, #B07620 12px);
}

.swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 4px;
}

/* ---------- Tabelas ---------- */

.table-wrapper {
    overflow-x: auto;
}

.table-card,
.card > .table-wrapper,
.panel > .table-wrapper {
    border: 1px solid var(--line-soft);
    border-radius: 16px;
}

.transactions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.transactions-table th,
.transactions-table td {
    text-align: left;
    padding: 13px 16px;
    border-top: 1px solid var(--line-soft);
    vertical-align: middle;
}

.transactions-table thead th {
    background: var(--soft-2);
    border-top: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.transactions-table tbody tr:hover td {
    background: #FCFBF8;
}

.text-right {
    text-align: right !important;
}

.center {
    text-align: center;
}

.pos {
    color: var(--success);
}

.neg {
    color: var(--danger);
}

.total-row td {
    font-weight: 700;
    background: var(--soft-2);
}

.row-actions {
    white-space: nowrap;
    text-align: right;
}

div.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

td.row-actions .ghost-btn,
td.row-actions .primary-btn,
td.row-actions .soft-btn {
    margin-left: 4px;
}

/* ---------- Formulários ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 14px;
    font-weight: 500;
}

.form-field input,
.form-field select,
.form-field textarea,
.form-table input,
.form-table select {
    background: var(--card);
    border: 1px solid var(--control);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.form-table input:focus,
.form-table select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(154, 91, 19, 0.18);
    outline-offset: 0;
}

.form-table input,
.form-table select {
    width: 100%;
    min-width: 90px;
    padding: 8px 10px;
    font-size: 14px;
}

.form-field input[type="checkbox"],
.form-table input[type="checkbox"] {
    width: auto;
    min-width: 0;
    accent-color: var(--accent);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.field-error {
    color: var(--danger-text);
    font-size: 13px;
}

.plan-form {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.weekday-field > div[id] {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding-top: 8px;
}

.weekday-field label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confirm-box {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--warning-tint);
    color: var(--warning-text);
}

.danger-zone {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pay-amount {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 4px 0 16px;
}

.explainer summary {
    cursor: pointer;
    font-weight: 600;
}

.explainer ol,
.explainer ul {
    margin: 12px 0 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

/* ---------- Dashboard: faixa do teto ---------- */

.cap-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    align-items: center;
    padding: 18px 22px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--card);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

.cap-strip:hover {
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.cap-strip.state-over { background: var(--danger-soft); }
.cap-strip.state-tight { background: #FFFAEE; }

.cap-strip-value {
    font-size: 24px;
    font-weight: 700;
}

.cap-strip-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    color: var(--muted);
    font-size: 14px;
}

/* ---------- Agenda ---------- */

.agenda {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.agenda-row {
    display: grid;
    grid-template-columns: 82px 1fr 170px;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--soft-2);
}

.agenda-row.is-today {
    background: var(--accent-tint);
}

.agenda-day {
    font-weight: 600;
    text-transform: capitalize;
}

.agenda-bar .muted {
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agenda-values {
    text-align: right;
}

/* ---------- Compras / cotação ---------- */

.sub-nav {
    margin: 0;
}

.sub-nav .chip-success {
    background: var(--accent-tint);
    color: var(--accent-dark);
    font-weight: 600;
}

.filter-form {
    align-items: end;
}

.link-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.link-form input,
.link-form select {
    background: var(--card);
    border: 1px solid var(--control);
    border-radius: 10px;
    padding: 7px 10px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.link-form input[type="text"] {
    min-width: 200px;
    flex: 1;
}

.link-form input[type="number"] {
    width: 90px;
}

.inline-actions {
    display: inline-flex;
    gap: 6px;
}

.row-pick td {
    background: #F3F8F5;
}

.whatsapp-text {
    width: 100%;
    background: var(--soft-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    resize: vertical;
}

/* ---------- Telas menores ---------- */

@media (max-width: 1100px) {
    .panel-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        height: auto;
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 12px;
        padding: 12px 14px 8px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .brand {
        padding: 0;
    }

    .brand-sub {
        display: none;
    }

    .side-foot {
        margin: 0 0 0 auto;
        padding: 0;
    }

    .side-nav {
        order: 3;
        flex-basis: 100%;
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        padding-bottom: 2px;
    }

    .side-link {
        padding: 8px 12px;
        border-radius: 999px;
        font-size: 14px;
    }

    .side-link .icon {
        display: none;
    }

    .main-area {
        padding: 14px 10px 32px;
        gap: 10px;
    }

    .content,
    .kpi-grid,
    .metrics-grid,
    .split {
        gap: 10px;
    }

    .page-title {
        font-size: 26px;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .primary-btn,
    .page-actions .ghost-btn {
        flex: 1 1 auto;
        padding: 9px 12px;
        font-size: 14px;
    }

    .card,
    .panel {
        padding: 18px;
        border-radius: 20px;
    }

    .hero-status {
        padding: 18px;
    }

    .hero-status-copy h2 {
        font-size: 23px;
    }

    .free-value {
        font-size: 30px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi {
        padding: 14px;
        gap: 8px;
        border-radius: 18px;
    }

    .kpi-icon {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .kpi-sub {
        display: none;
    }

    .agenda-row {
        grid-template-columns: 70px 1fr 110px;
    }

    .budget-row {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .list-end {
        margin-left: 58px;
    }
}

/* cartões dentro de cartões ficam planos */
.card .metric-card,
.panel .metric-card,
.card .kpi,
.panel .kpi {
    box-shadow: none;
    border-color: transparent;
    background: var(--soft-2);
}

/* ---------- Gráficos do Dashboard (HTML + CSS) ---------- */

.chart-alert {
    margin-bottom: 14px;
}

.vchart {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    height: 230px;
    padding-bottom: 22px;
    font-variant-numeric: tabular-nums;
}

.vchart-y {
    position: relative;
    min-width: 88px;
    font-size: 12px;
    color: var(--muted);
    text-align: right;
}

.vchart-y span {
    position: absolute;
    right: 0;
    transform: translateY(50%);
    white-space: nowrap;
}

.vchart-y span[style*="top"] {
    transform: translateY(-10%);
}

.vchart-plot {
    position: relative;
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

.vchart-zero {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: #CFC6B6;
}

.vcol {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    outline: none;
}

.vcol:hover,
.vcol:focus-visible {
    background: rgba(154, 91, 19, 0.06);
    border-radius: 6px;
}

.vbar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(18px, 70%);
    background: var(--accent);
    border-radius: 4px 4px 0 0;
}

.vbar.is-neg {
    border-radius: 0 0 4px 4px;
    background: var(--danger);
}

.vcol:hover .vbar,
.vcol:focus-visible .vbar {
    filter: brightness(1.12);
}

.gbar {
    position: absolute;
    bottom: 0;
    width: min(9px, 34%);
    border-radius: 4px 4px 0 0;
}

.gbar-in {
    right: 50%;
    margin-right: 1px;
    background: #2A78D6;
}

.gbar-out {
    left: 50%;
    margin-left: 1px;
    background: #EB6834;
}

.vtick {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.vtip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--text);
    color: #FFFFFF;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: var(--shadow);
    pointer-events: none;
}

.vtip strong {
    display: inline-block;
    margin-right: 4px;
    font-size: 13px;
}

.vcol:hover .vtip,
.vcol:focus-visible .vtip {
    display: block;
}

.vcol:first-child .vtip,
.vcol:nth-child(2) .vtip,
.vcol:nth-child(3) .vtip {
    left: 0;
    transform: none;
}

.vcol:last-child .vtip,
.vcol:nth-last-child(2) .vtip,
.vcol:nth-last-child(3) .vtip {
    left: auto;
    right: 0;
    transform: none;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    font-size: 13px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.key {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.key-in { background: #2A78D6; }
.key-out { background: #EB6834; }

.table-view {
    margin-top: 12px;
}

.table-view summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
}

.table-view .table-wrapper {
    margin-top: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.kv-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--soft-2);
}

.mini-title {
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin: 18px 0 6px;
}

.list.compact .list-row {
    padding: 10px 0;
    gap: 8px 12px;
}

.list.compact .list-main {
    flex: 1 1 160px;
}

.meter-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.meter-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 6px;
}

.hbar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    align-items: center;
    font-size: 14px;
    border-radius: 8px;
}

.hbar-row:focus-visible,
.hbar-row:hover {
    background: var(--soft-2);
}

.hbar-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hbar-track {
    height: 8px;
    grid-column: 1 / -1;
    order: 3;
}

.hbar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.hbar-value {
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .vchart {
        height: 190px;
    }

    .vchart-y {
        min-width: 64px;
        font-size: 11px;
    }

    .hbar-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .hbar-track {
        grid-column: 1 / -1;
        order: 3;
    }
}

/* ---------- Sugestão do dia ---------- */

.budget-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
}

.budget-row-input {
    display: flex;
    gap: 6px;
}

.budget-row-input input {
    width: 150px;
    background: var(--card);
    border: 1px solid var(--control);
    border-radius: 10px;
    padding: 7px 10px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

.suggestion-split {
    margin-top: 12px;
}

.suggestion-col .list-row:first-of-type {
    border-top: 0;
    padding-top: 4px;
}

.avatar.small {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.ai-box {
    margin-top: 16px;
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--soft-2);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.ai-head > div {
    flex: 1 1 240px;
}

.ai-form {
    margin: 0;
}

.ai-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

code {
    font-size: 13px;
    background: var(--soft);
    padding: 1px 6px;
    border-radius: 6px;
}

.suggestion-split .suggestion-col {
    flex: 1 1 420px;
    min-width: 0;
}
