:root {
  --bg: #0a0d0c;
  --surface: #111614;
  --surface-2: #171d1a;
  --line: #29312d;
  --text: #f1f5ee;
  --muted: #98a39d;
  --lime: #c8ff72;
  --lime-dark: #1e2b17;
  --coral: #ff8c76;
  --blue: #79b8ff;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% -10%, #273222 0, transparent 32rem), var(--bg); }
a { color: var(--lime); text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, .button { cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 580px); padding: clamp(32px, 7vw, 72px); border: 1px solid var(--line); border-radius: 32px; background: linear-gradient(145deg, rgba(23,29,26,.98), rgba(13,17,15,.98)); box-shadow: 0 40px 100px rgba(0,0,0,.45); }
.brand-mark { display: block; width: 88px; height: 88px; object-fit: contain; filter: drop-shadow(0 10px 24px rgba(153, 255, 0, .14)); }
.login-card h1, .review-header h1 { font-size: clamp(2.4rem, 8vw, 4.7rem); letter-spacing: -.065em; line-height: .96; margin: 18px 0 24px; }
.lede { color: var(--muted); font-size: 1.1rem; line-height: 1.7; }
.fine-print { color: var(--muted); font-size: .78rem; margin: 20px 0 0; }
.eyebrow { color: var(--lime); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.home-shell { width: min(100% - 48px, 1180px); min-height: 100vh; display: flex; flex-direction: column; margin: 0 auto; }
.home-topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.instance-status { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(17,22,20,.72); font-size: .76rem; }
.instance-status span, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(200,255,114,.08); }
.home-main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: clamp(52px, 9vh, 110px) 0 56px; }
.home-hero { display: grid; grid-template-columns: 1.12fr .88fr; gap: clamp(40px, 8vw, 100px); align-items: center; }
.home-copy h1 { max-width: 780px; margin: 14px 0 24px; font-size: clamp(3rem, 6.2vw, 5.8rem); line-height: .96; letter-spacing: -.07em; }
.home-copy .lede { max-width: 670px; margin: 0; }
.home-actions { display: flex; align-items: center; gap: 18px; margin-top: 32px; }
.home-actions .button { min-height: 52px; padding: 0 24px; box-shadow: 0 14px 36px rgba(137,220,0,.12); }
.home-actions span { max-width: 170px; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.home-defaults { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; max-width: 670px; margin: 46px 0 0; }
.home-defaults div { padding: 17px 18px 0 0; border-top: 1px solid var(--line); }
.home-defaults dt { color: var(--muted); font-size: .7rem; }
.home-defaults dd { margin: 7px 0 0; font-size: .92rem; font-weight: 780; }
.example-card { position: relative; overflow: hidden; padding: 24px; border: 1px solid #35422f; border-radius: 28px; background: linear-gradient(155deg, rgba(29,40,24,.96), rgba(14,18,16,.98) 58%); box-shadow: 0 38px 90px rgba(0,0,0,.38); }
.example-card::before { content: ""; position: absolute; width: 240px; height: 240px; top: -150px; right: -100px; border-radius: 50%; background: rgba(174,255,38,.16); filter: blur(28px); }
.example-heading { position: relative; display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: .78rem; font-weight: 750; }
.example-heading > div { display: flex; align-items: center; gap: 9px; }
.example-heading small { color: var(--muted); font-weight: 600; }
.example-input { display: grid; gap: 7px; margin: 26px 0 14px; padding: 18px; border: 1px solid rgba(255,255,255,.07); border-radius: 15px; background: rgba(7,10,8,.55); }
.example-input small { color: var(--muted); }
.example-input strong { font-size: 1.22rem; letter-spacing: -.02em; }
.example-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--line); }
.example-fields div { padding: 15px; background: rgba(12,16,14,.92); }
.example-fields dt { color: var(--muted); font-size: .68rem; }
.example-fields dd { margin: 7px 0 0; font-size: .88rem; font-weight: 750; }
.example-card > p { margin: 18px 2px 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }
.home-info { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: clamp(54px, 9vh, 96px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.home-info article { display: grid; grid-template-columns: auto 1fr; gap: 16px; padding: 25px clamp(18px, 3vw, 32px); border-right: 1px solid var(--line); }
.home-info article:first-child { padding-left: 0; }
.home-info article:last-child { border-right: 0; }
.home-info article > span { color: var(--lime); font-size: .68rem; font-weight: 800; }
.home-info h2 { margin: -3px 0 7px; font-size: 1rem; }
.home-info p { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.home-footer { display: flex; flex-wrap: wrap; gap: 9px 24px; padding: 22px 0; color: #6f7973; font-size: .68rem; }
.home-footer span + span::before { content: "·"; margin-right: 24px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px; font-weight: 750; color: var(--text); background: none; }
.button.primary { color: #11170d; background: var(--lime); }
.button.secondary { border-color: var(--line); background: var(--surface-2); }
.button.ghost { border-color: var(--line); color: var(--muted); }
.button.small { min-height: 34px; padding: 0 12px; font-size: .8rem; }
.telegram { width: 100%; margin-top: 22px; }

.app-shell { width: min(100% - 32px, 1220px); margin: 0 auto; padding-bottom: 80px; }
.app-shell.narrow { width: min(100% - 32px, 850px); }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 28px; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 850; letter-spacing: -.025em; }
.wordmark img { display: block; width: 34px; height: 34px; object-fit: contain; }
.section-nav { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.section-nav a { color: var(--muted); font-size: .76rem; font-weight: 650; }
.section-nav a:hover { color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: .86rem; }
.user-identity { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .86rem; }
.user-avatar { display: block; width: 34px; height: 34px; border: 1px solid #3c4937; border-radius: 50%; object-fit: cover; background: var(--surface-2); box-shadow: 0 0 0 3px rgba(200,255,114,.05); }

.hero-grid { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 14px; margin: 44px 0 16px; }
.metric { min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric.primary-metric { background: linear-gradient(135deg, #1d2818, #121713); }
.metric span { color: var(--muted); font-size: .8rem; }
.metric strong { font-size: clamp(1.7rem, 3vw, 2.65rem); letter-spacing: -.055em; }
.metric strong small { color: var(--muted); font-size: .7rem; letter-spacing: 0; }
.metric em { color: var(--coral); font-size: .72rem; font-style: normal; }
.metric > a { color: var(--muted); font-size: .7rem; }
.metric > a:hover { color: var(--lime); }
.positive { color: var(--lime); }
.negative { color: var(--coral); }

.capture-panel { display: grid; grid-template-columns: .8fr 1.2fr; gap: 40px; align-items: center; margin: 16px 0 60px; padding: clamp(24px, 5vw, 52px); border-radius: 28px; color: #12160f; background: var(--lime); }
.capture-panel .eyebrow { color: #435d27; }
.capture-panel h2 { margin: 5px 0; font-size: 2rem; letter-spacing: -.04em; }
.capture-panel p { color: #43503a; line-height: 1.5; }
.capture-form textarea { width: 100%; min-height: 120px; resize: vertical; padding: 16px; border: 1px solid rgba(0,0,0,.15); border-radius: 14px; color: var(--text); background: #121713; }
.capture-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.capture-panel .button.primary { color: var(--text); background: #121713; }
.capture-panel .button.primary:disabled { cursor: wait; opacity: .82; }
.file-button { position: relative; overflow: hidden; padding: 10px 0; font-weight: 750; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.submit-progress { display: inline-flex; align-items: center; gap: 9px; }
.submit-progress[hidden], .processing-note[hidden] { display: none; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--lime); border-radius: 50%; animation: spin .7s linear infinite; }
.processing-note { margin: 10px 0 0; color: #27351f; font-size: .74rem; font-weight: 700; text-align: right; }
@keyframes spin { to { transform: rotate(360deg); } }

.section { margin: 60px 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 20px; }
.section-heading > span { color: var(--muted); font-size: .76rem; }
.section-heading h2, .settings-card h2, .line-items h2 { margin: 4px 0 0; font-size: 1.7rem; letter-spacing: -.04em; }
.draft-section { margin-top: 0; }
.draft-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.draft-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 20px; border-bottom: 1px solid var(--line); color: var(--text); transition: background .16s ease; }
.draft-row:last-child { border-bottom: 0; }
.draft-row:hover { background: var(--surface-2); }
.draft-copy { min-width: 0; display: grid; gap: 4px; }
.draft-copy > span { color: var(--lime); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; }
.draft-copy > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-copy > small { color: var(--muted); font-size: .7rem; }
.draft-value { flex: 0 0 auto; display: grid; justify-items: end; gap: 7px; }
.draft-value > strong { font-variant-numeric: tabular-nums; }
.draft-value > strong small { color: var(--muted); font-size: .68rem; }
.draft-value > span { color: var(--muted); font-size: .7rem; }
.empty-state { padding: 30px; border: 1px dashed #354039; border-radius: var(--radius); background: rgba(17,22,20,.55); }
.empty-state p { max-width: 540px; margin: 7px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.account-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.account-card { min-height: 170px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-card h3 { margin: 5px 0; }
.account-card strong { font-size: 1.7rem; letter-spacing: -.04em; }
.account-card strong small, .account-card p, .account-kind { color: var(--muted); font-size: .75rem; }
.account-kind { text-transform: uppercase; letter-spacing: .1em; }
.fx-notes { margin-top: 14px; color: var(--muted); font-size: .75rem; }
.fx-notes summary { cursor: pointer; color: var(--text); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 16px 18px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .88rem; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); }
td.amount { font-variant-numeric: tabular-nums; font-weight: 750; }
td.amount.income { color: var(--lime); }
td.amount.expense { color: var(--coral); }
.text-button { border: 0; color: var(--muted); background: none; }
.activity-section .section-heading { margin-bottom: 12px; }
.activity-table { min-width: 760px; table-layout: auto; }
.activity-table th, .activity-table td { padding: 9px 12px; vertical-align: middle; }
.activity-table th { height: 34px; background: #0e1311; font-size: .62rem; }
.activity-table td { height: 42px; font-size: .78rem; }
.activity-table tbody tr:last-child td { border-bottom: 0; }
.activity-table tbody tr:hover { background: rgba(255,255,255,.018); }
.activity-table th:first-child, .activity-table td:first-child { padding-left: 14px; }
.activity-table th:last-child, .activity-table td:last-child { padding-right: 14px; }
.activity-date { width: 112px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.activity-record { min-width: 190px; }
.activity-record a { color: var(--text); }
.activity-record strong { font-size: .8rem; font-weight: 720; }
.kind-chip { display: inline-block; min-width: 62px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface-2); font-size: .58rem; font-weight: 800; letter-spacing: .07em; text-align: center; text-transform: uppercase; }
.kind-chip.income { border-color: rgba(200,255,114,.22); color: var(--lime); }
.kind-chip.expense { border-color: rgba(255,140,118,.22); color: var(--coral); }
.activity-table th:nth-last-child(2), .activity-table td.amount { white-space: nowrap; text-align: right; }
.activity-action { width: 70px; text-align: right; }
.activity-action .text-button { padding: 3px 0; font-size: .66rem; }
.activity-action .text-button:hover { color: var(--text); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stacked-form, .review-form { display: grid; gap: 16px; margin-top: 24px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 650; }
label small { font-weight: 400; }
input, textarea, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text); background: #0d110f; }
input:focus, textarea:focus, select:focus { border-color: var(--lime); box-shadow: 0 0 0 3px rgba(200,255,114,.09); }
textarea { min-height: 100px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.tag-list > span { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 8px; color: var(--muted); background: var(--surface-2); font-size: .72rem; }
.tag-list form { display: inline; }
.tag-list button { border: 0; color: var(--muted); background: none; }

.back-link { display: inline-block; margin-top: 32px; color: var(--muted); }
.review-header { padding: 50px 0 26px; }
.review-header h1 { margin-bottom: 12px; }
.review-header > p:last-child { color: var(--muted); }
.warning-box { padding: 18px; border: 1px solid #6a4338; border-radius: 14px; color: #ffc3b7; background: #241713; }
.warning-box p { margin: 6px 0 0; font-size: .85rem; }
.review-form { padding: clamp(22px, 5vw, 42px); border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.line-items { margin-top: 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.line-items > div { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line-items small { color: var(--muted); }
.review-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.cancel-form { display: flex; justify-content: center; margin-top: 18px; }
.error-card { text-align: center; }

@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; }
  .home-copy { max-width: 780px; }
  .example-card { width: min(100%, 620px); }
  .home-info { grid-template-columns: 1fr; }
  .home-info article, .home-info article:first-child { padding: 22px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .home-info article:last-child { border-bottom: 0; }
  .section-nav { display: none; }
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .capture-panel { grid-template-columns: 1fr; gap: 12px; }
  .account-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .home-shell { width: min(100% - 28px, 1180px); }
  .home-topbar { min-height: 72px; }
  .instance-status { padding: 7px 9px; }
  .home-main { padding-top: 42px; }
  .home-copy h1 { font-size: clamp(2.7rem, 14vw, 4.3rem); }
  .home-actions { align-items: stretch; flex-direction: column; }
  .home-actions .button { width: 100%; }
  .home-actions span { max-width: none; text-align: center; }
  .home-defaults { margin-top: 34px; }
  .home-defaults div { padding-right: 8px; }
  .example-card { padding: 18px; border-radius: 22px; }
  .home-footer { display: grid; gap: 6px; }
  .home-footer span + span::before { content: none; }
  .app-shell { width: min(100% - 20px, 1220px); }
  .topbar { min-height: 72px; }
  .user-identity > span { display: none; }
  .hero-grid, .account-grid, .settings-grid, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .hero-grid { margin-top: 24px; }
  .metric { min-height: 125px; }
  .capture-panel { padding: 24px; }
  .capture-actions { align-items: stretch; flex-direction: column; }
  .capture-actions .button { width: 100%; }
  .draft-row { align-items: flex-start; padding: 16px; }
  .draft-copy > strong { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.5s; }
}
