:root {
  --bg: #080a09;
  --surface: #101411;
  --surface-2: #161b17;
  --surface-3: #1d231e;
  --line: #222a24;
  --line-strong: #2f3a32;
  --text: #eaf1ea;
  --muted: #8a978e;
  --faint: #5b665f;

  --acid-1: #c8ff2e;
  --acid-2: #1fff8f;
  --acid: linear-gradient(135deg, #c8ff2e 0%, #6dff5c 52%, #1fff8f 100%);
  --acid-soft: linear-gradient(135deg, rgba(200, 255, 46, 0.16), rgba(31, 255, 143, 0.1));
  --on-acid: #06110a;
  --loss: #ff7a6b;
  --loss-soft: rgba(255, 122, 107, 0.12);

  --q0: #9aa59d;
  --q1: #6fe08a;
  --q2: #62b4ff;
  --q3: #b58cff;
  --q4: #ff7a6b;
  --q5: #ffc04d;

  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 11px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tabbar-h: 68px;
  --art-opacity: 0.075; /* насколько заметен фоновый рисунок (0 — скрыть) */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 380px at 50% -140px, rgba(130, 255, 80, 0.075), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--acid-1); outline-offset: 2px; }
::selection { background: rgba(200, 255, 46, 0.3); }
/* фоновый рисунок: линии рельефа и знак радиации, еле заметные */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url('/bg.svg') center / cover no-repeat;
  opacity: var(--art-opacity);
}
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--acid); color: var(--on-acid);
  font-weight: 600; letter-spacing: 0.005em; white-space: nowrap;
  transition: filter 0.15s, box-shadow 0.2s, transform 0.1s;
}
.btn:hover { filter: brightness(1.08); box-shadow: 0 6px 26px -8px rgba(120, 255, 70, 0.55); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; filter: none; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 34px; padding: 0 14px; font-size: 13.5px; }

.btn.ghost {
  color: var(--text);
  border: 1px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--acid) border-box;
}
.btn.ghost:hover { box-shadow: 0 6px 26px -10px rgba(120, 255, 70, 0.45); filter: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.danger-confirm {
  width: auto; padding: 0 14px; border-radius: 999px;
  color: var(--loss); border-color: rgba(255, 122, 107, 0.5); background: var(--loss-soft);
  font-size: 13.5px; font-weight: 600;
}

/* ---------- поля ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 13px; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--acid-1); box-shadow: 0 0 0 3px rgba(200, 255, 46, 0.14); }
.hint { font-size: 13px; color: var(--muted); min-height: 20px; }
.hint.ok { color: var(--acid-1); }
.hint.err { color: var(--loss); }

/* ---------- сегменты и чипы ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.seg button {
  min-height: 34px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 500; font-size: 14px;
  transition: color 0.15s, background 0.2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--acid); color: var(--on-acid); font-weight: 600; }
.seg.expense button[aria-pressed='true'].is-expense { background: var(--loss); color: #1c0905; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 6px; background: var(--surface-3); color: var(--muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
}
.tag.region { color: var(--acid-1); background: rgba(200, 255, 46, 0.09); }
.q { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.q::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- каркас ---------- */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(8, 10, 9, 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 980px; margin: 0 auto; padding: 12px 20px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.logo { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; display: inline-flex; align-items: baseline; gap: 1px; }
.logo b { font-weight: 600; background: var(--acid); -webkit-background-clip: text; background-clip: text; color: transparent; }
.user { justify-self: end; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-nick { color: var(--muted); font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  position: relative; display: flex; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.tab-ind {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0; border-radius: 999px;
  background: var(--acid); box-shadow: 0 6px 24px -8px rgba(120, 255, 70, 0.6);
  transition: transform 0.4s var(--ease), width 0.4s var(--ease);
}
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 18px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 500;
  transition: color 0.2s;
}
.tab svg { width: 18px; height: 18px; flex: none; }
.tab:hover { color: var(--text); }
.tab[aria-current='page'] { color: var(--on-acid); font-weight: 600; }

main { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }
.page { display: grid; gap: 28px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 14px; }
.section { display: grid; gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--text); font-weight: 600; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acid-2); box-shadow: 0 0 0 0 rgba(31, 255, 143, 0.6); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(31, 255, 143, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 255, 143, 0); } }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 12.5px;
}
.status-pill.demo { color: #ffc04d; border-color: rgba(255, 192, 77, 0.35); background: rgba(255, 192, 77, 0.07); }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--acid-2); }
.status-pill.demo i { background: #ffc04d; }

/* ---------- вход ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 22px; }
.auth-logo { text-align: center; display: grid; gap: 8px; justify-items: center; }
.auth-logo .logo { font-size: 30px; }
.auth-form { display: grid; gap: 16px; padding: 24px; }
.auth-err { min-height: 20px; color: var(--loss); font-size: 14px; }

/* ---------- аукцион ---------- */
.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 16px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbox .input { padding-left: 46px; min-height: 52px; border-radius: 999px; font-size: 16px; }
.results { display: grid; margin-top: 10px; overflow: hidden; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; width: 100%; }
.result:last-child { border-bottom: 0; }
.result:hover, .result:focus-visible { background: var(--surface-2); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.thumb { flex: none; width: 44px; height: 44px; border-radius: 11px; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; color: var(--muted); font-weight: 700; font-size: 16px; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.thumb.lg { width: 60px; height: 60px; border-radius: 15px; font-size: 22px; }

.lots { display: grid; overflow: hidden; }
.feed { max-height: 560px; overflow-y: auto; align-content: start; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.lot {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; width: 100%; text-align: left;
}
.lot:last-child { border-bottom: 0; }
button.lot:hover { background: var(--surface-2); }
.lot-main { min-width: 0; display: grid; gap: 3px; }
.lot-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.lot-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lot-meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.lot-price { text-align: right; display: grid; gap: 3px; justify-items: end; }
.price { font-weight: 700; font-size: 16px; white-space: nowrap; }
.price small { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.unit { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--acid); color: var(--on-acid); }
.badge.neg { background: var(--loss-soft); color: var(--loss); }
.badge.neutral { background: var(--surface-3); color: var(--muted); }

@keyframes fresh { from { background: rgba(200, 255, 46, 0.16); } to { background: transparent; } }
.lot.fresh { animation: fresh 2.4s ease-out; }

.deals { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.deal {
  position: relative; display: grid; gap: 14px; padding: 16px; text-align: left; color: inherit; width: 100%;
  border: 1px solid transparent; border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, rgba(200, 255, 46, 0.5), rgba(31, 255, 143, 0.08) 55%, var(--line)) border-box;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.deal:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -18px rgba(120, 255, 70, 0.45); }
.deal-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.deal-top .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.deal-off { margin-left: auto; font-family: var(--font-display); font-weight: 600; font-size: 22px; background: var(--acid); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
.deal-bottom { display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.deal-price { font-size: 20px; font-weight: 700; }
.deal-note { color: var(--muted); font-size: 12.5px; }

.item-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.item-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 14px 16px; display: grid; gap: 4px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 20px; font-weight: 700; }
.chart { padding: 14px 16px 8px; display: grid; gap: 6px; }
.chart svg { width: 100%; height: 110px; display: block; overflow: visible; }
.chart-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; }

/* ---------- бухгалтер ---------- */
.balance-card { padding: 26px; display: grid; gap: 20px; position: relative; overflow: hidden; }
.balance-card::after { content: ''; position: absolute; right: -80px; top: -120px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(130, 255, 80, 0.1), transparent 70%); pointer-events: none; }
.balance-label { color: var(--muted); font-size: 14px; }
.balance { font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 7vw, 52px); letter-spacing: -0.03em; line-height: 1.1; background: var(--acid); -webkit-background-clip: text; background-clip: text; color: transparent; word-break: break-all; }
.balance.neg { background: none; color: var(--loss); -webkit-background-clip: initial; background-clip: initial; }
.balance small { font-size: 0.5em; margin-left: 6px; font-weight: 500; }
.balance-row { display: flex; gap: 28px; flex-wrap: wrap; align-items: center; position: relative; z-index: 1; }
.mini { display: grid; gap: 2px; }
.mini .k { font-size: 13px; color: var(--muted); }
.mini .v { font-weight: 600; font-size: 16px; }
.mini .v.pos { color: var(--acid-1); }
.mini .v.neg { color: var(--loss); }
.start-edit { display: flex; gap: 8px; align-items: center; }
.start-edit .input { min-height: 38px; width: 150px; }

.entry-form { padding: 20px; display: grid; gap: 16px; }
.entry-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
.entry-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.summary { padding: 22px; display: grid; gap: 18px; border: 1px solid transparent; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--acid) border-box; border-radius: var(--radius); }
.summary.minus { background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, var(--loss), #8a3a31) border-box; }
.summary-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.summary-verdict { font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 5vw, 36px); letter-spacing: -0.02em; background: var(--acid); -webkit-background-clip: text; background-clip: text; color: transparent; }
.summary.minus .summary-verdict { background: none; color: var(--loss); -webkit-background-clip: initial; background-clip: initial; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.summary-text { color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.summary-text b { color: var(--text); font-weight: 600; }

.day-label { color: var(--muted); font-size: 13px; padding: 14px 16px 6px; font-weight: 500; }
.entry { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 14px; padding: 11px 16px; border-top: 1px solid var(--line); }
.day-label + .entry { border-top: 0; }
.sign { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px; background: rgba(200, 255, 46, 0.1); color: var(--acid-1); }
.sign.out { background: var(--loss-soft); color: var(--loss); }
.entry-note { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-time { color: var(--muted); font-size: 13px; }
.entry-sum { font-weight: 700; white-space: nowrap; }
.entry-sum.pos { color: var(--acid-1); }
.entry-sum.neg { color: var(--loss); }

/* ---------- заметки ---------- */
.note-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: transparent; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; color: inherit; }
.note-row:last-child { border-bottom: 0; }
.note-row:hover { background: var(--surface-2); }
.note-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-meta { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.note-meta span { color: var(--faint); margin-right: 8px; }
.note-actions { display: flex; align-items: center; gap: 4px; }
.chev { color: var(--faint); width: 18px; height: 18px; }

.note-view { display: grid; gap: 16px; }
.note-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 6px 10px 6px 0; font-weight: 600; font-size: 16px; color: var(--acid-1); }
.back svg { width: 20px; height: 20px; }
.note-date { color: var(--muted); font-size: 13px; text-align: center; }
.note-area { width: 100%; min-height: 60vh; resize: none; padding: 4px 2px; background: transparent; border: 0; color: var(--text); font-size: 17px; line-height: 1.6; }
.note-area:focus { outline: none; }
.note-area::placeholder { color: var(--faint); }
.save-state { color: var(--faint); font-size: 12.5px; min-width: 90px; text-align: right; }

.toast-err { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--loss-soft); color: var(--loss); font-size: 14px; }

/* ---------- мобильная версия ---------- */
@media (max-width: 760px) {
  /* backdrop-filter у шапки делал её контейнером для fixed-панели вкладок */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .topbar-in { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .balance-card { padding: 20px; }
  .balance-row { gap: 16px 24px; }
  .balance-row > :first-child { flex-basis: 100%; }
  .entry-actions > div { width: 100%; }
  .entry-actions .btn { flex: 1; }
  .user-nick { display: none; }
  main { padding: 20px 16px calc(var(--tabbar-h) + 36px); }
  .page-title { font-size: 23px; }

  .tabs {
    position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    height: var(--tabbar-h); padding: 6px; background: rgba(16, 20, 17, 0.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-color: var(--line-strong);
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
  }
  .tab-ind { top: 6px; bottom: 6px; }
  .tab { flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 0 6px; font-size: 12.5px; min-height: 0; }
  .tab svg { width: 21px; height: 21px; }

  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat .v { font-size: 15px; }
  .entry-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .lot { grid-template-columns: auto 1fr; padding: 12px; }
  .lot-price { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; align-items: baseline; gap: 10px; }
  .entry { grid-template-columns: auto 1fr auto auto; row-gap: 0; }
  .entry .sign { grid-row: 1 / 3; }
  .entry-note { grid-column: 2; grid-row: 1; }
  .entry-time { grid-column: 2; grid-row: 2; }
  .entry-sum { grid-column: 3; grid-row: 1 / 3; }
  .entry .icon-btn { grid-column: 4; grid-row: 1 / 3; }
  .deals { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- фильтры качества и заточки на странице предмета ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip {
  min-height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 7px; transition: border-color 0.15s, color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip[aria-pressed='true'] { color: var(--text); border-color: var(--acid-1); background: var(--acid-soft); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.select {
  min-height: 34px; padding: 0 30px 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 13.5px; color-scheme: dark;
}
.select:focus { outline: none; border-color: var(--acid-1); }
.stat .s { color: var(--faint); font-size: 12px; }
.deal-basis { color: var(--faint); font-size: 12px; }
