/* ============================================================
   Маляр Калькулятор — дизайн-система
   ============================================================ */

/* ===== ТОКЕНЫ ===== */
:root {
  color-scheme: light;

  --accent:        #16a34a;
  --accent-2:      #65d94e;
  --accent-soft:   #e8f8ed;
  --accent-ink:    #0f7a37;
  --grad:          linear-gradient(135deg, #16a34a 0%, #4ac26b 55%, #86e05a 100%);

  --bg:            #f4f6f5;
  --surface:       #ffffff;
  --surface-2:     #f0f3f1;
  --surface-3:     #e6ebe8;
  --border:        #dfe5e1;
  --border-strong: #c8d2cc;

  --text:          #10221a;
  --text-2:        #4a5b52;
  --text-3:        #8a978f;

  --c-base:        #16a34a;
  --c-hardener:    #f0862a;
  --c-thinner:     #2f8ce0;
  --c-accel:       #9b5de5;
  --c-retard:      #e0495f;

  --danger:        #d92d3f;
  --danger-soft:   #fdeaec;
  --warn-soft:     #fff4e3;
  --info-soft:     #e8f2fd;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;
  --r-full: 999px;

  --sh-1: 0 1px 2px rgba(16,34,26,.05), 0 2px 8px rgba(16,34,26,.04);
  --sh-2: 0 4px 12px rgba(16,34,26,.07), 0 12px 32px rgba(16,34,26,.06);
  --sh-3: 0 12px 40px rgba(16,34,26,.16);
  --sh-accent: 0 6px 20px rgba(22,163,74,.32);

  --header-h: 60px;
  --nav-h:    66px;
  --safe-b:   env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.22,.9,.26,1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent:        #34d364;
    --accent-2:      #8ceb62;
    --accent-soft:   #143020;
    --accent-ink:    #7ef0a3;
    --grad:          linear-gradient(135deg, #17a34d 0%, #35c86a 55%, #7ede55 100%);

    --bg:            #0c110e;
    --surface:       #151b17;
    --surface-2:     #1c2420;
    --surface-3:     #26302a;
    --border:        #2a342e;
    --border-strong: #3b483f;

    --text:          #e9f1ec;
    --text-2:        #a4b3aa;
    --text-3:        #6d7c73;

    --c-hardener:    #ff9d4d;
    --c-thinner:     #5aa9f0;
    --c-accel:       #b583f0;
    --c-retard:      #ff6b7d;

    --danger:        #ff6b7d;
    --danger-soft:   #2e1519;
    --warn-soft:     #2e2312;
    --info-soft:     #12212e;

    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 4px 14px rgba(0,0,0,.5);
    --sh-3: 0 12px 40px rgba(0,0,0,.65);
    --sh-accent: 0 6px 20px rgba(52,211,100,.22);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #34d364; --accent-2: #8ceb62; --accent-soft: #143020; --accent-ink: #7ef0a3;
  --grad: linear-gradient(135deg, #17a34d 0%, #35c86a 55%, #7ede55 100%);
  --bg: #0c110e; --surface: #151b17; --surface-2: #1c2420; --surface-3: #26302a;
  --border: #2a342e; --border-strong: #3b483f;
  --text: #e9f1ec; --text-2: #a4b3aa; --text-3: #6d7c73;
  --c-hardener: #ff9d4d; --c-thinner: #5aa9f0; --c-accel: #b583f0; --c-retard: #ff6b7d;
  --danger: #ff6b7d; --danger-soft: #2e1519; --warn-soft: #2e2312; --info-soft: #12212e;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 4px 14px rgba(0,0,0,.5);
  --sh-3: 0 12px 40px rgba(0,0,0,.65);
  --sh-accent: 0 6px 20px rgba(52,211,100,.22);
}

/* ===== БАЗА ===== */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

::selection { background: var(--accent); color: #fff; }

/* ===== ШАПКА ===== */
#app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  display: flex;
  align-items: center;
  gap: 11px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(20px);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 11px;
  background: var(--grad);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .3px;
  box-shadow: var(--sh-accent);
  flex-shrink: 0;
}

#app-header h1 {
  flex: 1; min-width: 0;
  font-size: 16px; font-weight: 700; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#app-header h1 .version {
  display: block;
  font-size: 11px; font-weight: 500; color: var(--text-3);
  letter-spacing: .2px;
}

.icon-btn {
  width: 38px; height: 38px;
  border: none; background: var(--surface-2);
  border-radius: var(--r-full);
  display: grid; place-items: center;
  color: var(--text-2); cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(.92); }

/* ===== КОНТЕНТ ===== */
#main-content {
  padding: calc(var(--header-h) + env(safe-area-inset-top, 0px) + 14px) 14px
           calc(var(--nav-h) + var(--safe-b) + 28px);
  max-width: 620px;
  margin: 0 auto;
}
@media (min-width: 620px) { #main-content { padding-left: 20px; padding-right: 20px; } }

.tab-panel { display: none; animation: rise .32s var(--ease); }
.tab-panel.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== НАВИГАЦИЯ ===== */
#bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.8) blur(22px);
  -webkit-backdrop-filter: saturate(1.8) blur(22px);
  border-top: 1px solid var(--border);
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  border: none; background: none;
  color: var(--text-3);
  font-size: 10.5px; font-weight: 600; letter-spacing: .1px;
  cursor: pointer; position: relative;
  transition: color .2s var(--ease);
}
.nav-btn svg { transition: transform .3s var(--ease); }
.nav-btn.active { color: var(--accent); }
.nav-btn.active svg { transform: translateY(-1px) scale(1.08); }
.nav-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 4px 4px;
  background: var(--grad);
}
.nav-btn:active svg { transform: scale(.88); }

/* ===== КАРТОЧКИ ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--sh-1);
}
.card-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-3);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 7px;
}
.card-title::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* ===== СЕГМЕНТИРОВАННЫЙ ПЕРЕКЛЮЧАТЕЛЬ ===== */
.segmented {
  position: relative;
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-full);
  padding: 4px;
  gap: 2px;
}
.segmented::before {
  content: '';
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / var(--seg-count, 2));
  border-radius: var(--r-full);
  background: var(--grad);
  box-shadow: var(--sh-accent);
  transition: transform .38s var(--ease);
  transform: translateX(calc(var(--seg-i, 0) * 100%));
}
.segmented[data-active="0"] { --seg-i: 0; }
.segmented[data-active="1"] { --seg-i: 1; }
.segmented[data-active="2"] { --seg-i: 2; }
.seg-btn {
  flex: 1; position: relative; z-index: 1;
  border: none; background: none;
  padding: 10px 8px;
  border-radius: var(--r-full);
  font-size: 14px; font-weight: 650;
  color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: color .28s var(--ease);
}
.seg-btn.active { color: #fff; }

/* ===== ПОЛЯ ===== */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.select-wrap { position: relative; }
.select-arrow {
  position: absolute; right: 13px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

.form-select, .form-input, textarea, .form-search {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit; font-size: 15px;
  transition: border-color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
  appearance: none; -webkit-appearance: none;
}
.form-select { padding-right: 38px; cursor: pointer; }
textarea { min-height: 0; resize: vertical; line-height: 1.5; }

.form-select:focus, .form-input:focus, textarea:focus, .form-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}
.form-select:disabled {
  opacity: .5; cursor: not-allowed;
}

/* Крупный числовой ввод */
.big-input-wrap {
  position: relative;
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 4px 16px 4px 4px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.big-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}
.big-input-wrap input {
  flex: 1; min-width: 0;
  border: none; background: none;
  padding: 14px 12px;
  font-family: var(--mono);
  font-size: 30px; font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
}
.big-input-wrap input:focus { outline: none; }
.big-input-wrap input::-webkit-outer-spin-button,
.big-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.big-input-wrap input[type=number] { -moz-appearance: textfield; }
.big-unit {
  font-size: 16px; font-weight: 700;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ===== ЧИПЫ ===== */
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 9px 15px;
  min-height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 620;
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all .2s var(--ease);
}
.chip:active { transform: scale(.94); }
.chip.active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-accent);
}
.chip[data-zone="cold"].active { background: linear-gradient(135deg,#1668c4,#4aa3f0); box-shadow: 0 6px 18px rgba(22,104,196,.3); }
.chip[data-zone="warm"].active { background: linear-gradient(135deg,#e0761a,#f5a94a); box-shadow: 0 6px 18px rgba(224,118,26,.3); }
.chip[data-zone="hot"].active  { background: linear-gradient(135deg,#c92a3c,#f0616f); box-shadow: 0 6px 18px rgba(201,42,60,.3); }

/* ===== ТЕМПЕРАТУРА ===== */
.temp-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.temp-head .big-input-wrap { flex: 1; }
.zone-pill {
  padding: 8px 15px;
  border-radius: var(--r-full);
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-ink);
  transition: all .3s var(--ease);
}
.zone-pill[data-zone="cold"]   { background: var(--info-soft);   color: #2f8ce0; }
.zone-pill[data-zone="warm"]   { background: var(--warn-soft);   color: #d97316; }
.zone-pill[data-zone="hot"]    { background: var(--danger-soft); color: var(--danger); }

.adj-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.adj-item {
  display: flex; gap: 9px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  font-size: 13px; line-height: 1.45;
  color: var(--text-2);
  animation: rise .3s var(--ease);
}
.adj-item[data-kind="retarder"]    { border-left-color: var(--c-retard); background: var(--danger-soft); }
.adj-item[data-kind="accelerator"] { border-left-color: var(--c-accel);  background: var(--info-soft); }
.adj-item[data-kind="warning"]     { border-left-color: var(--c-hardener); background: var(--warn-soft); }
.adj-icon { flex-shrink: 0; font-size: 15px; line-height: 1.3; }

/* ===== ИНФО-ПЛАШКА РАСХОДА ===== */
.coverage-info {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 12px; padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12.5px; line-height: 1.45;
  animation: rise .3s var(--ease);
}
.coverage-info b { font-family: var(--mono); font-weight: 700; }

/* ===== КНОПКИ ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;
  padding: 12px 22px;
  border: none; border-radius: var(--r-sm);
  font-size: 15px; font-weight: 680;
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--sh-accent); }
.btn-primary:hover { box-shadow: 0 8px 26px rgba(22,163,74,.42); }
.btn-outline {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface-3); }
.btn-danger-outline {
  background: transparent; color: var(--danger);
  border: 1.5px solid color-mix(in srgb, var(--danger) 40%, transparent);
}
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

/* Липкая кнопка расчёта */
.calc-cta { margin: 16px 0 4px; }
.calc-cta .btn { width: 100%; min-height: 54px; font-size: 16.5px; border-radius: var(--r); }

/* ===== РЕЗУЛЬТАТ ===== */
.result { animation: rise .4s var(--ease); }

.result-hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--grad);
  color: #fff;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--sh-2);
}
.result-hero::after {
  content: '';
  position: absolute; right: -40px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.13);
}
.result-hero > * { position: relative; z-index: 1; }
.rh-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; opacity: .85; }
.rh-value {
  font-family: var(--mono);
  font-size: 42px; font-weight: 800;
  letter-spacing: -2px; line-height: 1.1;
  margin: 3px 0 2px;
}
.rh-value small { font-size: 19px; font-weight: 700; letter-spacing: 0; opacity: .9; margin-left: 3px; }
.rh-sub { font-size: 13px; opacity: .9; }
.rh-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px;
}
.rh-tag {
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,.2);
  font-size: 11.5px; font-weight: 650;
  backdrop-filter: blur(4px);
}

/* Шкала состава */
.comp-bar {
  display: flex;
  height: 12px; border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface-3);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
}
.comp-seg { transition: width .6s var(--ease); min-width: 2px; }
.comp-seg[data-c="base"]        { background: var(--c-base); }
.comp-seg[data-c="hardener"]    { background: var(--c-hardener); }
.comp-seg[data-c="thinner"]     { background: var(--c-thinner); }
.comp-seg[data-c="accelerator"] { background: var(--c-accel); }
.comp-seg[data-c="retarder"]    { background: var(--c-retard); }

/* Строки компонентов */
.comp-list { display: flex; flex-direction: column; gap: 8px; }
.comp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.comp-row[data-c="base"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}
.comp-dot {
  width: 11px; height: 11px; border-radius: 50%;
  flex-shrink: 0;
}
.comp-dot[data-c="base"]        { background: var(--c-base); }
.comp-dot[data-c="hardener"]    { background: var(--c-hardener); }
.comp-dot[data-c="thinner"]     { background: var(--c-thinner); }
.comp-dot[data-c="accelerator"] { background: var(--c-accel); }
.comp-dot[data-c="retarder"]    { background: var(--c-retard); }

.comp-name { font-size: 14.5px; font-weight: 660; line-height: 1.25; }
.comp-formula {
  font-family: var(--mono);
  font-size: 11.5px; color: var(--text-3);
  margin-top: 2px;
}
.comp-amount {
  font-family: var(--mono);
  font-size: 18px; font-weight: 750;
  white-space: nowrap; letter-spacing: -.4px;
}
.comp-amount small { font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 2px; }

.result-total {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding: 15px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  font-weight: 700;
}
.result-total .rt-val { font-family: var(--mono); font-size: 21px; letter-spacing: -.5px; }

.result-actions { display: flex; gap: 9px; margin-top: 13px; }
.result-actions .btn { flex: 1; }

.result-note {
  margin-top: 12px; padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border-left: 3px solid var(--text-3);
  font-size: 12.5px; color: var(--text-2); line-height: 1.5;
}

/* ===== ИСТОРИЯ ===== */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px;
}
.section-head h2 { font-size: 20px; font-weight: 780; letter-spacing: -.4px; }
.count-badge {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12px; font-weight: 750;
}
.hint-line {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3);
  margin-bottom: 14px;
}

.history-list { display: flex; flex-direction: column; gap: 9px; }
.hist-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--sh-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.hist-item:active { transform: scale(.99); }
.hist-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.hist-code { font-size: 15.5px; font-weight: 730; letter-spacing: -.2px; }
.hist-name { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.hist-date { font-size: 11px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.hist-figs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.hist-fig {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11.5px; font-weight: 620;
  color: var(--text-2);
}
.hist-fig b { color: var(--text); }
.hist-acts { display: flex; gap: 7px; }
.hist-acts .btn { flex: 1; }

/* ===== БИБЛИОТЕКА ===== */
.search-wrap { position: relative; margin-bottom: 11px; }
.search-wrap .search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.form-search { padding-left: 40px; border-radius: var(--r-full); }
.form-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.filter-scroll {
  display: flex; gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 -14px 13px;
  padding-left: 14px; padding-right: 14px;
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }

.library-list { display: flex; flex-direction: column; gap: 9px; }
.lib-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-1);
  transition: box-shadow .2s var(--ease);
}
.lib-card.open { box-shadow: var(--sh-2); border-color: var(--border-strong); }
.lib-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px;
  cursor: pointer;
}
.lib-swatch {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.lib-swatch[data-chem="pu"]      { background: linear-gradient(135deg,#16a34a,#5fd17f); }
.lib-swatch[data-chem="pu-ac"]   { background: linear-gradient(135deg,#0d8f6f,#4ecfae); }
.lib-swatch[data-chem="ac"]      { background: linear-gradient(135deg,#1668c4,#5aa9f0); }
.lib-swatch[data-chem="pe"]      { background: linear-gradient(135deg,#e0761a,#f5a94a); }
.lib-swatch[data-chem="wb"]      { background: linear-gradient(135deg,#0d8a99,#4ecad6); }
.lib-swatch[data-chem="solvent"] { background: linear-gradient(135deg,#6b7280,#a3adb8); }

.lib-info { flex: 1; min-width: 0; }
.lib-code { font-size: 15.5px; font-weight: 730; letter-spacing: -.2px; }
.lib-desc { font-size: 12px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-chev { color: var(--text-3); transition: transform .3s var(--ease); flex-shrink: 0; }
.lib-card.open .lib-chev { transform: rotate(180deg); }

.lib-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--border); padding-top: 13px; }
.lib-card.open .lib-body { display: block; animation: rise .26s var(--ease); }
.lib-text { font-size: 13px; color: var(--text-2); line-height: 1.55; margin-bottom: 12px; }

.lib-specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
@media (min-width: 460px) { .lib-specs { grid-template-columns: repeat(3, 1fr); } }
.spec {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.spec-k { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); }
.spec-v { font-family: var(--mono); font-size: 15px; font-weight: 720; margin-top: 2px; }

.lib-mix { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mix-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 13px;
}
.mix-row .comp-dot { width: 9px; height: 9px; }
.mix-row b { font-family: var(--mono); margin-left: auto; font-weight: 720; }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tag {
  padding: 4px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2);
}
.tag[data-t="chem"] { background: var(--accent-soft); color: var(--accent-ink); }
.tag[data-t="warn"] { background: var(--warn-soft);  color: #d97316; }

/* ===== ПУСТЫЕ СОСТОЯНИЯ ===== */
.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px 24px; text-align: center;
  color: var(--text-3);
}
.empty svg { opacity: .35; margin-bottom: 14px; }
.empty h3 { font-size: 16px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.empty p { font-size: 13px; }

/* ===== АДМИН-ПАНЕЛЬ ===== */
#admin-overlay {
  position: fixed; inset: 0;
  background: rgba(8,16,12,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  display: none; align-items: flex-end;
}
#admin-overlay.open { display: flex; animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#admin-panel {
  width: 100%;
  max-height: 93vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 0 16px calc(24px + var(--safe-b));
  animation: slideUp .36s var(--ease);
  -webkit-overflow-scrolling: touch;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 620px) {
  #admin-overlay { align-items: center; justify-content: center; }
  #admin-panel { max-width: 560px; border-radius: var(--r-lg); max-height: 88vh; }
}

#admin-panel::before {
  content: '';
  display: block; width: 38px; height: 4px;
  border-radius: 2px; background: var(--border-strong);
  margin: 10px auto 4px;
}

.admin-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0 14px;
  background: var(--bg);
}
.admin-head h2 { font-size: 19px; font-weight: 780; letter-spacing: -.3px; }

.admin-lock { display: grid; place-items: center; margin: 22px 0 6px; color: var(--accent); }
.admin-hint { text-align: center; font-size: 13.5px; color: var(--text-3); margin-bottom: 22px; }

.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: none; background: none;
  color: var(--text-3); cursor: pointer;
  display: grid; place-items: center; border-radius: var(--r-full);
}
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }

.form-error {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px; font-weight: 600;
  margin-bottom: 12px;
  animation: shake .4s var(--ease);
}
@keyframes shake {
  0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); }
}

.admin-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.admin-user { font-size: 13px; color: var(--text-3); }

.admin-tabs {
  display: flex; gap: 3px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  padding: 4px; margin-bottom: 16px;
}
.admin-tab-btn {
  flex: 1; border: none; background: none;
  padding: 9px 6px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 650;
  color: var(--text-2); cursor: pointer;
  transition: all .22s var(--ease);
}
.admin-tab-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--sh-1); }

.admin-section { display: none; }
.admin-section.active { display: block; animation: rise .26s var(--ease); }

.admin-section-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.admin-section-title { font-size: 14px; font-weight: 700; }

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-list-item {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.admin-list-item > div:first-child { flex: 1; min-width: 0; }
.admin-list-item-name { font-size: 14px; font-weight: 680; }
.admin-list-item-meta { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.admin-actions { display: flex; gap: 6px; flex-shrink: 0; }
.admin-actions .btn { min-height: 34px; padding: 6px 11px; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

hr.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.spinner {
  width: 17px; height: 17px;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== МОДАЛКА ===== */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8,16,12,.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 400;
  display: none; align-items: center; justify-content: center;
  padding: 18px;
}
#modal-overlay.open { display: flex; animation: fade .22s var(--ease); }
#modal-box {
  width: 100%; max-width: 480px;
  max-height: 86vh; overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-3);
  animation: pop .28s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(14px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.modal-title { font-size: 17.5px; font-weight: 760; letter-spacing: -.3px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ===== TOAST ===== */
#toast {
  position: fixed;
  left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 130%);
  max-width: calc(100vw - 32px);
  padding: 13px 20px;
  border-radius: var(--r-full);
  background: var(--text);
  color: var(--bg);
  font-size: 14px; font-weight: 620;
  box-shadow: var(--sh-3);
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: transform .42s var(--ease), opacity .3s var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ===== ПРОМПТ УСТАНОВКИ ===== */
#install-prompt {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--sh-3);
  z-index: 200;
  animation: rise .4s var(--ease);
}
.ip-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.ip-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: var(--sh-accent);
}
.ip-text strong { display: block; font-size: 14px; font-weight: 700; }
.ip-text span { font-size: 12px; color: var(--text-3); }
.ip-acts { display: flex; gap: 8px; }
.ip-acts .btn { flex: 1; }

/* ===== ПЕЧАТЬ ===== */
@media print {
  #app-header, #bottom-nav, .calc-cta, .result-actions, #install-prompt { display: none !important; }
  #main-content { padding: 0; max-width: none; }
  .card, .result-hero { box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== ПРОЦЕНТНОЕ ПОЛЕ ===== */
.pct-wrap { position: relative; }
.pct-wrap .form-input { padding-right: 34px; font-family: var(--mono); font-weight: 650; }
.pct-sign {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-weight: 650; pointer-events: none;
}
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 10px; line-height: 1.45; }

/* ===== ГАЛОЧКА ===== */
.check-row {
  display: flex; align-items: flex-start; gap: 11px;
  margin-top: 12px; padding: 12px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.check-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.check-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border-strong);
  border-radius: 7px;
  display: grid; place-items: center;
  color: transparent;
  transition: all .18s var(--ease);
}
.check-row input:checked + .check-box {
  background: var(--grad); border-color: transparent; color: #fff;
}
.check-row input:focus-visible + .check-box {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.check-text { font-size: 13px; line-height: 1.4; }
.check-text b { display: block; font-weight: 680; font-size: 13.5px; }
.check-text span { color: var(--text-3); font-size: 12px; }

/* Предупреждение в заметке результата */
.result-note[data-warn="1"] {
  background: var(--warn-soft);
  border-left-color: var(--c-hardener);
  color: var(--text);
}

/* ===== ЗАПАС ОТДЕЛЬНОЙ СТРОКОЙ ===== */
.comp-seg[data-c="reserve"]  { background: var(--text-3); }
.comp-dot[data-c="reserve"]  { background: var(--text-3); }
.comp-row[data-c="reserve"] {
  border-style: dashed;
  background: transparent;
}
.result-subtotal {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 11px 15px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 13.5px; color: var(--text-2);
}
.result-subtotal span:last-child { font-family: var(--mono); font-weight: 680; }
