:root {
  color-scheme: dark;
  --bg: #0c0f13;
  --card: #171c23;
  --ink: #eef1f5;
  --muted: #a0aab8;
  --line: #2b333e;
  --green: #b6df94;
  --light: #243327;
  --amber: #efbe78;
  --radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 85% 0%, #1c292530, transparent 550px), var(--bg);
  color: var(--ink);
  font-size: 15px;
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
.shell { max-width: 850px; margin: auto; padding: var(--tg-content-safe-area-inset-top, 0px) 26px 105px; }
header { display: flex; align-items: center; justify-content: space-between; padding: 26px 0 23px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 850; letter-spacing: 2px; }
.brand-mark { display: grid; place-items: center; background: linear-gradient(135deg, #c4e8a6, #96c47a); color: #152019; height: 35px; width: 35px; border-radius: 10px; font-size: 23px; letter-spacing: -2px; box-shadow: 0 0 22px #b6df9412; }
.brand-tag { font-size: 9px; font-weight: 600; letter-spacing: 1.6px; color: var(--muted); padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; margin-left: 4px; }
.icon-button { background: #171c2380; border: 1px solid var(--line); color: var(--muted); border-radius: 50%; width: 38px; height: 38px; font-size: 24px; }
main { padding-top: 30px; }
.eyebrow { font-size: 10px; font-weight: 750; letter-spacing: 2px; color: var(--muted); }
h1 { font-size: 34px; letter-spacing: -1.4px; margin: 8px 0 10px; line-height: 1.12; }
h2 { font-size: 21px; letter-spacing: -.5px; margin: 8px 0; }
h3 { font-size: 16px; margin: 0 0 6px; }
.subtitle { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 24px; }
.hero { border-radius: var(--radius); padding: 26px; background: radial-gradient(ellipse at 90% 10%, #b6df941c, transparent 65%), linear-gradient(120deg, #1c2822, #151b20); border: 1px solid #354738; color: var(--ink); margin: 25px 0 16px; position: relative; overflow: hidden; box-shadow: 0 12px 32px #00000020; }
.hero:after { content: "А"; position: absolute; right: 20px; top: -30px; font-size: 200px; font-weight: 900; color: #b6df9408; pointer-events: none; }
.hero .eyebrow { color: #c3d2c1; }
.hero-value { font-size: 38px; font-weight: 650; letter-spacing: -1.5px; margin: 14px 0 10px; color: #d8efc7; }
.hero-value small { font-size: 14px; letter-spacing: 0; color: #a5b5a3; }
.hero-footer { display: flex; justify-content: space-between; font-size: 12px; color: #b3c0b3; border-top: 1px solid #b6df9420; padding-top: 16px; position: relative; z-index: 1; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 15px 0 25px; }
.stat { padding: 19px; background: linear-gradient(135deg, #1b222b, var(--card)); border: 1px solid var(--line); border-radius: 16px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { display: block; font-size: 23px; letter-spacing: -.6px; margin-top: 10px; }
.stat small { font-size: 11px; font-weight: 400; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 14px; gap: 10px; }
.section-head h2 { margin: 0; }
.link { color: var(--green); font-size: 12px; font-weight: 650; }
.card { background: linear-gradient(135deg, #1a2028, var(--card)); border: 1px solid var(--line); border-radius: 16px; padding: 19px; margin: 10px 0; box-shadow: 0 4px 15px #0000000d; }
.car-card { display: block; transition: transform .15s, border-color .15s, background .15s; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.car-icon { height: 45px; width: 45px; background: linear-gradient(135deg, #2c3b2d, #202c25); color: var(--green); border: 1px solid #3b4d373d; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.car-icon svg { width: 27px; height: 27px; }
.car-main { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }
.card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; font-size: 12px; gap: 10px; }
.pill { display: inline-block; font-size: 10px; font-weight: 650; border-radius: 6px; padding: 5px 8px; background: var(--light); color: #c4e6ac; border: 1px solid #b6df9418; }
.pill.amber { background: #33291c; color: var(--amber); border-color: #efbe7820; }
.positive { color: var(--green); }
.negative { color: #f09084; }
.primary { border: 1px solid #c5e6a7; border-radius: 12px; background: linear-gradient(120deg, #bfe49f, #a9d484); color: #192315; padding: 14px 20px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 16px #b6df940b; transition: filter .15s, transform .15s; }
.secondary { border: 1px solid #394452; border-radius: 12px; background: #202731; color: var(--ink); padding: 13px 18px; font-size: 14px; font-weight: 600; }
.full { width: 100%; }
.actions { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.actions > * { flex: 1; }
.empty { padding: 35px 20px; text-align: center; line-height: 1.7; color: var(--muted); border: 1px dashed #35404b; border-radius: 16px; margin: 15px 0; background: #14191f70; }
.search { width: 100%; padding: 14px 16px; background: #131820; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); margin: 0 0 14px; outline-color: var(--green); }
nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 850px); background: #131820ed; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid #35404b; display: flex; justify-content: space-around; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 3; box-shadow: 0 -10px 35px #00000025; }
nav a { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); min-width: 55px; padding: 5px 12px; border-radius: 10px; }
nav svg { height: 21px; width: 21px; }
nav a.active { color: var(--green); font-weight: 700; background: #b6df940b; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-grid span { font-size: 11px; color: var(--muted); display: block; margin-bottom: 5px; }
.detail-grid strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.ledger { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ledger:last-child { border: 0; }
.ledger strong { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.back { display: block; margin-bottom: 14px; color: var(--green); font-size: 13px; }
dialog { width: min(94%, 480px); border: 1px solid #394452; border-radius: 24px; padding: 25px; color: var(--ink); background: linear-gradient(145deg, #202731, #151a21); max-height: 85vh; overflow: auto; box-shadow: 0 28px 90px #00000070; }
dialog::backdrop { background: #06080bbd; backdrop-filter: blur(6px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
label { display: block; font-size: 12px; font-weight: 650; margin: 16px 0 8px; color: #c5ced9; }
input, select { width: 100%; border: 1px solid #35404b; border-radius: 10px; padding: 13px; background: #11161d; color: var(--ink); outline-color: var(--green); min-width: 0; }
input::placeholder { color: #929ead; opacity: 1; }
input:focus, select:focus { border-color: var(--green); }
.form-error { color: #f49b90; font-size: 13px; line-height: 1.6; min-height: 20px; }
.demo-label { font-size: 11px; color: #cbd4c1; background: #21291f; border: 1px solid #b6df9418; padding: 9px 12px; border-radius: 8px; margin-bottom: 20px; }
#toast { position: fixed; bottom: 105px; left: 50%; transform: translateX(-50%); background: #232d25; color: #e3f0d9; border: 1px solid #48613f; box-shadow: 0 8px 30px #00000050; padding: 13px 20px; border-radius: 12px; max-width: 90%; width: max-content; font-size: 13px; z-index: 8; }
.date { font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.alert { padding: 15px; border-radius: 12px; background: #33291c; border: 1px solid #efbe7820; color: var(--amber); font-size: 13px; line-height: 1.6; }
[hidden] { display: none !important; }
@media (hover: hover) {
  .car-card:hover { transform: translateY(-2px); border-color: #6e8960; background: #202a2c; }
  .primary:hover { filter: brightness(1.08); }
  .secondary:hover, .icon-button:hover { border-color: #667564; }
  .link:hover { color: #d0edb7; }
}
@media (max-width: 480px) {
  .shell { padding: var(--tg-content-safe-area-inset-top, 0px) 18px 110px; }
  header { padding-top: 20px; }
  main { padding-top: 24px; }
  h1 { font-size: 30px; }
  .brand-tag { display: none; }
  .hero { padding: 22px; }
  .hero-value { font-size: 33px; }
  .stat { padding: 16px; }
  .stat strong { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .car-card, .primary { transition: none; }
  .car-card:hover { transform: none; }
}
.author-line { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.record-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.roles-field { margin: 20px 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; }
.roles-field legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.role-choice { display: flex; gap: 12px; align-items: center; min-height: 36px; margin: 6px 0; cursor: pointer; }
.role-choice input { width: 20px; height: 20px; padding: 0; accent-color: var(--green); flex-shrink: 0; }
.add-buyer { margin-top: 10px; width: 100%; }
.pill { white-space: normal; overflow-wrap: anywhere; }
.undo { font-size: 11px; padding: 8px 12px; color: var(--muted); }
.sub-record { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 16px; }
@media(max-width:480px) { .ledger { font-size: 12px; } .ledger span { min-width: 0; } .ledger strong { flex-shrink: 0; } }
