:root{
  --bg0:#05070c;
  --glass: rgba(255,255,255,.08);
  --glass2: rgba(255,255,255,.10);
  --stroke: rgba(255,255,255,.12);
  --stroke2: rgba(255,255,255,.18);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --shadow: 0 18px 50px rgba(0,0,0,.55);
  --r: 18px;
  --r2: 22px;
  --pad: 16px;
  --bg-img: none;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(1200px 700px at 20% 0%, rgba(80,130,255,.18), transparent 60%),
              radial-gradient(900px 600px at 90% 20%, rgba(70,255,190,.12), transparent 55%),
              linear-gradient(180deg, #060915, #05070c 60%, #05070c);
  overflow-x:hidden;
  position:relative;
}

body.hasBgImg::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:-2;
  background-image: var(--bg-img);
  background-position:center;
  background-size:cover;
  background-repeat:no-repeat;
  filter: blur(20px);
  transform: scale(1.06);
}

body.role-partner-generic{
  background: radial-gradient(1200px 700px at 20% 0%, rgba(43,95,200,.22), transparent 60%),
              radial-gradient(900px 600px at 90% 20%, rgba(40,120,255,.10), transparent 55%),
              linear-gradient(180deg, #06101f, #071322 60%, #071322);
}

.glass{
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  border-radius: var(--r2);
}

.authPage{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.authShell{
  width:min(520px, 96vw);
}
.authCard{
  padding:26px;
}
.authTitle{font-size:28px; font-weight:850; letter-spacing:.2px}
.authSub{margin-top:6px; color:var(--muted)}
.field{margin-top:14px}
.pwdField{position:relative}
.iconBtn{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  color:var(--text);
  border-radius: 12px;
  padding:8px 10px;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.iconBtn:hover{transform: translateY(-1px); border-color:var(--stroke2)}
.pwdField .iconBtn{
  position:absolute;
  right:10px;
  top:50%;
  transform: translateY(-50%);
  padding:8px 10px;
}
.input, .textarea, .select{
  width:100%;
  padding:12px 14px;
  border-radius: 14px;
  border:1px solid var(--stroke);
  outline:none;
  background: rgba(0,0,0,.28);
  color:var(--text);
}
.select{appearance:none}
.input::placeholder, .textarea::placeholder{color:rgba(255,255,255,.45)}
.input:focus, .textarea:focus{border-color: rgba(120,180,255,.55)}
.msg{margin-top:10px; color:rgba(255,255,255,.75); min-height:18px}
.quote{margin-top:18px; color:rgba(255,255,255,.65); font-style:italic}

.btn{
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.20);
  color:var(--text);
  border-radius: 14px;
  padding:10px 14px;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
  white-space:nowrap;
}
.btn:hover{transform: translateY(-1px); border-color: var(--stroke2)}
.btn.primary{
  background: linear-gradient(180deg, rgba(90,150,255,.95), rgba(60,120,255,.85));
  border-color: rgba(110,170,255,.70);
  color:#06101a;
  font-weight:900;
}
.btn.danger{
  background: linear-gradient(180deg, rgba(255,90,90,.95), rgba(220,60,60,.85));
  border-color: rgba(255,120,120,.55);
  color:#1a0505;
  font-weight:900;
}
.btn.icon{padding:10px 12px}
.btn.pill{border-radius:999px}
.w100{width:100%}
.hidden{display:none !important}

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  margin:12px 12px 0;
}
.brandTitle{font-weight:900; letter-spacing:.3px}
.brandSub{margin-top:4px; color:var(--muted); font-size:13px}
.topActions{display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end}

.seg{
  display:flex;
  border:1px solid var(--stroke);
  border-radius: 14px;
  overflow:hidden;
  background: rgba(0,0,0,.22);
}
.segBtn{
  border:0;
  background:transparent;
  color:var(--text);
  padding:10px 14px;
  cursor:pointer;
  font-weight:800;
}
.segBtn.active{
  background: rgba(90,150,255,.28);
}

.main{padding:14px 12px 26px}
.panel{margin:12px auto; padding:16px; max-width:1100px}
.panelTitle{font-size:18px; font-weight:900; margin-bottom:10px}
.formGrid{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:10px;
  align-items:center;
}
.dirRow{display:flex; gap:10px; grid-column:1/-1}
.dirRow .btn{padding:10px 14px; font-weight:900}
.dirRow .btn.active{background: rgba(120,180,255,.22); border-color: rgba(120,180,255,.42)}
@media (max-width: 900px){
  .formGrid{grid-template-columns:1fr}
}

.boardWrap{margin-top:14px}
.board{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:12px;
  padding:0 12px;
}
@media (max-width: 1100px){
  .board{grid-template-columns:1fr 1fr}
}
@media (max-width: 640px){
  .board{grid-template-columns:1fr}
}
.col{
  min-height: 240px;
  padding:12px;
  border-radius: var(--r2);
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
}
.colHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-weight:900;
  margin-bottom:10px;
}
.count{
  padding:4px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  font-size:13px;
}
.colBody{display:flex; flex-direction:column; gap:10px; min-height:120px}

.ticket{
  border-radius: 18px;
  border:1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
  padding:12px;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.ticket:hover{transform: translateY(-2px); border-color: rgba(160,210,255,.35)}
.ticket .tId{font-weight:950; letter-spacing:.2px}
.tRow{margin-top:6px}
.muted{color:var(--muted)}
.chips{display:flex; flex-wrap:wrap; gap:8px}
.chip{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
  font-size:12px;
  color:rgba(255,255,255,.8);
}

.modal{
  position:fixed;
  inset:0;
  z-index:200;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
.modalCard{
  width: min(980px, 96vw);
  max-height: 90vh;
  overflow:auto;
  padding:16px;
}
.modalWide{width:min(1100px, 96vw)}
.modalTall{max-height: 92vh}
.modalHead{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.modalTitle{font-size:20px; font-weight:950}
.modalSub{color:var(--muted); margin-top:4px}
.modalText{color:var(--muted); padding:10px 0}
.lbl{color:rgba(255,255,255,.70); font-size:12px; margin:8px 0 6px}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:10px}
.grid3{display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px}
.grid4{display:grid; grid-template-columns:1.2fr 1fr .8fr 1fr; gap:10px}
@media (max-width: 900px){
  .grid2,.grid3,.grid4{grid-template-columns:1fr}
}
.row{display:flex; align-items:center}
.rowEnd{display:flex; justify-content:flex-end; gap:10px; margin-top:12px}
.rowBetween{display:flex; justify-content:space-between; gap:10px; margin-top:12px; flex-wrap:wrap}
.gap8{gap:8px}

.ticketGrid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  margin-top:12px;
}
@media (max-width: 900px){.ticketGrid{grid-template-columns:1fr}}
.kv, .kvFull{
  border:1px solid var(--stroke);
  border-radius: 16px;
  background: rgba(0,0,0,.18);
  padding:10px 12px;
}
.kvFull{margin-top:10px}
.k{color:rgba(255,255,255,.60); font-size:12px}
.v{font-weight:850; margin-top:6px; overflow-wrap:anywhere}
.imgWrap{
  margin-top:12px;
  border:1px solid var(--stroke);
  border-radius: 18px;
  overflow:hidden;
  background: rgba(0,0,0,.18);
}
.imgWrap img{width:100%; display:none; max-height:420px; object-fit:contain; background:rgba(0,0,0,.25)}
.twoCols{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:12px}
@media (max-width: 900px){.twoCols{grid-template-columns:1fr}}
.textarea{min-height:90px; resize:vertical}

.list{margin-top:12px; display:flex; flex-direction:column; gap:10px}
.listItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px;
  border-radius: 18px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
}
.listMain{min-width:0}
.listTitle{display:flex; align-items:center; gap:10px; font-weight:950}
.listSub{margin-top:6px; color:var(--muted); overflow-wrap:anywhere}
.listSub a{color:rgba(140,200,255,.95); text-decoration:none}
.listSub a:hover{text-decoration:underline}
.dot{width:10px; height:10px; border-radius:999px; display:inline-block}
.hint{margin-top:10px; color:rgba(255,255,255,.60); font-size:12px}

.statsGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
  margin-top:12px;
}
@media (max-width: 900px){.statsGrid{grid-template-columns:1fr 1fr}}
.statBox{
  padding:12px;
  border-radius: 18px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.18);
}
.statNum{font-size:24px; font-weight:950}
.statLbl{color:var(--muted); margin-top:6px}

.donutRow{display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-top:12px}
@media (max-width: 980px){.donutRow{grid-template-columns:1fr}}
.donutCard{
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  padding:12px;
}
.donutTop{display:flex; align-items:baseline; justify-content:space-between}
.donutTitle{font-weight:950}
.donutSub{color:var(--muted); font-size:12px}

.donutWrap{display:grid; grid-template-columns: 220px 1fr; gap:14px; align-items:center; margin-top:10px}
@media (max-width: 680px){.donutWrap{grid-template-columns:1fr}}
.donut{
  width:220px;
  aspect-ratio: 1 / 1;
  border-radius:999px;
  position:relative;
}
.donutCenter{
  position:absolute;
  inset:18px;
  border-radius:999px;
  background: rgba(0,0,0,.55);
  border:1px solid var(--stroke);
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
}
.donutCenter .big{font-size:24px; font-weight:950}
.legend{display:flex; flex-direction:column; gap:10px}
.legItem{display:flex; align-items:center; justify-content:space-between; gap:10px}
.legLeft{display:flex; align-items:center; gap:10px}
.legName{color:rgba(255,255,255,.82); font-weight:800}
.legVal{color:var(--muted); font-weight:800}

.chartCard{
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  padding:12px;
  margin-top:12px;
}
.chartTitle{font-weight:950}
.bars{display:flex; align-items:flex-end; gap:6px; height:168px; max-height:168px; overflow:hidden; margin-top:10px}
.barCol{flex:1; min-width:0; display:flex; flex-direction:column; align-items:stretch; gap:4px; justify-content:flex-end}
.bar{
  border-radius: 10px;
  background: rgba(90,150,255,.35);
  border:1px solid rgba(120,180,255,.25);
}
.bar.solved{background: rgba(60,220,150,.35); border-color: rgba(80,255,190,.20)}
.barLbl{font-size:11px; color:rgba(255,255,255,.55); text-align:center; margin-top:4px}

.chatLayout{display:grid; grid-template-columns: 260px 1fr; gap:12px; margin-top:12px; min-height:64vh}
@media (max-width: 900px){.chatLayout{grid-template-columns:1fr; min-height:auto}}
.chatList{
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  padding:10px;
  overflow:auto;
  max-height:70vh;
}
.chatItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:10px;
  border-radius: 14px;
  cursor:pointer;
  border:1px solid transparent;
}
.chatItem:hover{border-color: rgba(160,210,255,.22); background: rgba(255,255,255,.04)}
.chatItem.active{border-color: rgba(120,180,255,.45); background: rgba(90,150,255,.18)}
.chatItem .code{font-weight:950}
.chatItem .badge{
  font-size:11px;
  color:rgba(255,255,255,.75);
  border:1px solid var(--stroke);
  padding:2px 8px;
  border-radius:999px;
}

.chatMain{
  border:1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:70vh;
}
.chatHeader{padding:12px; font-weight:950; border-bottom:1px solid var(--stroke)}
.chatBody{
  padding:12px;
  overflow:auto;
  flex:1;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bubble{
  max-width: 78%;
  padding:10px 12px;
  border-radius: 16px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.06);
}
.bubble.me{align-self:flex-end; background: rgba(90,150,255,.18); border-color: rgba(120,180,255,.28)}
.bubble .meta{font-size:11px; color:rgba(255,255,255,.55); margin-top:6px}
.bubble img{max-width:100%; border-radius: 14px; margin-top:8px; border:1px solid var(--stroke)}
.chatSend{display:flex; gap:10px; padding:12px; border-top:1px solid var(--stroke)}
.fileInput{color:rgba(255,255,255,.75); max-width:190px}
/* ===== Partner board: colored headers ===== */
.col.col-new .colTitle{
  background: rgba(74,163,255,.18);
  border: 1px solid rgba(74,163,255,.30);
}
.col.col-inwork .colTitle{
  background: rgba(255,193,74,.18);
  border: 1px solid rgba(255,193,74,.30);
}
.col.col-notsolved .colTitle{
  background: rgba(255,74,74,.16);
  border: 1px solid rgba(255,74,74,.28);
}
.col.col-solved .colTitle{
  background: rgba(57,201,116,.16);
  border: 1px solid rgba(57,201,116,.28);
}

/* чуть “живее” для партнёров */
body.role-partner .card,
body.role-partner .col,
body.role-partner .ticket{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  border-color: rgba(255,255,255,.10);
}
/* ===== Wallpaper blur 15% ===== */
body.hasBgImg::before{
  content:"";
  position: fixed;
  inset: 0;
  background-image: var(--bg-img);
  background-size: cover;
  background-position: center;
  filter: blur(2px);
  transform: scale(1.05);
  opacity: .35;
  z-index: -2;
}

body.hasBgImg::after{
  content:"";
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 18, 0.658); /* затемнение для читаемости */
  z-index: -1;
}
/* colored board headers */
.board .col:nth-child(1) .colHead{color:#9fcbff;}
.board .col:nth-child(1){border-color: rgba(74,163,255,.22); background: rgba(40,90,180,.10);}
.board .col:nth-child(2) .colHead{color:#ffd595;}
.board .col:nth-child(2){border-color: rgba(255,193,74,.22); background: rgba(170,110,25,.10);}
.board .col:nth-child(3) .colHead{color:#ffb0b0;}
.board .col:nth-child(3){border-color: rgba(255,74,74,.22); background: rgba(140,40,40,.10);}
.board .col:nth-child(4) .colHead{color:#aef0c5;}
.board .col:nth-child(4){border-color: rgba(57,201,116,.22); background: rgba(30,110,55,.10);}

.tTop{display:flex; align-items:center; justify-content:space-between; gap:10px;}
.copyBtn{width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--stroke); background: rgba(0,0,0,.18); color:var(--text); border-radius:10px; cursor:pointer; flex:0 0 auto;}
.copyBtn:hover{border-color:var(--stroke2); transform: translateY(-1px);}
/* ===== CHATS FIX: fixed header + fixed list + only body scrolls ===== */

#chatsModal .modalCard{
  height: min(88vh, 920px);
  max-height: min(88vh, 920px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

#chatsModal .modalHead{
  position: sticky;
  top: 0;
  z-index: 5;
  background: inherit;
  backdrop-filter: blur(10px);
  padding-bottom: 12px;
}

#chatsModal .chatLayout{
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  min-height: 0;
  height: 100%;
}

#chatsModal .chatList{
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 0;
  align-self: start;
}

#chatsModal .chatMain{
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
}

#chatsModal .chatHeader{
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(10,14,24,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

#chatsModal .chatBody{
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

#chatsModal .chatSend{
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: rgba(10,14,24,.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.08);
}

#chatsModal #chatMsg{
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: rgba(10,14,24,.92);
}

/* мобильная адаптация */
@media (max-width: 900px){
  #chatsModal .modalCard{
    height: min(92vh, 980px);
  }

  #chatsModal .chatLayout{
    grid-template-columns: 1fr;
    grid-template-rows: 180px 1fr;
  }

  #chatsModal .chatList{
    height: 180px;
  }
}
.ticketStatusLine{margin-top:10px}
.chipStatus{
  background: rgba(90,150,255,.16);
  border-color: rgba(120,180,255,.32);
  color: rgba(220,235,255,.92);
}
.quickActions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
}
.miniActionBtn{
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  color: var(--text);
  border-radius: 12px;
  padding:7px 10px;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.miniActionBtn:hover{transform: translateY(-1px); border-color: rgba(160,210,255,.35)}
.miniActionBtn.active{
  background: rgba(90,150,255,.18);
  border-color: rgba(120,180,255,.40);
  box-shadow: inset 0 0 0 1px rgba(120,180,255,.18);
}
.kindBtn{position:relative; overflow:hidden}
.kindBtn.active{
  background: rgba(90,150,255,.18);
  border-color: rgba(120,180,255,.40);
  box-shadow: inset 0 0 0 1px rgba(120,180,255,.20);
}
.kindBtn.pressed{animation: kindPress .24s ease}
@keyframes kindPress{
  0%{transform: scale(1)}
  50%{transform: scale(.96)}
  100%{transform: scale(1)}
}
.kindReasonCard{width:min(620px, 96vw)}
.statsGrid3{grid-template-columns: repeat(3, 1fr); margin-top:12px}
@media (max-width: 900px){.statsGrid3{grid-template-columns:1fr}}
.returnCard{align-items:center}
.returnActions{
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 260px;
}
.returnInput{max-width:140px}
@media (max-width: 760px){
  .returnCard{align-items:flex-start; flex-direction:column}
  .returnActions{width:100%; min-width:0}
  .returnInput{max-width:none}
}

.ticketReturnBox{
  margin-top: 12px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
}
.ticketReturnLabel{
  font-size: 12px;
  font-weight: 800;
  color: rgba(255,255,255,.72);
  margin-bottom: 8px;
}
.ticketReturnRow{
  display:flex;
  gap:8px;
  align-items:center;
}
.ticketReturnInput{
  min-width: 0;
  flex:1 1 auto;
}
.ticketReturnBtn{
  white-space: nowrap;
}
@media (max-width: 760px){
  .ticketReturnRow{flex-direction:column; align-items:stretch}
}


.returnModalRow{display:flex; gap:10px; align-items:center; margin:10px 0 8px; flex-wrap:wrap}
.returnModalInput{max-width:220px}
.modalHint{font-size:12px; color:rgba(255,255,255,.58); margin-top:6px}
@media (max-width:720px){.returnModalInput{max-width:none; width:100%}.returnModalRow .btn{width:100%}}
