:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --text: #10201c;
  --muted: #66736f;
  --line: #e1e7e4;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --soft: #eef6f4;
  --income: #047857;
  --expense: #dc2626;
  --warning: #f59e0b;
  --info: #0891b2;
  --transfer: #6d28d9;
  --shadow: 0 10px 22px rgba(16, 32, 28, 0.07);
  --shadow-soft: 0 6px 16px rgba(16, 32, 28, 0.05);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.sheet-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.22rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.app-header,
.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px 8px;
  background: rgba(244, 246, 245, 0.92);
  backdrop-filter: blur(14px);
}

.install-info-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.install-info-btn:hover,
.install-info-btn:active {
  border-color: rgba(15, 118, 110, 0.36);
  background: var(--soft);
  color: var(--brand-dark);
}

.install-info-btn:active {
  transform: translateY(1px);
}

.install-info-btn svg {
  display: block;
}

.eyebrow,
.soft-label {
  display: block;
  color: var(--brand);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.soft-label {
  color: var(--muted);
  margin-bottom: 4px;
}

.app-shell {
  padding: 6px 12px 96px;
}

.page {
  display: none;
  gap: 10px;
}

.page.active {
  display: grid;
}

.panel,
.summary-card,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 12px;
}

.month-row,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.month-row {
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 60px;
  border-radius: 16px;
  padding: 9px 11px 9px 12px;
  box-shadow: var(--shadow-soft);
}

.month-row strong {
  display: block;
  font-size: 1rem;
  line-height: 1.15;
}

.month-row input {
  width: 132px;
  min-height: 38px;
  border-radius: 12px;
  padding: 7px 8px;
  font-size: 0.86rem;
}

.summary-grid,
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.summary-card,
.stat-card {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
}

.summary-card span,
.stat-card span,
.helper-text {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.summary-card strong,
.stat-card strong {
  font-size: 1.18rem;
  line-height: 1.15;
}

.balance-card {
  background: #fff;
  color: var(--text);
}

.balance-card strong {
  color: var(--brand-dark);
}

.income-text {
  color: var(--income);
}

.expense-text {
  color: var(--expense);
}

.transfer-text {
  color: var(--transfer);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.transaction-form {
  display: grid;
  gap: 11px;
}

.transaction-filter-panel {
  padding: 10px 11px;
}

.filter-top-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.filter-top-row label {
  flex: 1;
  gap: 4px;
}

.filter-top-row input {
  width: 145px;
  min-height: 38px;
  border-radius: 12px;
  padding: 7px 8px;
  font-size: 0.86rem;
}

.filter-summary {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.amount-field input {
  min-height: 54px;
  font-size: 1.35rem;
  font-weight: 800;
}

.quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid #cfe4df;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-dark);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 800;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 32, 28, 0.42);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(16, 32, 28, 0.46);
}

.app-modal-overlay {
  animation: fadeIn 160ms ease;
}

.bottom-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  max-height: 68vh;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -18px 36px rgba(16, 32, 28, 0.18);
  transform: translateY(105%);
  transition: transform 180ms ease;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle {
  justify-self: center;
  width: 42px;
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: #d7dfdc;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
}

.close-sheet-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7faf9;
  color: var(--text);
  cursor: pointer;
  font-weight: 950;
}

.sheet-content {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 6px 16px 12px;
}

.filter-group {
  display: grid;
  gap: 9px;
}

.filter-group h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 850;
}

.filter-chip.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.toast {
  display: grid;
  gap: 2px;
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 11px 13px 11px 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(16, 32, 28, 0.12);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
  pointer-events: auto;
  animation: toastIn 180ms ease;
}

.toast.success {
  border-left-color: var(--income);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast.danger,
.toast.error {
  border-left-color: var(--expense);
}

.toast.info {
  border-left-color: var(--info);
}

.toast.update-toast {
  padding: 8px 10px 8px 14px;
}

.update-toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.update-toast-text {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.update-toast-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease;
}

.update-toast-btn:active {
  background: var(--brand-dark, #0d6357);
}

.update-toast-close {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms ease;
}

.update-toast-close:hover,
.update-toast-close:active {
  opacity: 1;
}

.toast-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.toast-actions button {
  min-height: 34px;
  border-radius: 11px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.toast-actions .primary-button,
.toast-actions .ghost-button {
  width: auto;
}

.app-modal {
  position: fixed;
  right: 16px;
  left: 16px;
  top: 50%;
  z-index: 50;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 46px rgba(16, 32, 28, 0.2);
  padding: 18px;
  transform: translateY(-50%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.app-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.modal-close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf9;
  color: var(--text);
  cursor: pointer;
  font-weight: 950;
}

.modal-status-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 950;
}

.app-modal.danger .modal-status-icon {
  background: #fef2f2;
  color: var(--expense);
}

.app-modal.warning .modal-status-icon {
  background: #fffbeb;
  color: #b45309;
}

.app-modal.info .modal-status-icon {
  background: #ecfeff;
  color: var(--info);
}

.modal-copy {
  display: grid;
  gap: 5px;
  padding-right: 32px;
}

.modal-copy h2 {
  font-size: 1.08rem;
}

.modal-copy p:last-child,
.modal-dynamic-content p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.modal-dynamic-content {
  display: grid;
  gap: 10px;
}

.modal-field {
  display: grid;
  gap: 6px;
}

.modal-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.muted-button {
  color: var(--muted);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  padding-top: 2px;
}

.modal-actions .primary-button,
.modal-actions .ghost-button {
  width: 100%;
  min-height: 44px;
}

.modal-actions .danger-button {
  width: 100%;
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}

.primary-button,
.ghost-button,
.file-button,
.small-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #fff;
}

.ghost-button,
.file-button,
.small-button {
  background: #fff;
  border-color: var(--line);
  color: var(--brand-dark);
}

.text-button {
  min-height: 34px;
  background: transparent;
  color: var(--brand);
  padding: 4px 0;
}

.compact {
  width: auto;
  min-height: 36px;
  padding: 7px 11px;
}

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

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-radius: 14px;
  background: #fef2f2;
  color: var(--expense);
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 900;
}

.primary-button.danger-action {
  background: var(--expense);
}

.primary-button.warning-action {
  background: var(--warning);
}

.file-button input {
  display: none;
}

.form-actions,
.settings-actions {
  display: grid;
  gap: 9px;
  margin-top: 4px;
}

.settings-card {
  display: grid;
  gap: 12px;
}

.settings-heading {
  display: grid;
  gap: 4px;
}

.settings-list {
  display: grid;
  gap: 9px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}

.settings-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-row strong {
  font-size: 0.9rem;
}

.settings-row span,
.about-list span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.compact-action {
  width: auto;
  min-width: 82px;
  min-height: 36px;
  padding: 7px 10px;
}

.preference-grid {
  display: grid;
  gap: 10px;
}

.danger-zone {
  border-color: rgba(220, 38, 38, 0.18);
}

.about-list {
  display: grid;
  gap: 8px;
}

.update-info {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}

.update-info strong {
  font-size: 0.98rem;
}

.update-info span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.update-info b {
  color: var(--brand-dark);
}

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

/* Download app section */
.download-card {
  border-color: var(--brand);
  border-width: 1.5px;
}

.download-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}

.download-app-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--soft);
  overflow: hidden;
}

.download-app-icon img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.download-info-row div {
  display: grid;
  gap: 3px;
}

.download-info-row strong {
  font-size: 0.95rem;
  color: var(--text);
}

.download-info-row span {
  color: var(--muted);
  font-size: 0.8rem;
}

.install-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7faf9;
}

.install-tab {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-dark);
  padding: 8px 6px;
  cursor: pointer;
  font-weight: 850;
  font-size: 0.82rem;
  line-height: 1.1;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.install-tab:hover,
.install-tab:focus-visible {
  outline: none;
  background: var(--soft);
  border-color: rgba(15, 118, 110, 0.28);
}

.install-tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 16px rgba(15, 118, 110, 0.16);
}

.install-tab:active {
  transform: translateY(1px);
}

.download-guide-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 14px;
  background: #fbfdfc;
}

.download-guide-card div {
  display: grid;
  gap: 5px;
}

.download-guide-card strong {
  color: var(--text);
  font-size: 0.92rem;
}

.download-guide-card p {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.install-action-button {
  width: auto;
  min-width: 100px;
}

.primary-button.installed-state {
  background: var(--brand-dark);
}

.about-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.privacy-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--brand-dark);
  text-decoration: none;
}

.privacy-link:hover {
  text-decoration: underline;
}

.legal-links {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.offline-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.offline-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.4;
}

.offline-status-badge.online {
  background: #ecfdf5;
  color: #059669;
}

.offline-status-badge.offline {
  background: #fef2f2;
  color: #dc2626;
}

/* ── Google Sheets Sync ────────────────────── */
.sync-card {
  border-color: rgba(59, 130, 246, 0.2);
}

.sync-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.sync-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.sync-badge.disconnected {
  background: #fef2f2;
  color: #dc2626;
}

.sync-badge.connected {
  background: #ecfdf5;
  color: #059669;
}

.sync-badge.syncing {
  background: #eff6ff;
  color: #2563eb;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.5; }
}

.sync-info {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: var(--soft, #f8fafc);
  border-radius: 8px;
}

.sync-info a {
  color: #2563eb;
  font-size: 0.82rem;
  text-decoration: underline;
}

.sync-toggle-row {
  display: flex;
  align-items: center;
}

.sync-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
}

.sync-switch select {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line, #e2e8f0);
  background: var(--soft, #f8fafc);
  color: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  appearance: auto;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sync-actions .danger-button {
  grid-column: 1 / -1;
}

.transaction-list {
  display: grid;
  gap: 8px;
}

.transaction-card,
.master-item {
  display: grid;
  gap: 8px;
  padding: 10px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.transaction-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.transaction-main {
  min-width: 0;
}

.transaction-title {
  display: block;
  overflow: hidden;
  font-weight: 900;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.73rem;
}

.transaction-meta span {
  border-radius: 999px;
  background: #f4f6f5;
  padding: 3px 7px;
}

.transaction-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
}

.transaction-amount {
  font-weight: 950;
  font-size: 0.95rem;
  white-space: nowrap;
}

.amount-income {
  color: var(--income);
}

.amount-expense {
  color: var(--expense);
}

.amount-transfer {
  color: var(--transfer);
}

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

.small-button {
  min-height: 31px;
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 0.78rem;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef1ef;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.master-section {
  display: grid;
  gap: 11px;
}

.master-list {
  display: grid;
  gap: 8px;
}

.master-group {
  display: grid;
  gap: 8px;
  padding-top: 2px;
}

.master-group + .master-group {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.master-group h3 {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.9rem;
}

.master-list-inner {
  display: grid;
  gap: 8px;
}

.master-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.master-name {
  font-weight: 850;
}

.locked-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--soft);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 15;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.26);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 950;
}

.fab.hidden {
  display: none;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 6px 7px max(6px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
}

.nav-item.active {
  background: var(--soft);
  color: var(--brand-dark);
  box-shadow: inset 0 0 0 1px #cfe4df;
}

.nav-icon {
  display: block;
  font-size: 1rem;
  line-height: 1;
}

.recent-panel {
  padding: 11px;
}

.recent-panel .section-title {
  margin-bottom: 9px;
}

.recent-panel .text-button {
  min-height: 30px;
  font-size: 0.82rem;
}

.back-button {
  justify-self: start;
}

.help-guide-list {
  display: grid;
  gap: 10px;
}

.help-guide-card {
  display: grid;
  gap: 11px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 14px;
  background: #fbfdfc;
}

.help-guide-card div {
  display: grid;
  gap: 5px;
}

.help-guide-card strong {
  color: var(--text);
  font-size: 0.92rem;
}

.help-guide-card p {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.help-guide-action {
  width: 100%;
  min-height: 40px;
}

body.theme-dark {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1a1d24;
  --text: #e4e6eb;
  --muted: #8b8fa4;
  --line: #262a34;
  --brand: #2dd4bf;
  --brand-dark: #5eead4;
  --soft: #1e222b;
  --income: #34d399;
  --expense: #fb7185;
  --warning: #fbbf24;
  --info: #38bdf8;
  --transfer: #a78bfa;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body.theme-dark .app-header {
  background: rgba(17, 19, 24, 0.94);
  border-bottom-color: var(--line);
}

body.theme-dark .install-info-btn,
body.theme-dark .month-row,
body.theme-dark .summary-card,
body.theme-dark .stat-card,
body.theme-dark .panel,
body.theme-dark .app-modal,
body.theme-dark .bottom-sheet,
body.theme-dark .bottom-nav {
  background: var(--panel);
}

body.theme-dark .summary-card,
body.theme-dark .stat-card {
  border: 1px solid var(--line);
}

body.theme-dark .balance-card {
  background: var(--soft);
  border-color: rgba(45, 212, 191, 0.18);
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: #14161c;
  border-color: var(--line);
  color: var(--text);
}

body.theme-dark input:focus,
body.theme-dark select:focus,
body.theme-dark textarea:focus {
  border-color: rgba(45, 212, 191, 0.5);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.1);
}

body.theme-dark .chip {
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
}

body.theme-dark .chip:hover {
  border-color: var(--brand);
  color: var(--brand);
}

body.theme-dark .ghost-button,
body.theme-dark .file-button,
body.theme-dark .small-button,
body.theme-dark .settings-row,
body.theme-dark .update-info,
body.theme-dark .download-info-row,
body.theme-dark .download-guide-card,
body.theme-dark .help-guide-card,
body.theme-dark .transaction-card,
body.theme-dark .master-item,
body.theme-dark .install-tab {
  background: var(--soft);
  border-color: var(--line);
  color: var(--text);
}

body.theme-dark .install-tabs,
body.theme-dark .transaction-meta span,
body.theme-dark .close-sheet-button,
body.theme-dark .modal-close-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--muted);
}

body.theme-dark .fab {
  background: #0f766e;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.4);
}

body.theme-dark .install-tab.active,
body.theme-dark .primary-button {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

body.theme-dark .primary-button:hover {
  background: #0d9488;
  border-color: #0d9488;
}

body.theme-dark .ghost-button:hover,
body.theme-dark .file-button:hover,
body.theme-dark .small-button:hover {
  background: var(--panel);
  border-color: var(--brand);
  color: var(--brand);
}

body.theme-dark .text-button {
  color: var(--brand);
}

body.theme-dark .privacy-link {
  color: var(--brand);
}

body.theme-dark .privacy-section {
  background: var(--panel);
  border: 1px solid var(--line);
}

body.theme-dark .danger-button {
  background: rgba(251, 113, 133, 0.1);
  border-color: rgba(251, 113, 133, 0.24);
  color: #fb7185;
}

body.theme-dark .danger-button:hover {
  background: rgba(251, 113, 133, 0.18);
}

body.theme-dark .danger-zone {
  border-color: rgba(251, 113, 133, 0.16);
}

body.theme-dark .empty-state {
  border-color: var(--line);
  color: var(--muted);
}

body.theme-dark .bar-track {
  background: var(--soft);
}

body.theme-dark .bar-fill {
  background: var(--brand);
}

body.theme-dark .sheet-overlay,
body.theme-dark .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

body.theme-dark .nav-item {
  color: var(--muted);
}

body.theme-dark .nav-item.active {
  color: var(--brand);
}

body.theme-dark .bottom-nav {
  border-top-color: var(--line);
}

body.theme-dark .toast.success {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.28);
  color: #6ee7b7;
}

body.theme-dark .toast.warning {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.26);
  color: #fcd34d;
}

body.theme-dark .toast.info {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.26);
  color: #7dd3fc;
}

body.theme-dark .toast.danger,
body.theme-dark .toast.error {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.26);
  color: #fda4af;
}

body.theme-dark .download-guide-card {
  background: var(--soft);
  border-color: rgba(45, 212, 191, 0.12);
}

body.theme-dark .offline-status-badge.online {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
}

body.theme-dark .sync-badge.disconnected {
  background: rgba(251, 113, 133, 0.14);
  color: #fb7185;
}

body.theme-dark .sync-badge.connected {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
}

body.theme-dark .sync-badge.syncing {
  background: rgba(96, 165, 250, 0.14);
  color: #93c5fd;
}

body.theme-dark .sync-card {
  border-color: rgba(96, 165, 250, 0.18);
}

body.theme-dark .sync-info a {
  color: #93c5fd;
}

body.theme-dark .settings-card {
  border-color: var(--line);
}

body.theme-dark .master-item {
  background: var(--soft);
}

body.theme-dark .transaction-card {
  background: var(--panel);
  border-color: var(--line);
}

@media (min-width: 680px) {
  .summary-grid,
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-card.wide {
    grid-column: 1 / -1;
  }

  .transaction-form {
    grid-template-columns: repeat(2, 1fr);
  }

  .amount-field,
  .quick-row,
  .transaction-form label:last-of-type,
  .transaction-form .form-actions {
    grid-column: 1 / -1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.toast-container-top {
  position: fixed;
  top: 12px;
  right: 12px;
  left: 12px;
  z-index: 70;
  display: grid;
  gap: 8px;
  pointer-events: none;
  max-width: 420px;
  margin: 0 auto;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ── Legal Page Navigation ──────────────────── */
.legal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.legal-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--primary, #0f766e);
  text-decoration: none;
  transition: opacity 0.2s;
}

.legal-nav-link:hover {
  opacity: 0.75;
  text-decoration: underline;
}

.legal-nav-link.active {
  color: var(--text);
  pointer-events: none;
}

.legal-nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.legal-nav-sep {
  color: var(--muted, #94a3b8);
  font-size: 1rem;
}

.legal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line, #e2e8f0);
  font-size: 0.88rem;
}

.legal-footer-link {
  color: var(--primary, #0f766e);
  font-weight: 600;
  text-decoration: none;
}

.legal-footer-link:hover {
  text-decoration: underline;
}

.legal-footer-sep {
  color: var(--muted, #94a3b8);
}

body.theme-dark .legal-nav {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.theme-dark .legal-footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

body.theme-dark .legal-nav-link,
body.theme-dark .legal-footer-link {
  color: var(--brand, #14b8a6);
}
