:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #0b0b0d;
  --surface-strong: #121214;
  --line: #29292d;
  --line-soft: #1a1a1d;
  --text: #f5f5f7;
  --muted: #96969d;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, .15);
  --danger: #ff453a;
  --success: #30d158;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.access-gate {
  min-height: 100vh; min-height: 100dvh; display: grid; place-content: center;
  justify-items: center; gap: 12px; padding: 32px; text-align: center;
}
.access-gate h1 { margin: 8px 0 0; font-size: 24px; }
.access-gate p { max-width: 340px; margin: 0; color: var(--muted); line-height: 1.45; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { width: min(100%, 760px); min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--bg); }
.content { padding: max(20px, env(safe-area-inset-top)) 20px calc(104px + var(--safe-bottom)); }
.view { animation: reveal .22s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } }

.period-tabs { display: grid; grid-template-columns: repeat(5, minmax(max-content, 1fr)); gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line-soft); }
.period-tabs::-webkit-scrollbar { display: none; }
.period-tabs button { position: relative; min-width: 72px; padding: 13px 6px 15px; border: 0; background: transparent; color: var(--muted); font-size: 15px; white-space: nowrap; cursor: pointer; }
.period-tabs button::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.period-tabs button.active { color: var(--accent); }
.period-tabs button.active::after { background: var(--accent); }

.hero { padding: 34px 0 18px; }
.hero-heading-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.eyebrow { margin: 0; color: var(--muted); font-size: 16px; }
.period-label { margin: 7px 0 0; color: #66666c; font-size: 12px; line-height: 1.3; }
.hero-amount { margin: 22px 0 8px; font-size: clamp(44px, 13vw, 76px); font-weight: 600; line-height: .96; letter-spacing: -3px; font-variant-numeric: tabular-nums; }
.change-value { display: inline-flex; margin: 8px 0 0; color: var(--accent); font-size: 22px; font-variant-numeric: tabular-nums; }
.change-value.down { color: var(--danger); }
.change-value.neutral { color: var(--muted); font-size: 14px; }

.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--accent); cursor: pointer; }
.icon-button svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.privacy-toggle { flex: 0 0 auto; border-color: transparent; background: transparent; }

.chart-card { position: relative; min-height: 250px; margin: 8px -4px 14px; }
.chart { display: block; width: 100%; height: 250px; overflow: visible; }
.chart line { stroke: #303036; stroke-width: .22; stroke-dasharray: 1.2 1.4; vector-effect: non-scaling-stroke; }
.chart path { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 4px rgba(10, 132, 255, .15)); }
.chart-labels text { fill: var(--muted); font-size: 3.1px; font-variant-numeric: tabular-nums; }
.empty-chart { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--muted); font-size: 14px; }
.financial-concealed .chart { filter: blur(11px); opacity: .35; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 0 30px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-card { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; padding: 22px 12px; min-width: 0; }
.stat-card + .stat-card { border-left: 1px solid var(--line); }
.stat-card svg { width: 31px; height: 31px; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.stat-card p { margin: 0 0 5px; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: clamp(17px, 5vw, 24px); font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }

.summary-preview { display: block; width: 100%; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.section-title-row h2 { margin: 0; font-size: 23px; letter-spacing: -.4px; }
.badge { display: inline-grid; place-items: center; min-width: 28px; height: 28px; margin-left: 7px; padding: 0 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 15px; vertical-align: 2px; }
.chevron { color: var(--muted); font-size: 38px; font-weight: 200; line-height: 1; }
.preview-body { padding: 16px 0 0; }
.preview-date { margin: 0 0 14px; color: var(--muted); }
.preview-body dl { margin: 0; }
.preview-body dl div { display: flex; justify-content: space-between; gap: 20px; padding: 6px 0; }
.preview-body dt { color: var(--muted); }
.preview-body dd { margin: 0; font-variant-numeric: tabular-nums; }
.preview-body .preview-total { margin-top: 10px; padding: 16px 0 0; border-top: 1px solid var(--line); font-size: 21px; }
.preview-total dt { color: var(--text); }
.preview-total dd { color: var(--accent); }

.view-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0 22px; }
.view-header h1 { margin: 4px 0 0; font-size: 35px; letter-spacing: -1px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 13px; background: var(--surface-strong); }
.segmented button { min-height: 38px; padding: 7px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.segmented button.active { background: #29292d; color: var(--text); box-shadow: 0 1px 5px rgba(0,0,0,.35); }
.card-list { display: grid; gap: 12px; margin-top: 18px; }
.summary-card, .lot-card, .settings-card { border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(145deg, #0c0c0f, #070708); }
.summary-card { padding: 18px; }
.summary-card-header { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.summary-card h2 { margin: 0; font-size: 19px; }
.summary-period { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.status-pill { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.status-pill.confirmed { background: rgba(48, 209, 88, .13); color: var(--success); }
.money-rows { display: grid; gap: 8px; margin: 17px 0 0; }
.money-row { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.money-row strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.money-row.total { margin-top: 7px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--text); font-size: 19px; }
.money-row.total strong { color: var(--accent); }
.summary-actions { display: grid; grid-template-columns: 44px 44px 1fr; gap: 8px; margin-top: 16px; }
.summary-actions button { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-strong); cursor: pointer; }
.summary-actions .confirm-button { border-color: rgba(10, 132, 255, .4); background: var(--accent-soft); color: var(--accent); }
.adjustment-history { margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }

.settings-card { display: grid; gap: 18px; padding: 18px; }
.settings-card h2, .lots-heading h2 { margin: 0; font-size: 20px; }
.settings-card p, .lots-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.inline-form { display: grid; grid-template-columns: minmax(110px, 1fr) auto; gap: 9px; }
input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #151518; color: var(--text); }
.lots-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 30px; }
.lot-card { padding: 16px; }
.lot-card h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.lot-meta { margin: 6px 0 14px; color: var(--muted); font-size: 12px; }
.lot-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.lot-status { min-height: 17px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.security-note { margin: 26px 8px 0; color: #66666c; font-size: 12px; line-height: 1.5; text-align: center; }

.primary-button, .secondary-button { min-height: 46px; padding: 10px 16px; border-radius: 12px; cursor: pointer; }
.primary-button { border: 0; background: var(--accent); color: #fff; font-weight: 600; }
.secondary-button { width: 100%; margin-top: 14px; border: 1px solid var(--line); background: var(--surface-strong); color: var(--text); }
.compact { width: auto; min-height: 40px; margin-top: 0; padding: 8px 13px; border-radius: 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: wait; }
.empty-state { margin: 60px 0; color: var(--muted); text-align: center; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(100%, 760px); transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 1fr); padding: 11px 16px var(--safe-bottom); border-top: 1px solid rgba(40,40,44,.9); background: rgba(0,0,0,.88); backdrop-filter: blur(18px); }
.bottom-nav button { display: grid; justify-items: center; gap: 4px; padding: 4px; border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.bottom-nav svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button.active { color: var(--accent); }

.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: end center; padding: 20px 16px var(--safe-bottom); background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.modal-card { width: min(100%, 520px); padding: 22px; border: 1px solid var(--line); border-radius: 22px; background: #111114; box-shadow: 0 20px 70px rgba(0,0,0,.6); }
.modal-card h2 { margin: 0; font-size: 24px; }
.modal-card > p { margin: 8px 0 18px; color: var(--muted); line-height: 1.4; }
.adjustment-operation { margin-bottom: 18px; }
.modal-card label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.modal-actions .secondary-button { margin: 0; }

.toast { position: fixed; z-index: 70; left: 50%; bottom: calc(92px + var(--safe-bottom)); width: max-content; max-width: calc(100% - 32px); transform: translateX(-50%); padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; background: rgba(35,35,39,.96); color: var(--text); font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.45); }

@media (min-width: 620px) {
  .content { padding-left: 34px; padding-right: 34px; }
  .settings-card { grid-template-columns: 1fr 260px; align-items: center; }
  .chart-card, .chart { min-height: 300px; height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
