/* ==== Базовое ==== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  color: #0f172a;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e0f2fe 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 100%, #eef2ff 0%, transparent 50%),
    #f8fafc;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: linear-gradient(180deg, #0b1220 0%, #0e1830 100%);
  color: #e2e8f0; position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 8px 24px rgba(2,6,23,.18);
}
.topbar h1 {
  font-size: 16px; font-weight: 600; letter-spacing: .02em; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #22d3ee; box-shadow: 0 0 12px #22d3ee;
}
.topbar select {
  padding: 6px 10px; background: rgba(255,255,255,.06); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.14); border-radius: 8px;
  font-size: 13px; outline: none;
}
.topbar select:focus { border-color: #22d3ee; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 20px 40px; }

/* ==== Фильтры ==== */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.04);
  margin-bottom: 16px;
}
.filters select,
.filters input,
.filters button {
  height: 38px; padding: 0 12px; border: 1px solid #e2e8f0;
  border-radius: 10px; font-size: 14px; background: #fff;
  color: #0f172a; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.filters select:focus,
.filters input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* Поле поиска программы — шире, тянется */
.filters input#canProgram {
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 320px;
  padding-left: 34px;
  background: #f8fafc url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 10px center;
  background-size: 16px 16px;
  font-variant-numeric: tabular-nums;
}
.filters input#canProgram::placeholder { color: #94a3b8; }

.filters button {
  cursor: pointer;
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #fff; border-color: #4f46e5; font-weight: 500;
}
.filters button:hover { background: linear-gradient(180deg, #4f46e5, #4338ca); }

.status {
  color: #64748b; min-height: 20px; margin-bottom: 10px;
  font-size: 13px; padding-left: 4px;
}

/* ==== Сетка карточек ==== */
.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  position: relative; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 14px; padding: 14px 16px 12px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  display: flex; flex-direction: column; gap: 10px; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, #6366f1, #22d3ee);
  opacity: 0; transition: opacity .15s;
}
.card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 10px 24px -12px rgba(99,102,241,.35), 0 2px 6px rgba(15,23,42,.05);
  transform: translateY(-2px);
}
.card:hover::before { opacity: 1; }

.card header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.card-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title strong {
  font-size: 15px; line-height: 1.25; color: #0f172a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-year { font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; }

.card-badges { display: flex; gap: 6px; flex-shrink: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; min-width: 26px; padding: 0 8px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.badge svg { display: block; }

.badge-params { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.badge-params.badge-empty { background: #f1f5f9; border-color: #e2e8f0; color: #94a3b8; }

.badge-can { background: #eef2ff; border-color: #c7d2fe; color: #4338ca; }
.badge-can.badge-empty { background: #f1f5f9; border-color: #e2e8f0; color: #94a3b8; }

/* ==== Строка программы в карточке ==== */
.card-prog {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; margin-top: auto; padding-top: 4px;
}
.card-prog-label { color: #64748b; white-space: nowrap; }
.card-prog-value {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 600; color: #3730a3; font-variant-numeric: tabular-nums;
  padding: 2px 9px; background: #eef2ff; border: 1px solid #e0e7ff;
  border-radius: 6px; line-height: 1.4;
}
.card-prog-value svg { opacity: .7; flex-shrink: 0; }

.detail-prog { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 12px; }

/* ==== Модальное окно ==== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  animation: modal-fade .18s ease-out;
}
.modal.hidden { display: none; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  position: relative; background: #fff; border-radius: 16px;
  max-width: 920px; width: 100%; padding: 28px 32px 32px;
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .35), 0 8px 24px rgba(15, 23, 42, .12);
  animation: modal-pop .2s ease-out;
}
@keyframes modal-pop {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

#closeModal {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  font-size: 20px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
#closeModal:hover { background: #f1f5f9; color: #0f172a; border-color: #cbd5e1; }

.modal-content h2 { margin: 0 24px 12px 0; font-size: 20px; color: #0f172a; }
.modal-content h3 { margin: 22px 0 10px; font-size: 15px; color: #0f172a; }
.modal-content p { margin: 6px 0; color: #334155; }

.modal-content .btn {
  display: inline-block; margin-top: 8px; padding: 9px 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #fff; text-decoration: none; font-weight: 500; font-size: 14px;
}
.modal-content .btn:hover { background: linear-gradient(180deg, #4f46e5, #4338ca); }

.detail-photo {
  margin: -8px 0 16px; border-radius: 12px; overflow: hidden;
  border: 1px solid #e2e8f0; background: #f8fafc;
}
.detail-photo img { display: block; width: 100%; height: auto; }

.schemas-block {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin: 8px 0 4px;
}
.schema-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border: 1px solid #e2e8f0; border-radius: 10px;
  text-decoration: none; color: #334155; font-size: 12px; background: #fff;
  transition: border-color .15s, box-shadow .15s; overflow: hidden;
}
.schema-item:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 16px -8px rgba(99,102,241,.4);
}
.schema-item img {
  width: 100%; height: 110px; object-fit: cover;
  border-radius: 6px; background: #f1f5f9;
}
.schema-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schema-pdf { align-items: center; text-align: center; }
.pdf-icon {
  width: 100%; height: 110px; border-radius: 6px;
  background: linear-gradient(180deg, #fee2e2, #fecaca);
  color: #b91c1c; font-weight: 700; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .05em;
}

.params {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px; margin-bottom: 4px;
}
.param-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  background: #f8fafc; border: 1px solid #eef2f7; font-size: 13px;
}
.param-icon { display: inline-flex; color: #4f46e5; flex-shrink: 0; }
.param-name { color: #0f172a; }

.warn {
  color: #b45309; background: #fffbeb; border: 1px solid #fde68a;
  padding: 8px 12px; border-radius: 8px; font-size: 13px;
}

.can-data { margin-top: 20px; padding-top: 6px; border-top: 1px solid #e2e8f0; }
.can-title { margin: 8px 0 6px; font-size: 15px; }
.can-title a { color: #4f46e5; text-decoration: none; }
.can-title a:hover { text-decoration: underline; }
.can-title .ext { font-size: 12px; opacity: .7; }
.can-equipment { font-size: 13px; color: #64748b; margin-bottom: 10px; }

.bus {
  border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 10px 12px; margin: 8px 0; background: #fcfdff;
}
.bus-name {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: #0f172a; font-size: 14px; margin-bottom: 4px;
}
.bus-name svg { color: #4f46e5; }
.bus-location { font-size: 12px; color: #64748b; margin-bottom: 8px; }
table.wires { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
table.wires td { padding: 4px 6px; border-bottom: 1px dashed #e2e8f0; }
table.wires tr:last-child td { border-bottom: none; }
.wire-name { color: #334155; }
.wire-pin {
  text-align: right; font-variant-numeric: tabular-nums;
  color: #4338ca; font-weight: 600; white-space: nowrap;
}

.images { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.thumb {
  display: block; width: 84px; height: 64px; border-radius: 8px;
  overflow: hidden; border: 1px solid #e2e8f0; background: #f1f5f9;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.scheme { font-size: 13px; color: #334155; margin-top: 6px; }
.scheme a { color: #4f46e5; text-decoration: none; }
.scheme a:hover { text-decoration: underline; }

.func-title { margin: 16px 0 6px; font-size: 14px; }
table.functions { width: 100%; border-collapse: collapse; font-size: 13px; }
table.functions td { padding: 5px 8px; border-bottom: 1px solid #eef2f7; }
table.functions .fname { color: #334155; }
table.functions .fon {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.functions tr.yes .fon { color: #047857; font-weight: 600; }
table.functions tr.no  .fon { color: #94a3b8; }

.support-block {
  margin-top: 22px; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(180deg, #eef2ff, #e0e7ff);
  border: 1px solid #c7d2fe;
}
.support-block h3 { margin-top: 0; }
.support-block p { color: #3730a3; }

.equipment-links {
  margin-top: 22px; padding-top: 14px; border-top: 1px solid #e2e8f0;
}
.equipment-links ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.equipment-links li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px;
  background: #f8fafc; transition: border-color .15s, background .15s;
}
.equipment-links li:hover { border-color: #c7d2fe; background: #fff; }
.equipment-links a { color: #4f46e5; text-decoration: none; font-weight: 500; font-size: 14px; }
.equipment-links a:hover { text-decoration: underline; }
.equipment-links small { color: #64748b; font-size: 12px; }

.empty {
  grid-column: 1 / -1; text-align: center; color: #64748b;
  padding: 40px 0; font-size: 14px;
}