:root{
  --teal:#1a8f96;
  --teal-dark:#0f6b71;
  --ink:#20303a;
  --paper:#ffffff;
  --bg:#eef3f4;
  --line:#d7e0e2;
  --muted:#6b7c82;
  --accent:#e2f4f4;
}

*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0;
  font-family:'Segoe UI', Arial, sans-serif;
  background:var(--bg);
  color:var(--ink);
}

/* ---- Шапка портала ---- */
.portal-header{
  background:var(--teal-dark);
  color:#fff;
  padding:0 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  height:56px;
  position:sticky;
  top:0;
  z-index:100;
  box-shadow:0 1px 6px rgba(0,0,0,.15);
}
.portal-header .brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
  font-size:15px;
  text-decoration:none;
  color:#fff;
  letter-spacing:.01em;
}
.portal-header .brand .dot{
  width:8px;height:8px;border-radius:50%;
  background:#7ee0c9;
  flex:0 0 auto;
}
.portal-header nav{
  display:flex;
  gap:4px;
  align-items:center;
}
.portal-header nav a{
  color:#cfe9ea;
  text-decoration:none;
  font-size:13.5px;
  padding:8px 12px;
  border-radius:6px;
  white-space:nowrap;
}
.portal-header nav a:hover{background:rgba(255,255,255,.08); color:#fff;}
.portal-header nav a.active{background:rgba(255,255,255,.14); color:#fff; font-weight:600;}
.portal-header .logout{
  color:#cfe9ea;
  background:transparent;
  border:1px solid rgba(255,255,255,.25);
  border-radius:6px;
  padding:7px 12px;
  font-size:13px;
  cursor:pointer;
  margin-left:8px;
}
.portal-header .logout:hover{background:rgba(255,255,255,.08); color:#fff;}

/* Кнопка-гамбургер для мобильных */
.portal-header .burger{
  display:none;
  background:none;
  border:none;
  color:#fff;
  font-size:22px;
  cursor:pointer;
  padding:4px 8px;
}
@media (max-width:760px){
  .portal-header nav{
    display:none;
    position:absolute;
    top:56px; left:0; right:0;
    background:var(--teal-dark);
    flex-direction:column;
    align-items:stretch;
    padding:8px;
    box-shadow:0 4px 10px rgba(0,0,0,.2);
  }
  .portal-header nav.open{display:flex;}
  .portal-header nav a, .portal-header .logout{width:100%; text-align:left;}
  .portal-header .burger{display:block;}
}

/* ---- Главная / дашборд ---- */
.dash-wrap{max-width:1000px; margin:0 auto; padding:28px 20px 60px;}
.dash-wrap h1{font-size:22px; margin:0 0 6px;}
.dash-wrap .sub{color:var(--muted); font-size:14px; margin-bottom:28px;}

.card-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(240px, 1fr));
  gap:16px;
}
.tool-card{
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:12px;
  padding:20px;
  text-decoration:none;
  color:var(--ink);
  display:flex;
  flex-direction:column;
  gap:10px;
  transition:box-shadow .15s, transform .15s;
}
.tool-card:hover{box-shadow:0 4px 16px rgba(15,107,113,.15); transform:translateY(-2px);}
.tool-card .icon{
  width:40px; height:40px;
  border-radius:9px;
  background:var(--accent);
  color:var(--teal-dark);
  display:flex; align-items:center; justify-content:center;
  font-size:19px;
}
.tool-card .icon.green{background:#e4f1e8; color:#2f6f4f;}
.tool-card .name{font-weight:700; font-size:15px;}
.tool-card .desc{color:var(--muted); font-size:13px; line-height:1.4;}
.tool-card.disabled{opacity:.55; cursor:default; pointer-events:none;}
.tool-card .badge{
  font-size:11px; font-weight:600; color:var(--muted);
  background:var(--bg); border:1px solid var(--line);
  padding:2px 8px; border-radius:20px; align-self:flex-start;
}

/* ---- Страница логина ---- */
.login-wrap{
  min-height:100vh;
  display:flex; align-items:center; justify-content:center;
  padding:20px;
}
.login-box{
  background:var(--paper);
  border-radius:14px;
  padding:36px 32px;
  width:100%; max-width:360px;
  box-shadow:0 8px 30px rgba(15,107,113,.12);
  border:1px solid var(--line);
}
.login-box .dot-brand{
  display:flex; align-items:center; gap:8px;
  font-weight:700; color:var(--teal-dark); margin-bottom:22px; font-size:15px;
}
.login-box .dot-brand .dot{width:8px;height:8px;border-radius:50%;background:var(--teal);}
.login-box h1{font-size:18px; margin:0 0 4px;}
.login-box .sub{color:var(--muted); font-size:13px; margin-bottom:22px;}
.login-box label{display:block; font-size:12.5px; font-weight:600; color:var(--teal-dark); margin-bottom:6px; text-transform:uppercase; letter-spacing:.03em;}
.login-box input{
  width:100%; padding:12px 12px; border:1px solid var(--line); border-radius:8px;
  font-size:16px; font-family:inherit; background:#fbfdfd; margin-bottom:16px;
}
.login-box input:focus{outline:2px solid var(--teal); outline-offset:1px;}
.login-box button{
  width:100%; padding:12px; border:none; border-radius:8px;
  background:var(--teal); color:#fff; font-size:14.5px; font-weight:700;
  cursor:pointer;
}
.login-box button:hover{background:var(--teal-dark);}
.login-box .error{
  color:#c0392b; font-size:13px; margin:-8px 0 14px; display:none;
}
.login-box .error.show{display:block;}

/* ---- Справочники: страница-папка (список категорий) ---- */
.ref-folder-wrap{max-width:1000px; margin:0 auto; padding:28px 20px 60px;}
.ref-folder-wrap .eyebrow{
  font-size:11px; font-weight:700; color:var(--teal-dark);
  text-transform:uppercase; letter-spacing:.08em; margin-bottom:4px;
}
.ref-folder-wrap h1{font-size:22px; margin:0 0 6px; letter-spacing:-.01em;}
.ref-folder-wrap .sub{color:var(--muted); font-size:14px; margin-bottom:8px;}
.ref-group-label{
  font-size:11.5px; font-weight:700; color:var(--muted); text-transform:uppercase;
  letter-spacing:.05em; margin:28px 0 12px;
}
.ref-group-label:first-of-type{margin-top:20px;}

/* ---- Справочники: страница одной категории ---- */
.ref-page{max-width:880px; margin:0 auto; padding:20px 20px 60px;}
.ref-breadcrumb{
  display:flex; align-items:center; gap:6px; flex-wrap:wrap;
  font-size:13px; color:var(--muted); margin-bottom:18px;
}
.ref-breadcrumb a{color:var(--teal-dark); text-decoration:none; font-weight:600;}
.ref-breadcrumb a:hover{text-decoration:underline;}
.ref-breadcrumb .sep{color:var(--line);}

.ref-page-header{
  display:flex; align-items:center; gap:14px;
  padding-bottom:20px; margin-bottom:24px; border-bottom:1px solid var(--line);
}
.ref-page-icon{
  width:48px; height:48px; border-radius:12px; flex:0 0 auto;
  background:var(--accent); color:var(--teal-dark);
  display:flex; align-items:center; justify-content:center; font-size:24px;
}
.ref-page-header h1{font-size:21px; margin:0 0 3px; letter-spacing:-.01em;}
.ref-page-header .sub{color:var(--muted); font-size:13.5px; margin:0;}

.ref-section{margin-bottom:32px;}
.ref-section:last-child{margin-bottom:0;}
.ref-section-title{
  font-size:15px; font-weight:700; color:var(--ink); margin:0 0 4px;
  display:flex; align-items:center; gap:8px;
}
.ref-section-num{
  display:inline-flex; align-items:center; justify-content:center;
  width:20px; height:20px; border-radius:5px; flex:0 0 auto;
  background:var(--teal); color:#fff; font-size:11px; font-weight:700;
}
.ref-section-desc{color:var(--muted); font-size:13.5px; margin:0 0 14px; line-height:1.5;}
.ref-table-legend{color:var(--muted); font-size:12.5px; margin:10px 2px 0; line-height:1.5;}

.ref-empty{
  display:flex; flex-direction:column; align-items:flex-start; gap:10px;
  color:var(--muted); font-size:14px; line-height:1.55;
  background:var(--paper); border:1px solid var(--line); border-radius:12px;
  padding:28px; margin-top:8px;
}
.ref-empty .icon{font-size:26px;}
.ref-badge-soon{
  font-size:11px; font-weight:600; color:var(--muted);
  background:var(--bg); border:1px solid var(--line);
  padding:2px 8px; border-radius:20px; margin-left:2px; vertical-align:middle;
}

@media (max-width:600px){
  .ref-folder-wrap, .ref-page{padding-left:16px; padding-right:16px;}
  .ref-page-header{gap:12px;}
  .ref-page-icon{width:40px; height:40px; font-size:20px; border-radius:10px;}
  .ref-page-header h1{font-size:18px;}
}

/* ---- Таблицы внутри справочников ---- */
.ref-table-scroll{overflow-x:auto; border:1.5px solid #b9c7ca; border-radius:8px; -webkit-overflow-scrolling:touch;}
table.ref-table{width:100%; border-collapse:collapse; font-size:13.5px; min-width:520px;}
table.ref-table th{
  background:var(--accent); color:var(--teal-dark); font-weight:700;
  text-align:center; padding:10px 10px; border:1px solid #b9c7ca;
  white-space:normal;
}
table.ref-table td{
  padding:9px 10px; border:1px solid #b9c7ca; text-align:center;
}
table.ref-table td:first-child{font-weight:600; background:#fafcfc;}
table.ref-table tr:hover td{background:#f5fafa;}

/* На мобильном таблица с горизонтальной прокруткой читается плохо —
   вместо этого каждая строка превращается в отдельную карточку:
   первая ячейка становится заголовком карточки, остальные — парами
   "подпись: значение". Подписи берутся из data-label на каждой td. */
@media (max-width:600px){
  .ref-table-scroll{overflow-x:visible; border:none; border-radius:0;}
  table.ref-table{min-width:0; font-size:14px;}
  table.ref-table thead{
    position:absolute; width:1px; height:1px; overflow:hidden;
    clip:rect(0,0,0,0); white-space:nowrap;
  }
  table.ref-table, table.ref-table tbody{display:block;}
  table.ref-table tr{
    display:block; border:1.5px solid #b9c7ca; border-radius:10px;
    margin-bottom:12px; overflow:hidden; background:var(--paper);
  }
  table.ref-table td{
    display:flex; justify-content:space-between; align-items:baseline; gap:12px;
    text-align:right; border:none; border-top:1px solid #e3eaeb;
    padding:10px 12px;
  }
  table.ref-table td:first-child{
    display:block; text-align:left; border-top:none;
    background:var(--accent); color:var(--teal-dark); font-weight:700;
    padding:11px 12px;
  }
  table.ref-table td:not(:first-child)::before{
    content:attr(data-label);
    font-weight:600; color:var(--muted); text-align:left; flex:0 0 auto;
  }
}

/* ---- Список файлов (инструкции, документы) внутри справочника ---- */
.ref-files-loading{color:var(--muted); font-size:13.5px;}
.ref-file-list{
  display:flex; flex-direction:column; gap:8px;
}
.ref-file-link{
  display:flex; align-items:center; gap:12px;
  border:1.5px solid #b9c7ca; border-radius:10px; padding:13px 14px;
  text-decoration:none; color:var(--ink); font-size:14px;
  background:#fafcfc;
}
.ref-file-link:hover{border-color:var(--teal); background:var(--accent);}
.ref-file-link:active{background:var(--accent);}
.ref-file-icon{font-size:19px; flex:0 0 auto;}
.ref-file-name{flex:1 1 auto; word-break:break-word;}
.ref-file-link .arrow{color:var(--muted); font-size:14px; flex:0 0 auto;}

/* ---- Калькулятор производительности ---- */
.calc-field{margin-bottom:16px; max-width:420px;}
.calc-field label{
  display:block; font-size:12.5px; font-weight:600; color:var(--teal-dark);
  margin-bottom:6px; text-transform:uppercase; letter-spacing:.03em;
}
.calc-field select, .calc-field input{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:8px;
  font-size:15px; font-family:inherit; background:#fbfdfd; color:var(--ink);
}
.calc-field select:focus, .calc-field input:focus{outline:2px solid var(--teal); outline-offset:1px;}
.calc-btn{
  padding:12px 22px; border:none; border-radius:8px;
  background:var(--teal); color:#fff; font-size:14.5px; font-weight:700;
  cursor:pointer; font-family:inherit;
}
.calc-btn:hover{background:var(--teal-dark);}

.calc-results{
  background:var(--accent); border:1px solid var(--line); border-radius:10px;
  padding:6px 18px;
}
.calc-result-row{
  display:flex; justify-content:space-between; align-items:baseline; gap:12px;
  padding:13px 0; border-bottom:1px solid rgba(15,107,113,.12);
  flex-wrap:wrap;
}
.calc-result-row:last-child{border-bottom:none;}
.calc-result-label{font-size:13.5px; color:var(--teal-dark); font-weight:600;}
.calc-result-value{font-size:15px; font-weight:700; color:var(--ink); text-align:right;}
.calc-result-sub{font-size:12px; font-weight:400; color:var(--muted);}
.calc-result-muted{font-size:13px; font-weight:400; color:var(--muted); font-style:italic;}

@media (max-width:600px){
  .calc-result-row{flex-direction:column; gap:2px;}
  .calc-result-value{text-align:left;}
}

/* ---- Калькулятор фильтроцикла: подбор смолы, формула ---- */
.calc-field-optional{font-weight:400; text-transform:none; color:var(--muted); font-size:11.5px; letter-spacing:0;}

.calc-resin-grid{
  display:grid; grid-template-columns:repeat(2, 1fr); gap:12px;
}
.calc-resin-card{
  border:2px solid var(--line); border-radius:12px; padding:14px 16px;
  background:#fafcfc; cursor:pointer; transition:border-color .15s;
}
.calc-resin-card:hover{border-color:var(--teal);}
.calc-resin-card.fits{border-color:#8fc9a8; background:#f3faf5;}
.calc-resin-card.not-fits{border-color:#e3b0a8; background:#fdf5f4; opacity:.75;}
.calc-resin-card.selected{border-color:var(--teal); box-shadow:0 0 0 2px rgba(26,143,150,.15);}
.calc-resin-card-head{display:flex; align-items:center; gap:8px; margin-bottom:2px;}
.calc-resin-mark{
  flex:0 0 auto; width:20px; height:20px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:700; color:#fff; background:var(--muted);
}
.calc-resin-card.fits .calc-resin-mark{background:#3f9d63;}
.calc-resin-card.not-fits .calc-resin-mark{background:#c0392b;}
.calc-resin-name{font-weight:700; font-size:14.5px; color:var(--ink); flex:1 1 auto;}
.calc-resin-k{font-size:11px; color:var(--muted); font-weight:600;}
.calc-resin-desc{font-size:11.5px; color:var(--muted); margin-bottom:10px; line-height:1.4;}

.calc-bars{display:flex; flex-direction:column; gap:6px;}
.calc-bar-row{display:flex; flex-direction:column; gap:2px;}
.calc-bar-label{
  display:flex; justify-content:space-between; font-size:11px; color:var(--muted); font-weight:600;
}
.calc-bar-value{font-weight:400; color:var(--ink);}
.calc-bar-track{height:5px; border-radius:3px; background:var(--line); overflow:hidden;}
.calc-bar-fill{height:100%; border-radius:3px; transition:width .2s;}
.calc-bar-fill.empty{width:0 !important;}
.calc-bar-fill.ok{background:#3f9d63;}
.calc-bar-fill.over{background:#c0392b;}

@media (max-width:640px){
  .calc-resin-grid{grid-template-columns:1fr;}
}

.calc-formula-box{
  background:var(--accent); border:1px solid var(--line); border-radius:10px;
  padding:18px; text-align:center; margin-bottom:16px;
}
.calc-formula{font-size:17px; font-weight:700; color:var(--teal-dark); font-family:'Segoe UI', Arial, sans-serif;}
.calc-formula sub{font-size:11px;}

.calc-explain-list{display:flex; flex-direction:column; gap:10px;}
.calc-explain-row{font-size:13.5px; color:var(--ink); line-height:1.55; padding-left:2px;}
.calc-explain-row b{color:var(--teal-dark);}

@media (max-width:600px){
  .calc-resin-option{align-items:flex-start;}
  .calc-resin-desc{line-height:1.4;}
}
