:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --text: #141414;
  --text-2: #565656;
  --text-3: #8b8b8b;
  --border: #e4e4e1;
  --border-2: #c8c8c4;
  --c-sber: #1e9634;
  --c-alfa: #e02b1f;
  --track: #e9e9e6;
  --fill: #141414;
  --on-fill: #ffffff;
  --radius: 10px;
  --radius-lg: 14px;
  --dur: 0.65s;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101010;
    --surface: #191919;
    --surface-2: #212121;
    --text: #f0f0ee;
    --text-2: #a6a6a2;
    --text-3: #757572;
    --border: #282828;
    --border-2: #3d3d3b;
    --c-sber: #2fc24e;
    --c-alfa: #ff5348;
    --track: #2a2a2a;
    --fill: #f0f0ee;
    --on-fill: #141414;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

header.wrap { padding-top: 28px; padding-bottom: 4px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.tagline { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sync { font-size: 12px; color: var(--text-3); white-space: nowrap; padding-top: 6px; }

.login-overlay[hidden] { display: none; }
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.5;
}
.chart-line {
  fill: none;
  stroke: var(--text-3);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: chart-draw 7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.chart-line-2 {
  stroke-opacity: 0.45;
  stroke-width: 1.5;
  animation-delay: 0.5s;
}
@media (prefers-color-scheme: light) {
  .login-bg { opacity: 0.68; }
}
@keyframes chart-draw {
  0% { stroke-dashoffset: 1; opacity: 0; }
  10% { opacity: 1; }
  55% { stroke-dashoffset: 0; }
  80% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-line { animation: none; stroke-dashoffset: 0; opacity: 0.6; }
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.login-card form { flex-direction: column; margin-top: 16px; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; }

main.wrap { padding-bottom: 48px; }

section { margin-top: 14px; }

.tile, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.grid { display: grid; gap: 12px; }
.grid-3 { grid-template-columns: 1fr 1fr; }
.tile-wide { grid-column: 1 / -1; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }

.lab { font-size: 13px; color: var(--text-2); }
.num {
  font-size: 22px;
  font-weight: 600;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.hero-num { font-size: clamp(28px, 7vw, 36px); }
.sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }

.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  margin-top: 12px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--fill);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform var(--dur) var(--ease);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.seg button {
  background: none;
  border: none;
  padding: 0 13px;
  height: 36px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}
.seg button[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); }
.seg button[data-bank="sber"][aria-pressed="true"] { background: var(--c-sber); color: #fff; }
.seg button[data-bank="alfa"][aria-pressed="true"] { background: var(--c-alfa); color: #fff; }

.bdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.bdot-sber { background: var(--c-sber); }
.bdot-alfa { background: var(--c-alfa); }
.badge-sber { border-color: var(--c-sber); color: var(--c-sber); }
.badge-alfa { border-color: var(--c-alfa); color: var(--c-alfa); }

input[type="number"], input[type="text"], input[type="date"] {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.btn {
  border: none;
  border-radius: var(--radius);
  background: var(--fill);
  color: var(--on-fill);
  height: 40px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-ghost:hover { background: var(--surface-2); }

form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
form input[type="number"] { flex: 1; min-width: 130px; }
form input[type="text"] { flex: 1.2; min-width: 140px; }

.form-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.segs { display: flex; gap: 8px; flex-wrap: wrap; }

.hint { font-size: 13px; color: var(--text-3); margin-top: 10px; min-height: 1.2em; }
.err { color: var(--text); font-weight: 500; }

.plan-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.plan-row input { width: 120px; height: 34px; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; }
.list-title { font-size: 15px; font-weight: 600; }

ul.ops { list-style: none; margin: 8px 0 0; padding: 0; }
.op-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.op-date { font-size: 14px; color: var(--text-2); }
.badge {
  font-size: 12px;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--text-2);
  margin-left: 6px;
  white-space: nowrap;
}
.op-note { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.op-side { display: flex; align-items: center; gap: 8px; }
.op-amt { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.del {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
}
.del:hover { color: var(--text); background: var(--surface-2); }

.empty { color: var(--text-3); font-size: 14px; padding: 12px 0; }

footer.wrap {
  padding-bottom: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.foot-note { font-size: 12px; color: var(--text-3); }
.foot-actions { display: flex; gap: 8px; }

.pulse { animation: pulse 0.5s var(--ease); }
@keyframes pulse { 40% { transform: scale(1.02); } }

.op-enter { animation: op-in 0.4s ease-out; }
@keyframes op-in { from { opacity: 0; transform: translateY(-6px); } }

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