/* АТОН · Матрица продуктов — standalone PWA */

:root {
  --navy: #0B1F3A;
  --navy-2: #13294B;
  --gold: #C8A24A;
  --gold-soft: #F3E7C9;
  --ink: #0F172A;
  --muted: #64748B;
  --muted-2: #94A3B8;
  --line: #E2E8F0;
  --line-2: #EEF1F6;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --good: #0E9F6E;
  --warn: #B45309;
  --bad: #B91C1C;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(11, 31, 58, .45);
  --tap: 44px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  box-shadow: 0 10px 30px -18px rgba(11, 31, 58, .9);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { display: inline-flex; color: #fff; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 15px; letter-spacing: .18em; font-weight: 800; }
.brand-text span { font-size: 12px; color: rgba(255, 255, 255, .68); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.sync { font-size: 12px; color: rgba(255, 255, 255, .62); white-space: nowrap; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--gold);
  color: #231a05;
  font-weight: 600;
  font-size: 13px;
  padding: 0 15px;
  height: 36px;
  border-radius: 10px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #d8b35c; }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
  color: #fff;
}
.btn.ghost:hover { background: rgba(255, 255, 255, .16); }

/* ── hero ───────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  padding: clamp(18px, 3vw, 30px) clamp(14px, 3vw, 28px) 6px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}
.hero-text { min-width: 260px; flex: 1 1 320px; }
.hero-text h1 { font-size: clamp(22px, 3.2vw, 32px); }
.hero-text p { margin: 6px 0 0; color: var(--muted); font-size: 14px; max-width: 640px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.stat b { color: var(--ink); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.stat .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.stat.offline .dot { background: var(--warn); }

/* ── filters ────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px clamp(14px, 3vw, 28px);
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.field select, .field input {
  height: 38px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 15px; }
.field select:focus, .field input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11, 31, 58, .09); }
.field.narrow input { width: 108px; }
.field.search { position: relative; flex: 1 1 240px; max-width: 340px; }
.field.search svg { position: absolute; left: 11px; bottom: 11px; color: var(--muted-2); }
.field.search input { padding-left: 34px; width: 100%; }
.filters > .btn { height: 38px; }
.filters .btn.ghost { background: var(--card); border-color: var(--line); color: var(--muted); }
.filters .btn.ghost:hover { color: var(--ink); border-color: var(--muted-2); }

/* ── view tabs ──────────────────────────────────────────── */
.viewtabs {
  display: inline-flex;
  gap: 4px;
  margin: 2px auto 0;
  padding: 4px;
  background: #E9EDF3;
  border-radius: 12px;
}
.viewtabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 9px;
  transition: background .12s ease, color .12s ease;
}
.viewtabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

.view {
  flex: 1;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px clamp(14px, 3vw, 28px) 40px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── matrix ─────────────────────────────────────────────── */
.matrix-scroll { overflow: auto; max-height: calc(100dvh - 170px); border-radius: var(--radius); }
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; table-layout: fixed; }
.matrix .col-type { width: 170px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); vertical-align: top; }
.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #F8FAFC;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 12px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  text-align: left;
  font-size: 13.5px;
  font-weight: 700;
  padding: 12px;
  min-width: 168px;
  max-width: 200px;
  border-right: 1px solid var(--line);
}
.matrix thead th:first-child { left: 0; z-index: 4; }
.matrix td { padding: 7px; min-width: 150px; }
.matrix td.empty { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(148, 163, 184, .07) 6px 12px); }
.matrix tbody tr:hover th { background: #FAFBFD; }
.term-head small { display: block; font-size: 10px; font-weight: 600; color: var(--muted-2); letter-spacing: 0; text-transform: none; margin-top: 2px; }
.type-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted-2);
  background: var(--line-2);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: 1px;
}

.chip {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #FBFCFE;
  border-radius: 9px;
  padding: 6px 9px;
  margin-bottom: 5px;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
}
.chip:last-child { margin-bottom: 0; }
.chip:hover { border-color: var(--navy); background: #fff; transform: translateY(-1px); }
.chip-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--ink); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; gap: 4px; flex-wrap: nowrap; flex: none; }
.chip-meta .y { color: var(--good); font-weight: 600; }
.chip-meta .r { color: var(--warn); font-weight: 600; }
.chip.hl { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }

/* ── heat map ───────────────────────────────────────────── */
.heat-wrap { padding: 16px; }
.heat-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.heat-title h3 { font-size: 15px; }
.heat-hint { color: var(--muted); font-size: 12px; max-width: 760px; line-height: 1.45; margin: 0 0 14px; }
.heat { display: grid; grid-template-columns: minmax(112px, 150px) repeat(4, minmax(120px, 1fr)); gap: 6px; }
.heat-axis {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px;
  line-height: 1.3;
}
.heat-axis small { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted-2); }
.heat-cell {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 7px;
  min-height: 74px;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.heat-cell.nd { background: #F8FAFC; }
.heat-cell.s0 { background: #FEF2F2; border-color: #FBD5D5; }
.heat-cell.s1 { background: #FFF7ED; border-color: #FDE3C4; }
.heat-cell.s2 { background: #F0F9FF; border-color: #CFE8F7; }
.heat-cell.s3 { background: #ECFDF5; border-color: #C7EEDD; }
.heat-cell.s4 { background: #DCFCE7; border-color: #B5EBC9; }
.heat-legend { display: flex; align-items: center; gap: 7px; margin-top: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.heat-legend i { width: 22px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid rgba(15, 23, 42, .07); }

/* ── list ───────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #CBD5E1; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h3 { font-size: 14.5px; line-height: 1.3; }
.badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--line-2);
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.card-metrics { display: flex; gap: 14px; flex-wrap: wrap; }
.metric { display: flex; flex-direction: column; gap: 1px; }
.metric span { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); font-weight: 700; }
.metric b { font-size: 14px; font-variant-numeric: tabular-nums; }
.metric b.good { color: var(--good); }
.metric b.warn { color: var(--warn); }
.card .summary { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; gap: 8px; margin-top: auto; }
.link-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  padding: 0 12px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.link-btn:hover { border-color: var(--navy); background: #F8FAFF; }
.link-btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.link-btn.primary:hover { background: #17325a; }

/* ── empty / skeleton ───────────────────────────────────── */
.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.skeleton { display: grid; gap: 10px; }
.skeleton div { height: 64px; border-radius: 12px; background: linear-gradient(90deg, #EEF1F6 25%, #F7F9FC 37%, #EEF1F6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ── modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(11, 31, 58, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade .14s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  width: min(720px, 100%);
  max-height: min(86dvh, 900px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: pop .16s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-close {
  position: sticky;
  top: 10px;
  margin-left: calc(100% - 44px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  z-index: 2;
  margin-bottom: -34px;
}
.modal-close:hover { color: var(--ink); border-color: var(--muted-2); }
.modal-body { padding: 22px 24px 26px; }
.modal-body h2 { font-size: 20px; line-height: 1.25; padding-right: 40px; }
.modal-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 18px; }
.modal-section { margin-top: 18px; }
.modal-section h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); }
.modal-section p { margin: 0; font-size: 13.5px; line-height: 1.6; color: #1E293B; }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.param { background: #F8FAFC; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; }
.param span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); font-weight: 700; }
.param b { font-size: 13.5px; font-weight: 600; word-break: break-word; }
.modal-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 22px; }

/* ── toast / footer ─────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 70;
  max-width: min(92vw, 460px);
  text-align: center;
}
.toast[hidden] { display: none; }
.footer {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 16px clamp(14px, 3vw, 28px) calc(22px + env(safe-area-inset-bottom));
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  font-size: 11.5px;
  color: var(--muted-2);
  border-top: 1px solid var(--line);
}
.muted { color: var(--muted-2); }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero { gap: 14px; }
  .matrix-scroll { max-height: none; }
  .heat { grid-template-columns: minmax(84px, 108px) repeat(4, minmax(96px, 1fr)); gap: 5px; }
  .heat-axis { font-size: 10px; }
}
@media (max-width: 680px) {
  .topbar { gap: 10px; padding: 9px 12px; }
  .brand-text span { display: none; }
  .sync { display: none; }
  .btn { height: 34px; padding: 0 12px; font-size: 12.5px; }
  .hero { padding-top: 16px; }
  .hero-text p { font-size: 13px; }
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px 10px;
    padding: 12px;
    align-items: end;
  }
  .field.search { grid-column: 1 / -1; flex: 1 1 100%; max-width: none; }
  .filters .span2 { grid-column: 1 / -1; }
  .filters > .btn { grid-column: 1 / -1; }
  .field select, .field input { width: 100%; height: 36px; font-size: 13px; }
  .field.narrow input { width: 100%; }
  .view { padding: 12px 12px 32px; }
  .viewtabs { width: calc(100% - 24px); }
  .viewtabs button { flex: 1; padding: 8px 6px; }
  .cards { grid-template-columns: 1fr; }
  .heat-wrap { padding: 12px; }
  .heat { grid-template-columns: minmax(68px, 84px) repeat(4, minmax(74px, 1fr)); gap: 4px; }
  .heat-axis { font-size: 9px; }
  .heat-cell { padding: 5px; min-height: 60px; border-radius: 8px; }
  .chip-name { font-size: 11.5px; }
  .chip-meta { font-size: 10px; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-body { padding: 18px 18px 24px; }
  .matrix { min-width: 760px; }
  .matrix tbody th { min-width: 130px; font-size: 12.5px; padding: 9px; }
  .matrix td { min-width: 122px; padding: 6px; }
}

/* ── print ──────────────────────────────────────────────── */
@media print {
  .topbar, .filters, .viewtabs, .footer, .btn, .link-btn { display: none !important; }
  body { background: #fff; }
  .panel, .card { box-shadow: none; }
  .matrix-scroll { max-height: none; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
