:root {
  --forest: #12372a;
  --forest-2: #1d503d;
  --mint: #dff3e9;
  --coral: #ef7b62;
  --ink: #18302a;
  --muted: #6c7d77;
  --canvas: #f4f7f5;
  --surface: #ffffff;
  --line: #dfe8e3;
  --shadow: 0 18px 55px rgba(19, 55, 43, .10);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --ink: #edf7f2;
  --muted: #9db0a8;
  --canvas: #0d1915;
  --surface: #14251f;
  --line: #294239;
  --mint: #1c4435;
  --shadow: 0 18px 55px rgba(0, 0, 0, .28);
}

html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overscroll-behavior-y: none; }
input, select, textarea, button { font-size: 16px !important; }
a { color: var(--forest-2); }
[data-theme="dark"] a { color: #88d2ad; }
.text-secondary { color: var(--muted) !important; }

.btn { border-radius: 12px; font-weight: 700; min-height: 44px; }
.btn-primary { --bs-btn-bg: var(--forest); --bs-btn-border-color: var(--forest); --bs-btn-hover-bg: var(--forest-2); --bs-btn-hover-border-color: var(--forest-2); --bs-btn-active-bg: var(--forest-2); }
.btn-outline-primary { --bs-btn-color: var(--forest); --bs-btn-border-color: var(--forest); --bs-btn-hover-bg: var(--forest); --bs-btn-hover-border-color: var(--forest); }
.form-control, .form-select { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: 12px; min-height: 46px; }
.form-control:focus, .form-select:focus { background: var(--surface); color: var(--ink); border-color: #4e8c70; box-shadow: 0 0 0 .25rem rgba(29, 80, 61, .12); }
.form-control::placeholder { color: var(--muted); }
.form-label { font-weight: 700; font-size: .88rem; }
.modal-content { background: var(--surface); color: var(--ink); border: 0; border-radius: 22px; }
.modal-header, .modal-footer { border-color: var(--line); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }

.auth-page { min-height: 100svh; background: radial-gradient(circle at 10% 5%, #e7f4ec 0, transparent 38%), linear-gradient(145deg, #f7faf8, #e8f0ec); }
[data-theme="dark"] .auth-page { background: #0d1915; }
.auth-shell { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid rgba(255,255,255,.7); border-radius: 26px; box-shadow: var(--shadow); padding: clamp(24px, 4vw, 42px); }
.login-card { width: min(100%, 460px); }
.brand-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: #fff; background: linear-gradient(145deg, var(--forest-2), var(--forest)); font-weight: 900; letter-spacing: -.06em; box-shadow: 0 10px 25px rgba(18,55,42,.28); }
.brand-mark-lg { width: 68px; height: 68px; border-radius: 20px; font-size: 1.35rem; }
.brand-image { width: 48px; height: 48px; object-fit: contain; border-radius: 14px; background: #fff; padding: 3px; }
.brand-image-lg { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }
.secure-note { color: var(--muted); font-size: .84rem; text-align: center; }
.back-link { text-decoration: none; font-weight: 700; }
.installer-shell { max-width: 1180px; }
.installer-brand { display: flex; align-items: center; gap: 14px; }
.installer-brand h1 { margin: 0; font-size: 1.55rem; }
.installer-brand p { margin: 2px 0 0; color: var(--muted); }
.eyebrow { display: block; color: var(--coral); font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 8px; }
.auth-card h2 { font-size: 1.35rem; margin-bottom: 20px; }
.requirements-list { display: grid; gap: 12px; }
.requirement { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.status-dot { width: 25px; height: 25px; display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; }
.status-dot.ok { background: #24845c; }.status-dot.fail { background: #c44b48; }
.success-orb { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--mint); color: var(--forest); font-size: 2rem; font-weight: 900; margin-bottom: 18px; }

.app-layout { min-height: 100svh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1040; width: 264px; background: var(--forest); color: #fff; padding: 26px 18px; display: flex; flex-direction: column; }
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; }
.sidebar .brand strong { display: block; }.sidebar .brand small { color: rgba(255,255,255,.62); }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav button { width: 100%; border: 0; background: transparent; color: rgba(255,255,255,.72); display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; text-align: left; font-weight: 650; }
.sidebar-nav button:hover, .sidebar-nav button.active { background: rgba(255,255,255,.11); color: #fff; }
.nav-glyph { width: 24px; text-align: center; font-size: 1.05rem; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.14); font-weight: 800; }
.user-chip div { min-width: 0; }.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.user-chip small { color: rgba(255,255,255,.62); }
.sidebar-footer a { color: rgba(255,255,255,.75); font-size: .84rem; }

.app-main { margin-left: 264px; min-height: 100svh; }
.topbar { position: sticky; top: 0; z-index: 1030; min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px clamp(20px, 4vw, 44px); background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.topbar h1 { font-size: 1.45rem; margin: 0; }.topbar p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.top-actions { display: flex; gap: 9px; align-items: center; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); color: var(--ink); position: relative; }
.notification-count { position: absolute; right: -4px; top: -5px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; background: var(--coral); color: #fff; font: 700 11px/18px system-ui; }
.content { padding: 28px clamp(20px, 4vw, 44px) 100px; max-width: 1540px; }
.app-section { display: none; }.app-section.active { display: block; animation: sectionIn .22s ease both; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(5px); } }
.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.section-header h2 { margin: 0; font-size: 1.35rem; }.section-header p { margin: 4px 0 0; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(21,62,46,.045); }
.metric-card { padding: 20px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.metric-card::after { content: ''; position: absolute; width: 80px; height: 80px; border-radius: 50%; background: var(--mint); right: -26px; top: -28px; }
.metric-label { color: var(--muted); font-weight: 700; font-size: .84rem; }.metric-value { font-size: clamp(1.35rem, 2.2vw, 2rem); font-weight: 850; letter-spacing: -.04em; }.metric-meta { color: var(--muted); font-size: .78rem; }
.metric-card.balance { background: linear-gradient(145deg, var(--forest), #225c46); color: #fff; border: 0; }.metric-card.balance .metric-label,.metric-card.balance .metric-meta { color: rgba(255,255,255,.68); }.metric-card.balance::after { background: rgba(255,255,255,.08); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 18px; margin-top: 18px; }
.panel { padding: 22px; }.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }.panel-header h3 { margin: 0; font-size: 1rem; }
.chart-wrap { min-height: 270px; position: relative; }.chart-wrap canvas { width: 100%; height: 270px; }
.list-stack { display: grid; gap: 10px; }.list-item { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }.list-date { width: 46px; flex: 0 0 46px; text-align: center; border-radius: 11px; background: var(--mint); color: var(--forest); padding: 7px 3px; }.list-date strong,.list-date small { display: block; }.list-date strong { font-size: 1.05rem; }.list-item-main { min-width: 0; flex: 1; }.list-item-main strong,.list-item-main small { display: block; }.list-item-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.list-item-main small { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }.toolbar .form-control,.toolbar .form-select { width: auto; min-width: 160px; }.search-control { min-width: min(100%, 260px) !important; }
.data-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }.data-card .table { margin: 0; }.data-card th { color: var(--muted); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; padding: 15px 18px; white-space: nowrap; }.data-card td { padding: 14px 18px; vertical-align: middle; }.amount-income { color: #168458; font-weight: 800; }.amount-expense { color: #c34c4b; font-weight: 800; }
.type-badge { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; padding: 3px 9px; background: var(--mint); color: var(--forest-2); font-weight: 800; font-size: .72rem; }.type-badge.expense { background: #fde8e5; color: #9c3e3c; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }.empty-state strong { display: block; color: var(--ink); margin-bottom: 4px; }
.calculation-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }.calculation-box { background: var(--mint); padding: 13px; border-radius: 13px; }.calculation-box span,.calculation-box strong { display: block; }.calculation-box span { color: var(--muted); font-size: .78rem; }.calculation-box strong { font-size: 1.05rem; }
.fab-group { position: fixed; right: 22px; bottom: calc(22px + var(--safe-bottom)); z-index: 1020; display: grid; gap: 10px; justify-items: end; }.fab { border: 0; border-radius: 18px; min-height: 54px; padding: 0 20px; background: var(--coral); color: #fff; font-weight: 850; box-shadow: 0 14px 32px rgba(239,123,98,.35); }.fab.secondary { min-height: 46px; border-radius: 14px; background: var(--forest); font-size: .84rem; }
.mobile-nav { display: none; }
.toast-container { z-index: 2000; }.toast { background: var(--surface); color: var(--ink); border-color: var(--line); }
.skeleton { min-height: 24px; border-radius: 8px; color: transparent !important; background: linear-gradient(90deg, var(--line), var(--surface), var(--line)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; }.calendar-day { min-height: 105px; padding: 9px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }.calendar-day.muted { opacity: .45; }.calendar-day.today { outline: 2px solid var(--coral); }.calendar-number { font-size: .78rem; font-weight: 850; }.calendar-event { margin-top: 5px; padding: 5px 7px; border-radius: 8px; background: var(--mint); color: var(--forest-2); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.calendar-grid.agenda-alt { display: block; }.agenda-alt .list-item { margin-bottom: 8px; }.calendar-week .calendar-day { min-height: 220px; }
.report-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 18px; }.report-summary .calculation-box strong { font-size: 1.25rem; }
#transaction-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }.settings-grid .panel:last-child { grid-column: 1/-1; }
.https-warning { border-radius: 0; margin: 0; text-align: center; }

@media (max-width: 1199.98px) { .metric-grid { grid-template-columns: repeat(2,1fr); } #transaction-summary { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 991.98px) {
  .sidebar { display: none; }.app-main { margin-left: 0; }.topbar { min-height: 66px; }.topbar p { display: none; }.content { padding: 20px 14px calc(108px + var(--safe-bottom)); }.dashboard-grid { grid-template-columns: 1fr; }.fab-group { bottom: calc(84px + var(--safe-bottom)); right: 16px; }.mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(5,1fr); inset: auto 0 0 0; z-index: 1035; padding: 7px 6px calc(7px + var(--safe-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }.mobile-nav button { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; gap: 2px; font-size: .66rem !important; font-weight: 700; min-height: 48px; }.mobile-nav button .nav-glyph { font-size: 1.1rem; }.mobile-nav button.active { color: var(--forest-2); }.settings-grid { grid-template-columns: 1fr; }.settings-grid .panel:last-child { grid-column: auto; }
}
@media (max-width: 575.98px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }.metric-card { padding: 15px; min-height: 116px; }.metric-value { font-size: 1.28rem; }.section-header { align-items: flex-start; flex-direction: column; }.section-header .btn { width: 100%; }.panel { padding: 16px; }.dashboard-grid { gap: 12px; }.toolbar > * { flex: 1 1 140px; }.toolbar .form-control,.toolbar .form-select { width: 100%; min-width: 0 !important; }.data-card { border-radius: 16px; }.data-card td,.data-card th { padding: 12px; }.hide-mobile { display: none; }.calculation-strip,.report-summary,#transaction-summary { grid-template-columns: 1fr; }.calendar-grid { gap: 3px; }.calendar-day { min-height: 74px; padding: 5px; border-radius: 8px; }.calendar-event { padding: 3px 4px; font-size: 0; }.calendar-event::before { content: ''; display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--forest); }.topbar { padding-inline: 14px; }.topbar h1 { font-size: 1.15rem; }.top-actions .btn span { display: none; }
}

@media print { .sidebar,.topbar,.mobile-nav,.fab-group,.toolbar,.no-print { display: none !important; }.app-main { margin: 0; }.content { padding: 0; }.app-section { display: none !important; }.app-section.active { display: block !important; }.panel,.data-card,.metric-card { box-shadow: none; break-inside: avoid; } }
