:root{
  --ink:#0F172A; --muted:#64748B; --line:#E2E8F0; --bg:#F1F5F9; --card:#FFFFFF;
  --accent:#4F46E5; --accent2:#4338CA; --pos:#16A34A; --neg:#DC2626; --soft:#F8FAFC;
}
*{box-sizing:border-box; font-family:-apple-system,Segoe UI,Tahoma,Arial,sans-serif;}
body{margin:0; background:var(--bg); color:var(--ink); overflow-x:hidden;}
.wrap{max-width:1100px; margin:0 auto; padding:18px;}
header{display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:18px; flex-wrap:wrap;}
.brand{display:flex; align-items:center; gap:10px;}
.brand img{width:36px; height:36px; border-radius:9px;}
.brand h1{font-size:20px; margin:0;}
.brand p{font-size:12px; color:var(--muted); margin:2px 0 0;}
.actions{display:flex; gap:8px; flex-wrap:wrap;}
button{cursor:pointer; font-family:inherit;}
.btn{border:1px solid var(--line); background:var(--card); color:var(--ink); border-radius:10px; padding:9px 14px; font-size:14px; display:flex; align-items:center; justify-content:center; gap:4px;}
.btn:hover{background:var(--soft);}
.btn.primary{background:var(--accent); color:#fff; border-color:transparent;}
.btn.primary:hover{background:var(--accent2);}
.btn:disabled{opacity:.6; cursor:default;}
.btn.small{padding:6px 10px; font-size:13px;}
a{color:var(--accent);}

.grid{display:grid; gap:14px;}
.heroes{grid-template-columns:repeat(3,1fr);}
.kpis{grid-template-columns:repeat(auto-fit,minmax(155px,1fr));}
.charts{grid-template-columns:1.4fr 1fr;}
@media(max-width:760px){ .heroes,.charts{grid-template-columns:1fr;} .wrap{padding:16px;} }

.card{background:var(--card); border:1px solid var(--line); border-radius:16px; padding:16px; min-width:0;}
.hero .label{font-size:12px; color:var(--muted);}
.hero .val{font-size:26px; font-weight:800; margin-top:6px; line-height:1.1;}
.hero.accent .val{color:var(--accent);}
.hero.pos .val{color:var(--pos);}
.hero.ink .val{color:var(--ink);}
.bar{height:6px; background:var(--bg); border-radius:6px; margin-top:10px; overflow:hidden;}
.bar>span{display:block; height:100%; background:var(--pos);}
.kpi .l{font-size:12px; color:var(--muted);}
.kpi .v{font-size:18px; font-weight:700; margin-top:4px;}
.sec-title{font-size:14px; font-weight:700; margin:22px 2px 10px; display:flex; justify-content:space-between; align-items:center; gap:8px;}
table{width:100%; border-collapse:collapse; font-size:13px;}
th,td{text-align:right; padding:9px 8px; border-bottom:1px solid var(--line);}
th{color:var(--muted); font-weight:600; font-size:12px;}
.pill{display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:700; white-space:nowrap;}
.p-inc{background:#ECFDF5; color:var(--pos);}
.p-exp{background:#FEF2F2; color:var(--neg);}
.p-cap{background:#EEF2FF; color:var(--accent);}
.p-drw{background:#F1F5F9; color:var(--muted);}
.del{border:0; background:transparent; color:var(--muted); font-size:16px; padding:2px 6px; border-radius:6px;}
.del:hover{background:#FEF2F2; color:var(--neg);}
.chart-box{position:relative; width:100%; height:260px;}
.chart-box canvas{width:100%!important; height:100%!important;}
.table-wrap{overflow-x:auto; -webkit-overflow-scrolling:touch;}
td.nowrap{white-space:nowrap;}

/* modal */
.overlay{position:fixed; inset:0; background:rgba(15,23,42,.45); display:none; align-items:center; justify-content:center; padding:16px; z-index:50;}
.overlay.on{display:flex;}
.modal{background:#fff; border-radius:18px; padding:18px; width:380px; max-width:100%; max-height:92vh; overflow:auto;}
.modal.wide{width:560px;}
.modal h2{margin:0 0 12px; font-size:17px;}
label{display:block; font-size:12px; color:var(--muted); margin:11px 0 4px;}
input,select,textarea{width:100%; padding:9px 10px; border:1px solid var(--line); border-radius:10px; font-size:16px; outline:none; text-align:right; background:#fff; color:var(--ink);}
input:focus,select:focus,textarea:focus{border-color:var(--accent);}
textarea{resize:vertical; min-height:44px;}
.row{display:flex; gap:10px;}
.row>div{flex:1; min-width:0;}
.seg{display:flex; gap:6px;}
.seg button{flex:1; padding:9px 0; border:1px solid var(--line); background:#fff; border-radius:10px; font-size:13px; color:var(--muted);}
.seg button.on{color:#fff; border-color:transparent;}
.modal-actions{display:flex; gap:8px; margin-top:16px;}
.hidden{display:none !important;}
.toast{position:fixed; bottom:18px; left:50%; transform:translateX(-50%); padding:11px 18px; border-radius:12px; font-size:14px; color:#fff; opacity:0; transition:opacity .2s; z-index:60; pointer-events:none;}
.toast.show{opacity:1;}
.toast.ok{background:var(--pos);}
.toast.err{background:var(--neg);}
#loading{text-align:center; color:var(--muted); padding:60px 0;}
.err-msg{color:var(--neg); font-size:13px; min-height:18px; margin-top:10px;}
.muted{color:var(--muted); font-size:12px;}

/* auth screens */
.auth{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px;}
.auth .modal{width:360px;}
.auth .logo{display:flex; align-items:center; gap:10px; margin-bottom:6px;}
.auth .logo img{width:40px; height:40px; border-radius:10px;}

/* partner editor */
.prow{display:flex; gap:6px; align-items:center; margin-top:6px;}
.prow input.pname{flex:3;}
.prow input.pshare{flex:1; min-width:70px;}

/* calculator */
.calc-out{margin-top:15px; background:var(--soft); padding:12px; border-radius:8px; border:1px solid var(--line); font-size:14px;}
.calc-out .line{display:flex; justify-content:space-between; margin-bottom:6px;}
.calc-out .line span:first-child{color:var(--muted);}
.calc-out .line b{font-weight:bold;}
.calc-out .total{margin-top:10px; padding-top:10px; border-top:1px solid var(--line); font-weight:bold;}
.calc-out .total span:first-child{color:var(--ink);}
.calc-out .final{margin-top:10px; padding-top:10px; border-top:2px solid var(--line); font-weight:bold; color:var(--neg); font-size:16px;}
.calc-out .final span:first-child{color:var(--neg);}
.note{background:#FFF3CD; border-right:4px solid #F59E0B; padding:10px; font-size:12px; margin-bottom:15px; border-radius:4px; color:#92400E; line-height:1.7;}
