/* ========== БАЗА ========================================================== */
:root{
  --bg:#0b0c0f0a;          /* светлый фон страницы */
  --card:#ffffff;          /* фон карточек */
  --text:#0f172a;          /* основной текст */
  --muted:#64748b;         /* приглушённый текст */
  --line:#e5e7eb;          /* границы */
  --accent:#2563eb;        /* синий акцент */
  --accent-2:#1e40af;      /* тёмный акцент */
  --success:#16a34a;
  --danger:#dc2626;
  --warn:#a16207;

  --radius:12px;
  --shadow:0 6px 18px rgba(2,8,23,.06);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, "Noto Sans", Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:var(--bg);
}

/* Контейнер */
.container{
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

/* Заголовки */
.page-header h1{
  margin:0 0 6px;
  font-weight:700;
  font-size: clamp(20px, 2vw, 28px);
}
.subtle{color:var(--muted); margin:0 0 18px;}
.section-title{margin:18px 0 10px; font-size:18px}

/* Карточка */
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:16px;
  margin-bottom:14px;
  box-shadow: var(--shadow);
}

/* Ряд ввода */
.row{
  display:flex; gap:10px; align-items:center; flex-wrap:wrap;
}

/* Лейбл/подписи */
.label{display:block; font-weight:600; margin-bottom:6px}
.muted{color:var(--muted)}
.small{font-size:12px}
.dot{margin:0 6px; color:#cbd5e1}

/* Инпуты */
input[type="text"], textarea{
  flex:1;
  min-width:240px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fafafa;
  transition:border .15s, box-shadow .15s, background .15s;
}
textarea{width:100%; min-height:92px; resize:vertical}
input[type="text"]:focus, textarea:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background:#fff;
}

/* Чекбокс */
.checkbox{display:inline-flex; align-items:center; gap:8px; color:var(--muted)}

/* Кнопки */
.btn{
  --btn-bg:#f8fafc;
  --btn-br:var(--line);
  --btn-fg:#0f172a;
  appearance:none;
  border:1px solid var(--btn-br);
  background:var(--btn-bg);
  color:var(--btn-fg);
  padding:10px 14px;
  border-radius:10px;
  cursor:pointer;
  transition: transform .04s ease, background .15s, border .15s, color .15s;
}
.btn:hover{background:#eef2f7}
.btn:active{transform: translateY(1px)}

.btn--primary{
  --btn-bg: var(--accent);
  --btn-br: var(--accent);
  --btn-fg: #fff;
}
.btn--primary:hover{background:#2a57d9}

.btn--success{
  --btn-bg: var(--success); --btn-br: var(--success); --btn-fg:#fff;
}
.btn--danger{
  --btn-bg: var(--danger); --btn-br: var(--danger); --btn-fg:#fff;
}
.btn--ghost{
  --btn-bg: transparent; --btn-br: var(--line); --btn-fg: var(--text);
}
.actions{display:flex; gap:10px; flex-wrap:wrap; margin-top:8px}

/* Чипы / бейджи статусов */
.chip{display:inline-block; padding:3px 8px; border-radius:999px; font-size:12px; background:#eef2ff; color:#1e3a8a}
.badge{display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; background:#eef2ff; color:#1e3a8a}
.badge--ok{background:#e6ffed;color:#0a7a31}
.badge--wait{background:#fff6e6;color:#a65b00}
.badge--bad{background:#ffe6e6;color:#9a1a1a}
.token-status{margin-left:10px; font-weight:600; color:#b91c1c}

/* Информеры */
.notice{
  margin:10px 0;
  padding:12px 14px;
  border:1px solid var(--line);
  border-left:5px solid #94a3b8;
  border-radius:10px;
  background:#fcfcfd;
}
.notice.vin-result--ok{border-left-color: var(--success)}
.notice.vin-result--error{border-left-color: var(--danger)}
.summary{margin:8px 0 14px; font-weight:700}

/* Грид 2 колонки */
.grid-2{display:grid; grid-template-columns: 1fr 1.2fr; gap:14px}
@media (max-width: 1080px){ .grid-2{grid-template-columns:1fr}}

/* События */
.events{position:relative; padding-left:20px}
.events::before{content:""; position:absolute; left:8px; top:4px; bottom:4px; width:2px; background:var(--line)}
.event-item{
  position:relative; margin:0 0 10px; padding:8px 10px 8px 12px;
  border:1px solid var(--line); border-radius:10px; background:var(--card);
}
.event-item::before{
  content:""; position:absolute; left:-15px; top:14px; width:10px; height:10px;
  border-radius:50%; background:#64748b; box-shadow:0 0 0 3px #fff;
}
.event-head{display:flex; gap:8px; flex-wrap:wrap; font-size:13px; color:var(--muted)}
.event-title{color:var(--text); font-weight:600}
.events-empty{padding:10px; color:var(--muted); border:1px dashed var(--line); border-radius:10px; background:#f8fafc}

/* Таблица */
.table-wrap{overflow:auto; background:var(--card); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow)}
.table{width:100%; border-collapse:collapse; min-width:720px}
.table th, .table td{padding:10px 12px; border-bottom:1px solid var(--line); text-align:left; vertical-align:top}
.table thead th{position:sticky; top:0; background:#f8fafc; z-index:1; font-weight:700; font-size:13px}
.table tbody tr:nth-child(odd){background:#fcfcff}
.match{background:#ecfdf5 !important}
.mismatch{background:#fff1f2 !important}
.highlight-error-row{background:#ffe0b2 !important; box-shadow: 0 0 0 2px #ffd699 inset}

/* Фото */
.grid-photos{display:grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap:10px; margin-top:8px}
.photo-thumb, .grid-photos img{
  width:100%; aspect-ratio: 4 / 3; object-fit: cover;
  background:#f1f5f9; border:1px solid var(--line); border-radius:10px; cursor:zoom-in; transition: transform .12s ease
}
.grid-photos img:hover{transform:scale(1.02)}

/* Модалка */
.modal{position:fixed; inset:0; z-index:9999}
.modal__backdrop{position:absolute; inset:0; background:rgba(0,0,0,.55)}
.modal__content{
  position:absolute; inset:5% 8%;
  background:#0b0b0b; border-radius:14px; padding:10px;
  display:grid; grid-template-rows:auto 1fr auto; gap:6px;
  box-shadow: 0 15px 45px rgba(0,0,0,.45);
}
.modal__close{
  position:absolute; top:8px; right:10px;
  background:#1f2937; color:#fff; border:1px solid #374151;
  border-radius:8px; width:36px; height:36px; cursor:pointer; font-size:20px;
}
#photoModalImg{width:100%; height:100%; object-fit:contain; background:#000}
.modal__controls{display:flex; align-items:center; justify-content:center; gap:10px; color:#fff}

/* Ошибочная панель (аккордеон) */
.error-bar{
  border:1px solid #fecaca; background:#fff5f5; border-left:6px solid var(--danger);
  border-radius:12px; margin:14px 0; box-shadow:var(--shadow)
}
.error-bar__toggle{
  width:100%; text-align:left; border:0; background:transparent; padding:14px 16px; cursor:pointer; font-weight:700; color:#7f1d1d
}
.error-bar__body{padding: 0 16px 14px}
.hint{
  background:#fff8f1; border:1px solid #ffe4c7; color:#a16207;
  padding:8px 10px; border-radius:8px; margin-bottom:8px; font-size:13px; font-style:italic
}
.error-bar a{color:#991b1b; text-decoration:none; border-bottom:1px dashed #fecaca}
.error-bar a:hover{background:#ef4444; color:#fff; border-bottom-color:#ef4444}

/* Адаптив */
@media (max-width:720px){
  .modal__content{inset:6% 4%}
}

/* Тёмная тема (если у пользователя системная) */
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0b0f16;
    --card:#0f1320;
    --text:#e5e7eb;
    --muted:#94a3b8;
    --line:#1f2937;
    --accent:#3b82f6;
    --accent-2:#2563eb;
    --shadow:0 10px 30px rgba(0,0,0,.4);
  }
  .table thead th{background:#0c1220}
  .grid-photos img, .photo-thumb{background:#0b0f16}
  .events::before{background:#243142}
  .events-empty{background:#0c1220; border-color:#1f2937}
  .notice{background:#0c1220}
}

photo-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 120px;          /* <- важный fallback, чтобы IO видел элемент */
  object-fit: cover;
  border-radius: 8px;
  background: #f2f2f2;
  border: 1px solid #e5e7eb;
  transition: transform .15s;
  cursor: zoom-in;
}