:root{--o900:#26302A;--o700:#3F4A3B;--o500:#6B7F63;--o300:#8B9C82;--o100:#EFF1EA;--o50:#F5F6F1;--red:#B23A3A;--amber:#9C7A34;--green:#4F7A45;--mauve:#8C5A6B;--grey:#5B6B54;--ink:#1F2620;--paper:#FBFBF9;--line:#DDE2D8;--shadow:0 6px 24px rgba(38,48,42,.12)}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font:14px/1.45 "Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;color:var(--ink);background:var(--paper)}
a{color:var(--o700)}
.top{display:flex;align-items:center;gap:18px;padding:0 18px;height:52px;background:var(--o900);color:#fff;position:sticky;top:0;z-index:50}
.brand{color:#fff;font-weight:700;text-decoration:none;display:flex;align-items:center;gap:8px;letter-spacing:.3px}
.dot{width:10px;height:10px;border-radius:50%;background:var(--amber);display:inline-block}
.tabs{display:flex;gap:4px;flex:1;overflow-x:auto}
.tabs a{color:#dfe5da;text-decoration:none;padding:8px 12px;border-radius:8px;white-space:nowrap}
.tabs a.active,.tabs a:hover{background:var(--o700);color:#fff}
.me{display:flex;align-items:center;gap:10px;white-space:nowrap}
.me a{color:#fff;text-decoration:none}
.tag{background:var(--amber);color:#fff;font-size:10px;padding:1px 6px;border-radius:10px;vertical-align:middle}
button.link{background:none;border:0;color:#cfd6c9;cursor:pointer;font:inherit;padding:4px 6px}
.banner{background:#FBF0DE;color:#6b5320;padding:8px 18px;border-bottom:1px solid #eadcb8;font-size:13px}
.page{padding:18px;max-width:1900px;margin:0 auto}
.page-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:12px}
h1{font-size:22px;margin:0;color:var(--o700)}
h2{font-size:17px;color:var(--o700)}
h3{margin:0 0 10px;font-size:15px;color:var(--o700)}
.muted{color:#6f776d}
.small{font-size:12px;font-weight:400}
.head-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.btn{background:#fff;border:1px solid var(--line);color:var(--o700);padding:7px 12px;border-radius:8px;cursor:pointer;font:inherit;font-size:13px;text-decoration:none;display:inline-flex;align-items:center;gap:6px}
.btn:hover{border-color:var(--o500);background:var(--o50)}
.btn.primary{background:var(--o700);color:#fff;border-color:var(--o700)}
.btn.primary:hover{background:var(--o900)}
.btn.danger{color:var(--red);border-color:#e3c3c3}
.btn.small{padding:4px 8px;font-size:12px}
.btn.wide{width:100%;justify-content:center}
.btn:disabled{opacity:.5;cursor:default}
.chk{display:inline-flex;gap:6px;align-items:center;font-size:13px;white-space:nowrap;cursor:pointer}
.card{background:#fff;border:1px solid var(--line);border-radius:12px;padding:14px 16px;margin-bottom:14px}
.card.narrow{max-width:520px}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media(max-width:900px){.grid-2{grid-template-columns:1fr}}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:14px}
.kpi{background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px 14px}
.kpi .v{font-size:26px;font-weight:700;color:var(--o700);line-height:1.1}
.kpi .l{font-size:12px;color:#6f776d;margin-top:4px}
.kpi.warn .v{color:var(--red)}
.kpi.ok .v{color:var(--green)}
.kpi.amber .v{color:var(--amber)}
table.t{width:100%;border-collapse:collapse;font-size:13px}
.t th,.t td{padding:6px 8px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}
.t th{background:var(--o100);color:var(--o700);font-weight:600;font-size:12px;white-space:nowrap}
.t tr:hover td{background:var(--o50)}
.t td.n,.t th.n{text-align:center}
.t td.z{color:#c5cbc1;text-align:center}
.table-scroll{overflow-x:auto}
.chip{display:inline-block;padding:2px 8px;border-radius:12px;font-size:12px;white-space:nowrap;background:var(--o100);color:var(--grey)}
.chip.s-todo,.chip.s-progress,.chip.s-done,.chip.s-late,.chip.s-paused,.chip.p-hi,.chip.p-mid,.chip.p-lo{border-radius:3px;border-left:3px solid;border-right:3px solid;font-weight:600}
.chip.s-todo{background:#EFF1EA;color:#5B6B54;border-color:#5B6B54}.chip.s-progress{background:#FBF0DE;color:#9C7A34;border-color:#9C7A34}.chip.s-done{background:#E9F1E4;color:#4F7A45;border-color:#4F7A45}.chip.s-late{background:#F7E7E0;color:#B0684A;border-color:#B0684A}.chip.s-paused{background:#EFE6E9;color:#8C5A6B;border-color:#8C5A6B}
.chip.p-hi{background:#F7E7E0;color:#B0684A;border-color:#B0684A}.chip.p-mid{background:#FBF0DE;color:#9C7A34;border-color:#9C7A34}.chip.p-lo{background:#EFF1EA;color:#5B6B54;border-color:#5B6B54}
.feed{max-height:380px;overflow:auto;font-size:13px}
.feed .row{padding:6px 0;border-bottom:1px dashed var(--line)}
.feed .who{color:var(--o500);font-weight:600}
.feed .when{color:#8a918a;font-size:11px;margin-right:6px}
.feed a{text-decoration:none}
.overdue-flag{color:var(--red);font-weight:600}
.list{font-size:13px}
.list .row{padding:6px 0;border-bottom:1px dashed var(--line);display:flex;justify-content:space-between;gap:10px}
.list a{text-decoration:none}
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:8px}
.toolbar input[type=search],.toolbar select{padding:6px 8px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:13px;background:#fff;max-width:220px}
.legend{display:flex;gap:14px;font-size:12px;color:#6f776d;margin-bottom:8px;flex-wrap:wrap}
.legend .sw{display:inline-block;width:14px;height:10px;border-radius:2px;margin-right:5px;vertical-align:middle}
.bar-sw{background-color:#FCD5B5;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect x='0' y='0' width='1' height='1' fill='%23C00000'/><rect x='3' y='1' width='1' height='1' fill='%23C00000'/><rect x='2' y='2' width='1' height='1' fill='%23C00000'/><rect x='1' y='3' width='1' height='1' fill='%23C00000'/></svg>");background-size:4px 4px;image-rendering:pixelated;border:1px solid #FF0000;width:22px!important;height:12px!important}
.today-sw{background:#fff;border-left:2px solid var(--red);border-right:2px solid var(--red)}
/* ---- gantt ---- */
.gantt-wrap{overflow:auto;border:1px solid var(--line);border-radius:12px;background:#fff;max-height:calc(100vh - 235px)}
table.gantt{border-collapse:separate;border-spacing:0;font-size:12px}
.gantt th,.gantt td{border-right:1px solid #DEDACB;border-bottom:1px solid #DEDACB;padding:0 6px;height:26px;white-space:nowrap}
.gantt thead th{position:sticky;top:0;background:var(--o500);color:#fff;font-weight:600;z-index:3;text-align:center;font-size:11px}
.gantt thead tr:nth-child(2) th{top:26px}
.gantt th.grp{background:#B7A98E}
.gantt th.year.y-first{background:#8B9C82}
.gantt th.year.y-late{background:#5B6B54}
.gantt th.today-h{background:var(--red)!important}
.gantt .c-num{width:38px;min-width:38px;text-align:center;color:#8a918a}
.gantt .c-name{min-width:320px;max-width:440px;white-space:normal;text-align:left;line-height:1.25;padding:3px 6px}
.gantt .c-own{min-width:120px;text-align:left}
.gantt .sticky-1{position:sticky;left:0;z-index:2;background:#fff}
.gantt .sticky-2{position:sticky;left:38px;z-index:2;background:#fff;box-shadow:2px 0 0 #E3E7DF}
.gantt thead .sticky-1,.gantt thead .sticky-2{z-index:4;background:var(--o500)}
.gantt tr.lvl-project td{background:var(--o500);color:#fff;font-weight:700;height:30px}
.gantt tr.lvl-project td.sticky-1,.gantt tr.lvl-project td.sticky-2{background:var(--o500)}
.gantt tr.lvl-stage td{background:var(--o900);color:#fff;font-weight:700;height:26px}
.gantt tr.lvl-stage td.sticky-1,.gantt tr.lvl-stage td.sticky-2{background:var(--o900)}
.gantt tr.lvl-stage td.tl{background-color:#fff}
.gantt tr.lvl-stage td.c-date{color:#fff}
.gantt tr.lvl-stage .chip{background:rgba(255,255,255,.12);color:#fff;border-color:rgba(255,255,255,.5)}
.gantt td.c-note{min-width:280px;max-width:340px;white-space:normal;font-size:11px;line-height:1.2;padding:3px 6px;text-align:left;color:#3b453c}
.gantt td.c-note .clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;cursor:help}
.gantt tr.lvl-project td.c-note,.gantt tr.lvl-stage td.c-note{color:#e9ede6;font-weight:400}
.gantt tr.lvl-project td.tl{background-color:#fff}
.gantt tr.lvl-project td.c-date{color:#fff}
.gantt tr.lvl-task td{color:#4a544a;font-size:11px}
.gantt tr.zebra td{background:var(--o50)}
.gantt tr.zebra td.sticky-1,.gantt tr.zebra td.sticky-2{background:var(--o50)}
.gantt tr.zebra td.tl{background-color:#fff}
.gantt td.tl{width:22px;min-width:22px;padding:0}
.gantt td.tl.month{width:34px;min-width:34px}
.gantt td.tl.year{width:42px;min-width:42px}
.gantt td.tl.today{box-shadow:inset 1px 0 0 #B23A3A,inset -1px 0 0 #B23A3A}
.gantt td.tl.bar{background-color:#FCD5B5!important;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect x='0' y='0' width='1' height='1' fill='%23C00000'/><rect x='3' y='1' width='1' height='1' fill='%23C00000'/><rect x='2' y='2' width='1' height='1' fill='%23C00000'/><rect x='1' y='3' width='1' height='1' fill='%23C00000'/></svg>")!important;background-size:4px 4px!important;background-repeat:repeat!important;image-rendering:pixelated;box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 #fff}
.gantt td.tl.bar.bar-start{box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 #fff,inset 1px 0 0 #FF0000}
.gantt td.tl.bar.bar-end{box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 #fff,inset -2px 0 0 #FF0000}
.gantt td.tl.bar.bar-start.bar-end{box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 #fff,inset 1px 0 0 #FF0000,inset -2px 0 0 #FF0000}
.gantt td.tl.bar.today{box-shadow:inset 0 2px 0 #fff,inset 0 -2px 0 #fff,inset 1px 0 0 #B23A3A,inset -1px 0 0 #B23A3A}
.gantt .name-btn{background:none;border:0;font:inherit;color:inherit;cursor:pointer;text-align:left;padding:0;white-space:normal}
.gantt .name-btn:hover{text-decoration:underline}
.gantt .ind-1{padding-left:16px}
.gantt .ind-2{padding-left:34px}
.gantt .caret{display:inline-block;width:16px;cursor:pointer;opacity:.9;user-select:none}
.gantt .dir-tag{font-size:10px;background:rgba(255,255,255,.22);padding:1px 6px;border-radius:8px;margin-left:6px;font-weight:500}
.gantt .add{background:rgba(255,255,255,.2);border:0;color:#fff;border-radius:6px;padding:1px 6px;cursor:pointer;font-size:11px;margin-left:8px}
.gantt tr:not(.lvl-project) .add{background:var(--o100);color:var(--o700)}
.gantt td.c-date{text-align:center;color:#3b453c;min-width:78px}
.gantt td.c-date.late{color:var(--red);font-weight:700}
.gantt td.c-mid{text-align:center}
.gantt input[type=checkbox]{margin:0;cursor:pointer}
.gantt input[type=checkbox]:disabled{cursor:default;opacity:.5}
.gantt .ovd{color:var(--red);font-weight:700;margin-left:4px}
.loading{padding:30px;text-align:center;color:#8a918a}
.empty{padding:20px;text-align:center;color:#8a918a;font-size:13px}
/* ---- drawer ---- */
.drawer{position:fixed;top:0;right:0;height:100vh;width:500px;max-width:100vw;background:#fff;box-shadow:-8px 0 30px rgba(0,0,0,.15);z-index:80;overflow:auto;padding:18px 20px 30px}
.drawer-backdrop{position:fixed;inset:0;background:rgba(20,26,22,.25);z-index:70}
.drawer h2{margin:0 30px 4px 0;font-size:18px;color:var(--o700)}
.drawer .crumbs{font-size:12px;color:#6f776d;margin-bottom:12px}
.drawer .close{position:absolute;top:8px;right:12px;background:none;border:0;font-size:24px;cursor:pointer;color:#6f776d}
.form label{display:block;font-size:12px;color:#6f776d;margin:10px 0 4px}
.form input,.form select,.form textarea{width:100%;padding:7px 9px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:13px;background:#fff}
.form textarea{min-height:70px;resize:vertical}
.form input[type=checkbox]{width:auto;margin:0 6px 0 0;vertical-align:middle}
.form .chk{display:inline-flex;align-items:center}
.form .row2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.form .row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}
.form .actions{display:flex;gap:8px;margin-top:14px;flex-wrap:wrap;align-items:center}
.form .ro{padding:6px 0;border-bottom:1px dashed var(--line);font-size:13px}
.form .ro b{color:#6f776d;font-weight:500;font-size:12px;display:block}
.form .chks{display:flex;gap:16px;margin-top:10px}
.hist{margin-top:16px;font-size:12px}
.hist .row{padding:5px 0;border-bottom:1px dashed var(--line)}
/* ---- modal ---- */
.modal-bg{position:fixed;inset:0;background:rgba(20,26,22,.35);z-index:90;display:flex;align-items:center;justify-content:center;padding:16px}
.modal{background:#fff;border-radius:14px;padding:18px 20px;width:min(760px,100%);max-height:92vh;overflow:auto;box-shadow:var(--shadow);position:relative}
.modal h2{margin:0 30px 10px 0;color:var(--o700);font-size:18px}
.modal .close{position:absolute;top:8px;right:12px;background:none;border:0;font-size:24px;cursor:pointer;color:#6f776d}
.modal .preview{border:1px dashed var(--line);border-radius:10px;padding:10px;min-height:180px;margin-top:10px}
/* ---- visuals ---- */
.visuals{display:grid;grid-template-columns:repeat(auto-fill,minmax(330px,1fr));gap:14px}
.vcard{background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px 14px;min-height:220px;display:flex;flex-direction:column}
.vcard .vh{display:flex;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:6px}
.vcard .vh b{font-size:14px;color:var(--o700)}
.vcard .scope{font-size:11px;color:#6f776d}
.vcard .vbody{flex:1;min-height:160px}
.vcard .vm{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.vcard.hidden-v{opacity:.6;border-style:dashed}
svg.chart{width:100%;height:auto;display:block;font-family:inherit}
.kpi-big{font-size:46px;font-weight:700;color:var(--o700);text-align:center;padding:30px 0 6px}
.kpi-sub{text-align:center;color:#6f776d;font-size:12px}
/* ---- misc ---- */
#toast{position:fixed;bottom:18px;left:50%;transform:translateX(-50%);z-index:200;display:flex;flex-direction:column;gap:6px;pointer-events:none}
.toast{background:var(--o900);color:#fff;padding:9px 14px;border-radius:10px;font-size:13px;box-shadow:var(--shadow)}
.toast.err{background:var(--red)}
.alert{background:#F7E7E0;color:#8a3c2b;padding:8px 12px;border-radius:8px;margin:8px 0;font-size:13px}
.alert.ok{background:#E9F1E4;color:#3f6a37}
.hint{background:var(--o100);border-radius:10px;padding:10px 14px;font-size:13px;color:#3b453c;margin:0 0 12px}
.menu{position:relative}
.menu-body{display:none;position:absolute;right:0;top:100%;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow);min-width:210px;z-index:60;padding:6px 0}
.menu:hover .menu-body,.menu:focus-within .menu-body{display:block}
.menu-body a{display:block;padding:8px 14px;text-decoration:none;color:var(--ink);font-size:13px}
.menu-body a:hover{background:var(--o50)}
.section-title{margin:18px 0 10px}
code{background:var(--o100);padding:1px 5px;border-radius:4px;font-size:12px}
.inline-edit{width:100%;min-height:56px;border:1px solid transparent;border-radius:6px;padding:4px;font:inherit;font-size:12px;background:transparent;resize:vertical}
.inline-edit:focus{border-color:var(--o500);background:#fff;outline:none}
.inline-edit.dirty{border-color:var(--amber)}
.tpl-row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;padding:10px 0;border-bottom:1px dashed var(--line)}
.tpl-row .title{min-width:240px;font-weight:600;color:var(--o700)}
.tpl-row .ph{font-size:11px;color:#6f776d;width:100%}
.users-table select,.users-table input[type=text]{padding:4px 6px;border:1px solid var(--line);border-radius:6px;font:inherit;font-size:12px}
.matrix-table th.rot{writing-mode:vertical-rl;transform:rotate(180deg);white-space:nowrap;padding:8px 4px;font-size:11px;max-height:180px}
/* ---- login ---- */
.login-body{background:linear-gradient(160deg,var(--o900),var(--o500));min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px}
.login-card{background:#fff;border-radius:16px;padding:28px 30px;width:min(400px,100%);box-shadow:var(--shadow)}
.login-brand{font-weight:700;color:var(--o700);display:flex;align-items:center;gap:8px;margin-bottom:8px}
.login-card h1{font-size:20px;margin:0 0 4px}
@media(max-width:700px){.top{gap:8px;padding:0 10px}.page{padding:10px}.drawer{width:100vw}.gantt .c-name{min-width:210px;max-width:260px}.form .row2,.form .row3{grid-template-columns:1fr}.me form{display:none}}

/* ---- категоризация в карточке ---- */
.cat{margin-top:14px;padding:10px 12px;border:1px dashed var(--line);border-radius:10px;background:var(--o50)}
.cat b{color:var(--o700)}
/* ---- ERG: карточки проектов ---- */
.erg-head{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:8px}
.erg-title{font-weight:700;text-decoration:none;font-size:15px;color:var(--o700)}
.erg-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media(max-width:900px){.erg-grid{grid-template-columns:1fr}}
.erg-text{width:100%;min-height:150px;padding:8px 10px;border:1px solid var(--line);border-radius:8px;font:inherit;font-size:13px;line-height:1.45;resize:vertical}
.erg-text.dirty{border-color:var(--amber);box-shadow:0 0 0 2px #fbf0de}
.plist{max-height:440px;overflow:auto;border:1px solid var(--line);border-radius:10px;padding:8px 10px;background:#fff}
.pl-stage{background:var(--o100);padding:4px 8px;border-radius:6px;margin:8px 0 2px;font-size:13px}
.pl-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:4px 8px;border-bottom:1px dashed var(--line);font-size:13px}
.pl-row.done a{color:#6f776d}
.pl-note{width:100%;font-size:11px;color:#6f776d;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-left:22px}
.bulk{display:flex;gap:6px;margin-bottom:6px;flex-wrap:wrap}
.chk.small{font-size:12px}
/* ---- порядок проектов ---- */
.order-row{display:flex;align-items:center;gap:8px;padding:5px 8px;border-bottom:1px dashed var(--line);font-size:13px}
.order-row .nm{flex:1}
.order-dir{font-weight:700;color:var(--o700);margin-top:10px;padding:4px 8px;background:var(--o100);border-radius:6px}
#order-list{max-height:55vh;overflow:auto;margin:8px 0}
