/* Bright Business Command Center — v2.2 "clean" design
   Calm surfaces, big clear titles, one accent color (brand green), gold only for small highlights. */
:root {
  --green: #004F3B;
  --button: #00664A;
  --green-tint: #E8F1EC;
  --cream: #F7F0E4;
  --bg: #F8F5EF;
  --card: #FFFFFF;
  --ink: #14211C;
  --muted: #6F7A75;
  --faint: #A3ABA7;
  --gold: #C7A35A;
  --red: #B4533F;
  --red-tint: #FBEDEA;
  --line: rgba(20, 33, 28, 0.08);
  --field: #F3F0EA;
  --shadow: 0 1px 2px rgba(20, 33, 28, 0.04), 0 6px 20px rgba(20, 33, 28, 0.05);
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", Inter, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", Inter, "Segoe UI", Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
html[data-text-size="small"] body { font-size: 14px; }
html[data-text-size="large"] body { font-size: 18px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(0, 102, 74, 0.35); outline-offset: 2px; }
main { width: min(760px, 100%); margin: auto; padding: 14px 20px 120px; }

/* Top bar: small app name + settings, like an iOS navigation bar */
.header { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 52px; margin-bottom: 6px; }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.header h1 { color: var(--ink); font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 2px 0 0; }
.icon-button { border: 0; background: var(--card); color: var(--green); width: 40px; height: 40px; border-radius: 50%; font-size: 19px; box-shadow: var(--shadow); display: grid; place-items: center; transition: transform .15s ease; }
.icon-button:active { transform: scale(.94); }

/* Large page titles */
.hero { margin: 18px 0 22px; }
.hero h2 { font-family: var(--font-display); font-size: clamp(32px, 6vw, 46px); font-weight: 700; line-height: 1.05; letter-spacing: -.025em; color: var(--ink); margin: 0 0 6px; }
html[data-text-size="small"] .hero h2 { font-size: clamp(28px, 5vw, 40px); }
html[data-text-size="large"] .hero h2 { font-size: clamp(36px, 7vw, 54px); }
.hero p { font-size: 15px; color: var(--muted); margin: 0; }

/* Status message */
.attention { display: flex; align-items: center; gap: 12px; background: var(--green-tint); color: var(--green); border-radius: 16px; padding: 14px 16px; margin: 0 0 16px; font-size: 15px; font-weight: 500; line-height: 1.35; }
.attention::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

/* Key numbers in one calm card */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.metric { padding: 18px 20px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric span { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.metric strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: clamp(20px, 3.4vw, 28px); font-weight: 650; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.metric.expense strong { color: var(--red); }
.metric.profit strong { color: var(--green); }

/* Buttons: pills */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 30px; }
.primary, .secondary { min-height: 50px; border-radius: 999px; padding: 12px 20px; font-weight: 600; font-size: 16px; transition: transform .15s ease, background .15s ease; }
.primary { border: 0; background: var(--button); color: #fff; }
.secondary { border: 0; background: var(--card); color: var(--green); box-shadow: var(--shadow); }
.primary:active, .secondary:active { transform: scale(.97); }
.primary:hover { background: var(--green); }

/* Section labels & cards */
.section-label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 8px 4px 8px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.panel h2 { color: var(--ink); font-family: var(--font-display); font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 0 0 6px; }
.empty { color: var(--muted); margin: 10px 0 4px; font-size: 15px; }

/* List rows */
.transaction-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 14px 0; }
.transaction-row + .transaction-row { border-top: 1px solid var(--line); }
.transaction-main { min-width: 0; flex: 1; }
.transaction-row strong { display: block; font-weight: 600; font-size: 16px; }
.transaction-row small { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.transaction-end { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-shrink: 0; }
.transaction-amount { white-space: nowrap; font-weight: 650; font-size: 16px; font-variant-numeric: tabular-nums; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.row-actions { display: flex; gap: 6px; }
.edit-button, .delete-button { border: 0; border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; }
.edit-button { background: var(--green-tint); color: var(--green); }
.delete-button { background: var(--field); color: var(--muted); }
.delete-button:hover, .delete-button:focus-visible { background: var(--red-tint); color: var(--red); }

/* Tab bar: frosted, icons + labels */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 4; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px max(12px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)); background: rgba(248, 245, 239, 0.9); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
.bottom-nav button { border: 0; background: transparent; color: var(--faint); padding: 6px 4px 4px; font-size: 11px; font-weight: 600; display: grid; justify-items: center; gap: 3px; transition: color .15s ease; }
.bottom-nav button svg { width: 25px; height: 25px; }
.bottom-nav button.active { color: var(--button); }

/* Month switcher */
.month-switch { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); margin-top: 8px; }
.month-switch strong { min-width: 150px; text-align: center; color: var(--ink); font-size: 15px; font-weight: 600; }
.month-arrow { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--field); color: var(--green); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.month-arrow:disabled { opacity: .3; cursor: default; }

/* Insights */
.insight-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.insight { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.insight span { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.insight strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.insight-note { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.chart { height: 230px; }
.chart svg { width: 100%; height: 100%; display: block; }
.trend-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 4px 0 12px; color: var(--muted); font-size: 13px; }
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.trend-dot-sales { background: #004F3B; }
.trend-dot-expenses { background: #C96F52; }
.trend-dot-profit { background: #D6A62E; }
.chart-grid line { stroke: #EEEBE5; }
.chart-zero { stroke: #C9CFCB; stroke-width: 1.5; }
.chart svg text { fill: #9AA29E; font-size: 10px; font-family: var(--font); }
.chart-line { fill: none; stroke-width: 2.75; stroke-linecap: round; stroke-linejoin: round; }
.chart-sales { stroke: #004F3B; }
.chart-expenses { stroke: #C96F52; }
.chart-profit { stroke: #D6A62E; }
.chart svg circle { stroke: #fff; stroke-width: 2; }
.chart svg circle.chart-sales { fill: #004F3B; }
.chart svg circle.chart-expenses { fill: #C96F52; }
.chart svg circle.chart-profit { fill: #D6A62E; }
.expense-composition-panel > p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.expense-empty { color: var(--muted); background: var(--field); border-radius: 14px; padding: 20px; text-align: center; }
.expense-composition-layout { display: grid; grid-template-columns: minmax(170px, 210px) minmax(0, 1fr); gap: 26px; align-items: center; }
.expense-donut-column { display: grid; justify-items: center; gap: 10px; }
.expense-donut { width: 180px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; margin: auto; position: relative; }
.expense-donut::after { content: ""; position: absolute; inset: 22%; background: var(--card); border-radius: 50%; }
.expense-donut > div { position: relative; z-index: 1; display: grid; gap: 4px; justify-items: center; max-width: 72%; text-align: center; }
.expense-donut small { color: var(--muted); font-size: 11px; }
.expense-donut-total { color: var(--ink); font-size: 17px; font-weight: 650; text-align: center; overflow-wrap: anywhere; }
.expense-legend { display: grid; min-width: 0; }
.expense-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; }
.expense-row + .expense-row { border-top: 1px solid var(--line); }
.expense-row-label { min-width: 0; }
.expense-row-label strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-color-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; vertical-align: 1px; }
.expense-color-dot.cream-dot { outline: 1px solid var(--green); outline-offset: 1px; }
.expense-row-label small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.expense-row > b { color: var(--ink); white-space: nowrap; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.expense-list-toggle { border: 0; background: transparent; color: var(--button); font-size: 14px; font-weight: 600; padding: 10px 0 2px; }
.comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.comparison > div { min-width: 0; background: var(--field); padding: 16px; border-radius: 16px; }
.comparison span, .comparison small { display: block; color: var(--muted); font-size: 13px; }
.comparison strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: clamp(18px, 4vw, 22px); font-weight: 650; margin: 4px 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Settings: a floating sheet */
.settings-wrap { position: relative; }
.settings-panel { position: absolute; right: 0; top: 50px; z-index: 6; width: min(320px, calc(100vw - 32px)); max-height: calc(100vh - 140px); overflow: auto; padding: 18px; background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 22px; box-shadow: 0 20px 50px rgba(20, 33, 28, 0.18); animation: pop .18s ease-out; }
.settings-panel h2 { font-family: var(--font-display); font-size: 20px; font-weight: 650; margin: 0 0 14px; }
.settings-panel label { display: block; color: var(--muted); font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.settings-panel select { width: 100%; padding: 11px 12px; border: 0; border-radius: 12px; margin-bottom: 14px; background: var(--field); appearance: auto; }
.settings-note { color: var(--muted); font-size: 12px; line-height: 1.45; margin: -6px 0 12px; }
.font-options { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--field); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.font-options button { border: 0; background: transparent; border-radius: 9px; padding: 7px 0; color: var(--muted); font-weight: 600; }
.font-options button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 33, 28, 0.12); }
.settings-actions { display: grid; gap: 10px; }
.settings-primary-actions { display: grid; background: var(--field); border-radius: 14px; overflow: hidden; }
.settings-primary-actions .text-button { padding: 12px 14px; }
.settings-primary-actions .text-button + .text-button, .settings-primary-actions input + .text-button { border-top: 1px solid var(--line); }
.text-button { border: 0; background: transparent; color: var(--button); font-weight: 600; min-height: 44px; text-align: left; width: 100%; }
.settings-danger-action .text-button { color: var(--red); background: var(--red-tint); border-radius: 14px; padding: 12px 14px; }
.install-guidance { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.install-guidance-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.install-guidance h3 { font-size: 15px; font-weight: 650; margin: 0; }
.install-close { border: 0; background: var(--field); color: var(--muted); width: 28px; height: 28px; border-radius: 50%; font-size: 18px; line-height: 1; }
.install-guidance ol { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 10px 0 0; padding-left: 20px; }

/* Add / edit form: bottom sheet on phones, centered card on larger screens */
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(10, 20, 16, 0.32); animation: fade .2s ease-out; }
.modal[hidden], .page[hidden], .settings-panel[hidden], .toast[hidden] { display: none; }
.modal-box { position: relative; width: min(440px, 100%); background: var(--card); padding: 22px 20px 20px; border-radius: 24px; box-shadow: 0 24px 60px rgba(10, 20, 16, 0.25); animation: rise .25s cubic-bezier(.2, .9, .3, 1); }
.modal-box h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -.015em; margin: 0 0 8px; }
.modal-box label { display: block; color: var(--muted); font-size: 13px; font-weight: 500; margin: 14px 0 6px; }
.modal-box input, .modal-box select { width: 100%; min-height: 48px; padding: 12px 14px; border: 1.5px solid transparent; border-radius: 14px; background: var(--field); font-size: 16px; }
.modal-box input:focus, .modal-box select:focus { outline: none; border-color: var(--button); background: var(--card); }
.modal-box input[data-amount] { font-family: var(--font-display); font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.modal-box input[aria-invalid="true"] { border-color: var(--red); background: var(--red-tint); }
.form-error { color: var(--red); background: var(--red-tint); border-radius: 12px; padding: 10px 12px; margin: 14px 0 0; font-size: 14px; font-weight: 500; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.modal-actions .secondary { background: var(--field); box-shadow: none; }

/* Undo message */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 14px; background: rgba(20, 33, 28, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); color: #fff; padding: 10px 10px 10px 18px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); max-width: calc(100% - 32px); font-size: 15px; animation: rise .25s cubic-bezier(.2, .9, .3, 1); }
.toast span { white-space: nowrap; }
.toast-action { border: 0; background: var(--gold); color: #1B1406; font-weight: 700; border-radius: 999px; padding: 8px 16px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.toast { animation-name: toastIn; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (min-width: 900px) {
  .bottom-nav { left: 50%; right: auto; bottom: 18px; transform: translateX(-50%); width: 380px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; box-shadow: 0 10px 30px rgba(20, 33, 28, 0.12); }
  .toast { bottom: 96px; }
}

@media (max-width: 600px) {
  main { padding: 8px 16px 112px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 16px; }
  .metric.profit { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .insight-grid { grid-template-columns: 1fr 1fr; }
  .insight.insight:last-child { grid-column: 1 / -1; }
  .panel { padding: 16px; }
  .expense-composition-layout { grid-template-columns: 1fr; gap: 18px; }
  .expense-donut { width: min(170px, 48vw); }
  .comparison { grid-template-columns: 1fr; }
  /* Form slides up from the bottom like an iPhone sheet */
  .modal { place-items: end center; padding: 0; }
  .modal-box { width: 100%; border-radius: 24px 24px 0 0; padding: 26px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
  .modal-box::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: #D9D5CD; }
}
@media (max-width: 520px) {
  .transaction-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .transaction-row small { -webkit-line-clamp: 3; }
  .transaction-end { justify-content: space-between; }
}
@media (max-width: 360px) {
  .quick-actions { grid-template-columns: 1fr; }
  .insight-grid { grid-template-columns: 1fr; }
}
.modal-box input[type="number"]::-webkit-outer-spin-button, .modal-box input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.modal-box input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
