:root{
  --background:#fff;--foreground:#191A1D;--card:#fff;--primary:#191A1D;--primary-foreground:#fff;
  --muted:#F5F5F5;--muted-foreground:#616161;--accent:#E9E8DE;--border:#E9E8DE;--input:#E9E8DE;
  --success:#C0D99D;--warning:#F4D7A5;--info:#BCD3FF;--neutral:#D9DBE6;--destructive:#D92D20;--destructive-bg:#FDECEC;
  --clickup:#6D28D9;--clickup-bg:#D1CAEC;--r-md:8px;--r-lg:10px;--r-xl:14px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:"Geist",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;font-size:14px;line-height:1.45;color:var(--foreground);background:var(--background);-webkit-font-smoothing:antialiased}
button,input,select,textarea{font:inherit;color:inherit}
a{color:inherit}
#app{display:flex;min-height:100vh}
/* sidebar */
.sidebar{width:256px;flex:none;border-right:1px solid var(--border);padding:16px 12px;display:flex;flex-direction:column;gap:4px;position:sticky;top:0;height:100vh;background:var(--background)}
.logo{display:flex;align-items:flex-end;gap:8px;padding:4px 8px 20px}
.logo svg{height:18px;width:auto;display:block}
.logo span{font-weight:600;font-size:16px;color:var(--muted-foreground);line-height:1}
.nav{display:flex;align-items:center;gap:8px;padding:8px;border-radius:var(--r-md);text-decoration:none;font-weight:500;cursor:pointer}
.nav:hover{background:var(--muted)}
.nav.active{background:var(--accent)}
.nav svg{width:16px;height:16px;flex:none}
.spacer{flex:1}
.side-actions{display:flex;flex-direction:column;gap:8px;padding-bottom:16px;border-bottom:1px solid var(--border)}
.side-bottom{display:flex;flex-direction:column;gap:4px;padding:12px 0;border-bottom:1px solid var(--border)}
.user{display:flex;align-items:center;gap:10px;padding:12px 8px 0}
.avatar{width:32px;height:32px;border-radius:50%;background:var(--muted);display:grid;place-items:center;font-size:12px;color:var(--muted-foreground);flex:none}
.user small{display:block;color:var(--muted-foreground);font-size:12px}
/* main */
.main{flex:1;min-width:0;padding:32px 32px 60px;display:flex;flex-direction:column;gap:24px;max-width:1280px}
.head{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.head h1{margin:0 0 6px;font-size:24px;font-weight:600;letter-spacing:-.01em;line-height:1.1}
.head p,.sub{margin:0;color:var(--muted-foreground)}
.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.crumb{color:var(--muted-foreground);margin-bottom:8px;display:block;text-decoration:none}
.crumb:hover{color:var(--foreground)}
.title-row{display:flex;align-items:center;gap:12px;margin-bottom:8px}
.title-row h1{margin:0}
/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:36px;padding:0 14px;border-radius:var(--r-md);border:1px solid transparent;background:var(--primary);color:var(--primary-foreground);font-weight:500;cursor:pointer;white-space:nowrap}
.btn svg{width:16px;height:16px;flex:none}
.btn:hover{opacity:.9}
.btn.outline{background:var(--background);color:var(--foreground);border-color:var(--border)}
.btn.outline:hover{background:var(--muted);opacity:1}
.btn.ghost{background:transparent;color:var(--foreground)}
.btn.ghost:hover{background:var(--muted);opacity:1}
.btn.sm{height:30px;padding:0 10px;font-size:13px}
.btn.danger{background:var(--background);color:var(--destructive);border-color:var(--border)}
.btn.full{width:100%}
.icon-btn{border:0;background:transparent;cursor:pointer;color:var(--muted-foreground);padding:4px 6px;border-radius:6px}
.icon-btn:hover{background:var(--muted);color:var(--foreground)}
/* stats */
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
.stat{border:1px solid var(--border);border-radius:var(--r-xl);padding:20px;display:flex;flex-direction:column;gap:8px;background:var(--card);min-width:0}
.stat .l{color:var(--muted-foreground)}
.stat .v{font-size:24px;font-weight:600;letter-spacing:-.01em;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stat .h{color:var(--muted-foreground);font-size:12px}
/* tabs */
.tabs{display:inline-flex;gap:2px;padding:3px;background:var(--muted);border-radius:var(--r-lg);align-self:flex-start}
.tab{padding:6px 12px;border-radius:var(--r-md);font-weight:500;color:var(--muted-foreground);cursor:pointer;border:1px solid transparent;background:transparent;text-decoration:none;white-space:nowrap}
.tab.active{background:var(--background);border-color:var(--border);color:var(--foreground)}
/* table */
.table-wrap{border:1px solid var(--border);border-radius:var(--r-lg);overflow:auto;background:var(--card)}
table{border-collapse:collapse;width:100%}
th{background:var(--muted);color:var(--muted-foreground);font-size:12px;font-weight:500;text-align:left;padding:0 12px;height:40px;border-bottom:1px solid var(--border);white-space:nowrap}
td{padding:0 12px;height:46px;border-bottom:1px solid var(--border);white-space:nowrap}
tr:last-child td{border-bottom:0}
.r{text-align:right}
.mut{color:var(--muted-foreground)}
.str{font-weight:500}
tr.total td{background:var(--muted);font-weight:500}
tr.sub td:first-child{padding-left:24px;color:var(--muted-foreground)}
tr.sub td{color:var(--muted-foreground)}
tr.click{cursor:pointer}
tr.click:hover td{background:#FAFAF7}
td.cell{cursor:pointer}
td.cell:hover{background:var(--accent);outline:1.5px solid var(--foreground);outline-offset:-1.5px}
td.addrow{color:var(--muted-foreground);cursor:pointer}
td.addrow:hover{color:var(--foreground);background:var(--muted)}
td.addrow.strong{color:var(--foreground);font-weight:500}
td input.inline{height:30px;width:76px;text-align:right;border:1px solid var(--input);border-radius:6px;padding:0 6px;background:var(--background)}
.badge{display:inline-flex;align-items:center;height:22px;padding:0 8px;border-radius:999px;font-size:12px;font-weight:500;background:var(--muted);white-space:nowrap}
.badge.success{background:var(--success)}.badge.warning{background:var(--warning)}.badge.info{background:var(--info)}.badge.neutral{background:var(--neutral)}
.badge.danger{background:var(--destructive-bg);color:var(--destructive)}
.badge.outline{background:var(--background);border:1px solid var(--border)}
/* blocks */
.block{display:flex;flex-direction:column;gap:12px}
.block-head{display:flex;justify-content:space-between;align-items:center;gap:12px}
.block-head h2{margin:0 0 4px;font-size:16px;font-weight:600}
.card{border:1px solid var(--border);border-radius:var(--r-lg);padding:20px;background:var(--card)}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px;align-items:start}
.empty{border:1px dashed var(--border);border-radius:var(--r-lg);padding:56px 32px;display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center}
.empty .ic{width:48px;height:48px;border-radius:50%;background:var(--muted);display:grid;place-items:center}
.empty .ic svg{width:20px;height:20px}
.empty h3{margin:0 0 6px;font-size:16px;font-weight:600}
.empty p{margin:0;color:var(--muted-foreground);max-width:440px}
.note{background:var(--muted);border-radius:var(--r-md);padding:10px 12px;font-size:12px;color:var(--muted-foreground)}
.legend{font-size:12px;color:var(--muted-foreground)}
/* chart */
.chart{display:flex;align-items:flex-end;gap:0;height:280px}
.chart .m{flex:1;display:flex;flex-direction:column;align-items:center;height:100%;justify-content:flex-end}
.chart .bars{display:flex;align-items:flex-end;gap:4px;flex:1;width:100%;justify-content:center;border-bottom:1px solid var(--border)}

.chart .col{display:flex;flex-direction:column;justify-content:flex-end;align-items:center;height:100%}
.chart .col span{font-size:11px;line-height:20px;height:20px;white-space:nowrap}
.chart .m.now .lbl{color:var(--foreground);font-weight:600}
.totals{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}.totals small{display:block;color:var(--muted-foreground);font-size:12px;margin-bottom:4px}.totals b{font-size:20px;font-weight:600}
.stat.clickable{cursor:pointer}.stat.clickable:hover{border-color:var(--foreground)}.stat .more{font-size:12px;font-weight:500;margin-top:4px}
.pop .row{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;padding:10px 0;border-bottom:1px solid var(--border);cursor:pointer}.pop .row:last-of-type{border-bottom:0}.pop .row:hover b{text-decoration:underline}
.chart .bar{width:24px;border-radius:3px 3px 0 0;min-height:2px}
.chart .lbl{padding-top:8px;font-size:12px;color:var(--muted-foreground);text-align:center;line-height:1.3}
.chart .lbl b{display:block;font-weight:400;color:var(--foreground)}
.lg{display:flex;gap:16px;font-size:12px;color:var(--muted-foreground)}
.lg i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px}
.attn{display:flex;flex-direction:column}
.attn .it{padding:12px 0;border-bottom:1px solid var(--border);display:flex;flex-direction:column;gap:6px;align-items:flex-start;cursor:pointer}
.attn .it:first-child{padding-top:0}.attn .it:last-child{border-bottom:0;padding-bottom:0}
.attn small{color:var(--muted-foreground);font-size:12px}
/* modal */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:flex-start;justify-content:center;padding:48px 16px;overflow:auto;z-index:50}
.dialog{width:440px;max-width:100%;background:var(--card);border:1px solid var(--border);border-radius:var(--r-xl);padding:24px;display:flex;flex-direction:column;gap:20px;box-shadow:0 8px 24px rgba(0,0,0,.12)}
.dialog h2{margin:0 0 6px;font-size:18px;font-weight:600;line-height:1.1}
.dialog .desc{margin:0;color:var(--muted-foreground)}
.form{display:flex;flex-direction:column;gap:16px}
.field{display:flex;flex-direction:column;gap:8px}
.field label{font-weight:500;line-height:1}
.field small{color:var(--muted-foreground);font-size:12px}
.field input[type=text],.field input[type=number],.field input[type=date],.field input[type=month],.field select,.field textarea{height:36px;border:1px solid var(--input);border-radius:var(--r-md);padding:0 12px;background:var(--background);width:100%;outline:none}
.field input:focus,.field select:focus{border-color:var(--foreground)}
.field .auto{height:36px;border-radius:var(--r-md);padding:0 12px;background:var(--muted);display:flex;align-items:center;justify-content:space-between;font-weight:500}
.field .auto em{font-style:normal;font-weight:400;font-size:12px;color:var(--muted-foreground)}
.field.check{flex-direction:row;align-items:center}
.field.check input{width:16px;height:16px;accent-color:#191A1D}
.cu{color:var(--clickup)}
.src{border:1px solid var(--border);background:var(--background);border-radius:999px;height:22px;padding:0 8px;font-size:12px;font-weight:500;cursor:pointer;color:var(--muted-foreground);margin-right:6px}
.src.cu{background:rgba(209,202,236,.45);border-color:var(--clickup-bg);color:var(--clickup)}
.field.clickup select,.field.clickup input{border-color:var(--clickup);background:rgba(209,202,236,.35);color:var(--clickup)}
.footer{display:flex;justify-content:space-between;gap:8px;align-items:center}
.footer .right{display:flex;gap:8px;margin-left:auto}
.pop{position:absolute;width:340px;background:var(--card);border:1px solid var(--border);border-radius:var(--r-lg);padding:16px;display:flex;flex-direction:column;gap:14px;box-shadow:0 8px 24px rgba(0,0,0,.14);z-index:40}
.pop h4{margin:0 0 2px;font-size:14px;font-weight:500}
.pop .entry{display:flex;justify-content:space-between;gap:8px;align-items:center}
.pop hr{border:0;border-top:1px solid var(--border);margin:0;width:100%}
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--primary);color:#fff;padding:10px 16px;border-radius:999px;font-size:13px;z-index:60;opacity:0;transition:opacity .2s}
.toast.show{opacity:1}
.contractor{background:var(--background);min-height:100vh;width:100%}
.topbar{display:flex;justify-content:space-between;align-items:center;padding:16px 32px;border-bottom:1px solid var(--border)}
.cbody{max-width:1024px;margin:0 auto;padding:40px 32px;display:flex;flex-direction:column;gap:24px}
@media(max-width:1100px){.stats{grid-template-columns:repeat(2,1fr)}.grid2{grid-template-columns:1fr}}
.conn{display:flex;align-items:center;gap:8px;padding:10px 8px 0;font-size:12px;color:var(--muted-foreground);text-decoration:none}
.conn i{width:8px;height:8px;border-radius:50%;background:var(--neutral);flex:none}.conn i.ok{background:#6FA83A}.conn i.warn{background:#E0A93B}.conn i.bad{background:var(--destructive)}


/* ---- v2 ---- */
.dialog.wide{width:640px}
.stages{display:flex;flex-direction:column;gap:6px}
.st{display:grid;grid-template-columns:minmax(0,1fr) 68px 104px 138px 28px;gap:6px;align-items:center}
.st input{height:34px;border:1px solid var(--input);border-radius:var(--r-md);padding:0 8px;background:var(--background);width:100%;min-width:0;outline:none}
.st input:focus{border-color:var(--foreground)}
.st input:disabled{background:var(--muted);color:var(--muted-foreground)}
.st-h{font-size:12px;color:var(--muted-foreground)}
.st-foot{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding-top:4px}
.st-sum{font-size:12px;color:var(--muted-foreground)}
.rc{display:flex;flex-direction:column;gap:8px}
.rc .entry{display:flex;justify-content:space-between;gap:8px;align-items:center;border:1px solid var(--border);border-radius:var(--r-md);padding:8px 12px}
.deal{display:flex;flex-direction:column;gap:12px}
.deal h3{margin:0 0 4px;font-size:15px;font-weight:600}
.badge.asbtn{border:0;cursor:pointer;font:inherit;font-size:12px;font-weight:500}
td.pf{line-height:1.25;padding-top:6px;padding-bottom:6px;position:relative}
td.pf span{display:block;width:fit-content;margin-left:auto;padding:1px 6px;border-radius:4px}
td.pf .paid{background:rgba(192,217,157,.55);color:var(--foreground)}
td.pf .plan{color:var(--muted-foreground)}
td.pf .mut{padding:0}
td.pf .od{position:absolute;top:6px;left:6px;width:6px;height:6px;border-radius:50%;background:var(--destructive)}
tr.total td.pf .paid{background:rgba(192,217,157,.8)}
tr.sub2 td:first-child{padding-left:44px;color:var(--muted-foreground);font-size:13px}
tr.sub2 td{color:var(--muted-foreground)}
td.neg{color:var(--destructive)}
.icon-btn.tg{padding:2px 4px;margin-right:2px}
.block-head .lg{flex-wrap:wrap}
select{appearance:none;-webkit-appearance:none}
.field select,.field.clickup select,.pop select,select.btn,select.btn.outline{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23616161' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:16px;padding-right:36px;text-overflow:ellipsis}
.field select,.pop select{height:36px;padding-left:12px}
.pop select,.pop input[type=number],.pop input[type=date],.pop input[type=text]{height:36px;border:1px solid var(--input);border-radius:var(--r-md);padding-left:12px;background-color:var(--background);width:100%}
.pop input[type=number],.pop input[type=date],.pop input[type=text]{padding-right:12px}
@media(max-width:700px){.st{grid-template-columns:1fr 60px 90px}.st [data-k=date]{grid-column:1 / 3}}
td.pf .paid.negv,tr.total td.pf .paid.negv{background:rgba(217,45,32,.12);color:var(--destructive)}
.block-head>.actions{flex-wrap:nowrap;flex:none}
.block-head>div:first-child{min-width:0}
td .legend{line-height:1.3}

/* ---- v3 ---- */
.head h1{display:flex;align-items:center;gap:8px;margin:0}
.info[data-tip]{display:inline-grid;place-items:center;width:18px;height:18px;border-radius:50%;border:1px solid var(--border);font-size:11px;font-weight:600;font-style:normal;color:var(--muted-foreground);cursor:help;position:relative;flex:none;line-height:1;letter-spacing:0;vertical-align:middle;margin-left:6px;background:var(--background)}
.head h1 .info[data-tip]{margin-left:0}
.info[data-tip]:hover,.info[data-tip]:focus{border-color:var(--foreground);color:var(--foreground);outline:none}
.info[data-tip]:hover::after,.info[data-tip]:focus::after{content:attr(data-tip);position:absolute;top:calc(100% + 8px);left:-8px;width:320px;max-width:70vw;background:var(--primary);color:#fff;font-size:12px;font-weight:400;line-height:1.45;padding:10px 12px;border-radius:var(--r-md);z-index:30;white-space:normal;text-align:left;box-shadow:0 8px 24px rgba(0,0,0,.18)}
.block-head h2{display:flex;align-items:center;margin:0}
input[type=date],input[type=month]{cursor:pointer}
input[type=date]:disabled{cursor:default}
/* year tables: first and last column stay, months scroll */
.table-wrap.sticky table{min-width:max-content}
.table-wrap.sticky th,.table-wrap.sticky td{min-width:124px}
.table-wrap.sticky th:first-child,.table-wrap.sticky td:first-child:not([colspan]){position:sticky;left:0;z-index:3;min-width:260px;background:var(--card);box-shadow:1px 0 0 var(--border)}
.table-wrap.sticky th:last-child,.table-wrap.sticky td:last-child:not([colspan]){position:sticky;right:0;z-index:3;background:var(--card);box-shadow:-1px 0 0 var(--border)}
.table-wrap.sticky th:first-child,.table-wrap.sticky th:last-child,.table-wrap.sticky tr.total td:first-child,.table-wrap.sticky tr.total td:last-child{background:var(--muted)}
.table-wrap.sticky .stick{position:sticky;left:24px;width:fit-content}
.table-wrap.sticky td.addrow .stick{display:inline-block}
a.cu{font-size:12px;margin-left:6px}
a.btn{text-decoration:none}

/* ---- v4 ---- */
tr.sect td{background:#FAFAF7;height:52px}
.table-wrap.sticky tr.sect td:first-child,.table-wrap.sticky tr.sect td:last-child{background:#FAFAF7}
td input.inline::placeholder{color:var(--muted-foreground)}

/* ---- v5: sign-in, users, history ---- */
.login{margin:auto;width:380px;max-width:92vw;display:flex;flex-direction:column;gap:24px;padding:32px 0}
.login .card{display:flex;flex-direction:column;gap:16px}
.pass{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:20px;letter-spacing:.04em;background:var(--muted);border-radius:var(--r-md);padding:14px 16px;text-align:center;user-select:all;word-break:break-all}
.icon-btn svg{width:16px;height:16px;display:block}
.user{min-width:0}.user b,.user small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.btn:disabled{opacity:.5;cursor:default}
