:root{
  --canvas:#0b0b0d; --surface:#141417; --surface2:#1b1b20; --border:rgba(255,255,255,.08); --border2:rgba(255,255,255,.06);
  --text:#f5f5f7; --text2:#9a9aa3; --text3:#6d6d76;
  --violet:#7c6ff5; --violet-dark:#6c5ff0; --green:#34d399; --red:#f87171; --amber:#fbbf24;
}
*{box-sizing:border-box; margin:0; padding:0}
body{background:var(--canvas); color:var(--text); font:14px/1.5 'Inter',system-ui,sans-serif; -webkit-font-smoothing:antialiased; min-height:100vh}
.display{font-family:'Unbounded','Inter',system-ui,sans-serif}
a{color:#a79bff; text-decoration:none}
a:hover{text-decoration:underline}
[hidden]{display:none!important}
.container{max-width:1152px; margin:0 auto; padding:0 16px}
@media(min-width:768px){.container{padding:0 24px}}
.muted{color:var(--text2)}
.small{font-size:13px}
.center-note{padding:48px 0; text-align:center; color:var(--text2)}

header{position:sticky; top:0; z-index:30; border-bottom:1px solid var(--border2); background:rgba(11,11,13,.85); backdrop-filter:blur(10px)}
header .row{display:flex; align-items:center; justify-content:space-between; height:64px; gap:12px}
.brand{display:flex; align-items:center; gap:10px; color:var(--text)}
.brand:hover{text-decoration:none}
.brand img{width:32px; height:32px; border-radius:9px}
.brand span{font-size:17px; font-weight:700}
.user{display:flex; align-items:center; gap:12px; min-width:0; color:var(--text2)}
.user span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}

.btn{display:inline-flex; align-items:center; justify-content:center; gap:8px; border:1px solid transparent; border-radius:12px;
  padding:10px 18px; font:600 14px 'Inter',system-ui,sans-serif; cursor:pointer; transition:background .15s; color:var(--text); background:none}
.btn:hover{text-decoration:none}
.btn.primary{background:var(--violet); color:#fff}
.btn.primary:hover{background:var(--violet-dark)}
.btn.ghost{border-color:rgba(255,255,255,.14)}
.btn.ghost:hover{background:rgba(255,255,255,.05)}
.btn.sm{padding:7px 14px; font-size:13px; border-radius:999px}
.btn.lg{padding:15px 28px; font-size:16px}
.btn:disabled{opacity:.5; cursor:default}
.btn:focus-visible,.chip:focus-visible,input:focus-visible,select:focus-visible,.tabs a:focus-visible{outline:2px solid var(--violet); outline-offset:2px}

.card{border:1px solid var(--border); background:var(--surface); border-radius:20px; padding:20px}
@media(min-width:768px){.card{padding:24px}}
h2{font-size:16px; font-weight:600; margin-bottom:14px}

/* Вход */
.login{display:flex; justify-content:center; padding:48px 0}
.login-card{max-width:440px; width:100%; text-align:center; display:flex; flex-direction:column; gap:18px; padding:32px 24px}
.login-card h1{font-size:26px}
#login-wait{display:flex; flex-direction:column; gap:14px; align-items:center}
.check-code{font-size:40px; letter-spacing:.2em; padding:8px 20px; border-radius:16px; background:var(--surface2); border:1px solid var(--border)}
.status{color:var(--text2)}
.status.error{color:var(--red)}

/* Каркас кабинета */
.banner{margin-top:20px; padding:12px 16px; border-radius:14px; background:rgba(251,191,36,.1); border:1px solid rgba(251,191,36,.3); color:#fde68a}
.tabs{display:flex; gap:4px; margin-top:20px; overflow-x:auto; border-bottom:1px solid var(--border2); scrollbar-width:none}
.tabs a{padding:12px 14px; color:var(--text2); white-space:nowrap; border-bottom:2px solid transparent; font-weight:500}
.tabs a:hover{color:var(--text); text-decoration:none}
.tabs a.active{color:var(--text); border-bottom-color:var(--violet)}
.period{display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:20px 0}
.chip{border:1px solid var(--border); background:none; color:var(--text2); border-radius:999px; padding:6px 14px; font:500 13px 'Inter',system-ui,sans-serif; cursor:pointer}
.chip.active{background:rgba(124,111,245,.15); border-color:rgba(124,111,245,.5); color:var(--text)}
.custom{display:flex; flex-wrap:wrap; align-items:center; gap:8px; color:var(--text2)}
.tab{display:flex; flex-direction:column; gap:16px; padding-bottom:48px}

input,select{width:100%; background:var(--surface2); border:1px solid var(--border); color:var(--text); border-radius:10px; padding:9px 12px; font:14px 'Inter',system-ui,sans-serif; color-scheme:dark}
.custom input{width:auto}

.stats{display:grid; gap:12px; grid-template-columns:1fr}
@media(min-width:640px){.stats{grid-template-columns:repeat(3,1fr)}}
.stat{display:flex; flex-direction:column; gap:6px}
.stat span{color:var(--text2)}
.stat b{font-size:26px; font-weight:700; font-variant-numeric:tabular-nums}
.grid2{display:grid; gap:12px}
@media(min-width:768px){.grid2{grid-template-columns:1fr 1fr}}
.bars{list-style:none; display:flex; flex-direction:column; gap:10px}
.bars li{display:grid; grid-template-columns:1fr auto; gap:4px 12px}
.bars .bar{grid-column:1/-1; height:6px; border-radius:99px; background:var(--surface2); overflow:hidden}
.bars .bar i{display:block; height:100%; border-radius:99px; background:var(--violet)}
.bars .expense i{background:var(--red)}
.bars b{font-weight:600; font-variant-numeric:tabular-nums}
.tax dl{display:grid; grid-template-columns:1fr auto; gap:8px 16px}
.tax dt{color:var(--text2)}
.tax dd{text-align:right; font-variant-numeric:tabular-nums}
.tax dd.total{font-size:20px; font-weight:700}
.tax .disclaimer{margin-top:14px; font-size:12px; color:var(--text3)}

.toolbar{display:flex; flex-wrap:wrap; gap:8px; align-items:center}
.toolbar select{width:auto}
.spacer{flex:1}
.table-wrap{position:relative; overflow-x:auto; border:1px solid var(--border); border-radius:16px; background:var(--surface)}
.table{width:100%; border-collapse:collapse; min-width:560px}
.table th,.table td{padding:12px 14px; text-align:left; border-bottom:1px solid var(--border2); vertical-align:middle}
.table th{font-weight:500; color:var(--text2); font-size:13px}
.table tr:last-child td{border-bottom:none}
.table .num{text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums}
.table .income{color:var(--green)}
.table .expense{color:var(--red)}
.table .actions{white-space:nowrap; text-align:right}
.table .sub{margin-top:2px; font-size:12px; color:var(--text2)}
.table.ops{min-width:0}
@media(max-width:560px){.table th,.table td{padding:10px 8px} .table.ops td:first-child{white-space:nowrap; font-size:12px} .icon-btn{padding:4px}}
.sr{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0)}
.icon-btn{background:none; border:none; color:var(--text2); cursor:pointer; padding:4px 8px; border-radius:8px; font:14px 'Inter',system-ui,sans-serif}
.icon-btn:hover{color:var(--text); background:rgba(255,255,255,.06)}
.tag{display:inline-block; font-size:12px; padding:2px 8px; border-radius:99px; background:rgba(52,211,153,.12); color:var(--green)}
.links{display:flex; gap:10px}

.cards{display:grid; gap:12px}
@media(min-width:768px){.cards{grid-template-columns:1fr 1fr}}
.cards .card h3{font-size:15px; font-weight:600; margin-bottom:8px}
.cards dl{display:grid; grid-template-columns:auto 1fr; gap:4px 12px; font-size:13px}
.cards dt{color:var(--text3)}
.cards dd{word-break:break-word}

.form{display:flex; flex-direction:column; gap:14px; max-width:640px}
.form label{display:flex; flex-direction:column; gap:6px; color:var(--text2); font-size:13px}
.row2{display:grid; gap:14px}
@media(min-width:560px){.row2{grid-template-columns:1fr 1fr}}
.form-error{color:var(--red)}
.seg{display:grid; grid-template-columns:1fr 1fr; gap:6px; background:var(--surface2); padding:4px; border-radius:12px}
.seg label{display:block}
.seg input{position:absolute; opacity:0; width:1px}
.seg span{display:block; text-align:center; padding:8px; border-radius:9px; color:var(--text2); cursor:pointer; font-weight:600}
.seg input:checked+span{background:var(--surface); color:var(--text)}
.seg input:focus-visible+span{outline:2px solid var(--violet)}

dialog{margin:auto; width:min(480px,calc(100% - 32px)); background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:20px; padding:24px}
dialog::backdrop{background:rgba(0,0,0,.6)}
.dialog-actions{display:flex; justify-content:flex-end; gap:8px; margin-top:4px}

.toast{position:fixed; left:50%; bottom:24px; transform:translateX(-50%); background:var(--surface2); border:1px solid var(--border); padding:10px 18px; border-radius:12px; z-index:50; max-width:calc(100% - 32px)}
.toast.error{border-color:rgba(248,113,113,.5); color:#fecaca}

/* Документы: позиции и составные поля */
.with-btn{display:flex; gap:8px; align-items:center}
.with-btn select{flex:1; min-width:0}
.items{display:flex; flex-direction:column; gap:10px; border:1px solid var(--border); border-radius:14px; padding:14px}
.items-head{display:flex; justify-content:space-between; align-items:center; color:var(--text2); font-size:13px}
.items-head b{color:var(--text); font-variant-numeric:tabular-nums}
.item-row{display:grid; gap:8px; grid-template-columns:1fr; align-items:center}
@media(min-width:560px){.item-row{grid-template-columns:1fr 70px 70px 110px 32px}}
.item-row input{padding:8px 10px}
.item-row .del{justify-self:end}

/* Выписка */
.stmt-group{margin-top:18px}
.stmt-group h3{font-size:14px; font-weight:600; margin-bottom:4px}
.stmt-group p.hint{color:var(--text2); font-size:13px; margin-bottom:10px}
.stmt-op{display:grid; grid-template-columns:auto 1fr auto; gap:6px 12px; align-items:start;
  padding:10px 0; border-bottom:1px solid var(--border2)}
.stmt-op:last-child{border-bottom:none}
.stmt-op input[type=checkbox]{width:18px; height:18px; margin-top:2px; accent-color:var(--violet)}
.stmt-op .who{font-weight:500}
.stmt-op .meta{grid-column:2/-1; color:var(--text2); font-size:12px}
.stmt-op .sum{font-variant-numeric:tabular-nums; white-space:nowrap; font-weight:600}
.verify-ok{color:var(--green)}
.verify-bad{color:var(--amber)}

/* Автозаполнение по ИНН/БИК */
.lookup-note{font-size:13px; color:var(--text2); margin-top:-6px}
.lookup-note.warn{color:var(--amber)}
.lookup-note.error{color:var(--red)}
.with-btn .btn{white-space:nowrap}

/* Вход по почте */
.or{display:flex; align-items:center; gap:12px; color:var(--text2); font-size:13px}
.or::before,.or::after{content:""; flex:1; height:1px; background:var(--border)}
#email-form{display:flex; flex-direction:column; gap:14px; text-align:left}
#email-step-1,#email-step-2{display:flex; flex-direction:column; gap:12px}
.email-label{display:flex; flex-direction:column; gap:6px; color:var(--text2); font-size:13px}
.email-label input{width:100%}
.consent{display:flex; gap:8px; align-items:flex-start; font-size:12px; color:var(--text2); line-height:1.4}
.consent input{margin-top:2px; width:16px; height:16px; flex:none}
#email-form .btn{width:100%; justify-content:center}
/* Привязка Telegram — подсказка, а не предупреждение */
.banner.soft{display:flex; flex-wrap:wrap; gap:12px; align-items:center; justify-content:space-between;
  background:var(--surface2); border-color:var(--border); color:var(--text2)}
#link-dialog .form{text-align:center; gap:14px}
#link-dialog .check-code{align-self:center}
