:root {
  --ink: #17191d;
  --muted: #6c727c;
  --line: #dfe2e7;
  --soft: #f4f5f7;
  --paper: #fff;
  --accent: #e44b31;
  --accent-soft: #fff0ec;
  --green: #247a52;
  --shadow: 0 18px 55px rgba(20, 24, 31, .14);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--soft); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 68px;
  padding: 10px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; background: var(--ink); color: #fff; font-size: 20px; font-weight: 900; }
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand strong { letter-spacing: .11em; font-size: 14px; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.header-status { display: grid; justify-self: center; text-align: center; }
.header-status strong { font-size: 13px; }
.header-status span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.header-actions, .toolbar-actions { display: flex; align-items: center; gap: 8px; }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  transition: background .15s, border-color .15s, transform .15s;
}
.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; height: 17px; }
.button.dark { background: var(--ink); color: #fff; }
.button.secondary { border-color: var(--line); }
.button.secondary:hover, .button.ghost:hover { border-color: #b7bbc2; background: #fafafa; }
.button.ghost { min-height: 38px; border-color: var(--line); background: transparent; font-size: 13px; }
.button.wide { width: 100%; min-height: 50px; }
.button.is-loading svg { animation: spin .85s linear infinite; }
.counter { display: grid; min-width: 22px; height: 22px; place-items: center; border-radius: 99px; background: #fff; color: var(--ink); font-size: 12px; }
.counter.muted { background: var(--soft); }
.button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace { width: min(1600px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 80px; }
.workspace-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.section-label { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.workspace-title h1 { margin: 7px 0 5px; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.045em; line-height: 1; }
.workspace-title p, .selection-heading p { margin: 0; color: var(--muted); }
.payment-setting { min-width: 290px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.payment-setting > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.payment-setting > strong { display: block; font-size: 17px; }
.payment-setting small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.photo-mode-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; padding: 14px 16px; border: 1px solid #d9c373; border-radius: 12px; background: #fff9df; }
.photo-mode-banner > div { display: flex; align-items: center; gap: 10px; }
.photo-mode-banner strong { font-size: 14px; }
.photo-mode-banner span { color: #6c603b; font-size: 11px; }
.pipeline-heading { min-width: 0; }
.pipeline-actions { flex: 0 0 auto; }
.pipeline-actions label { display: flex; align-items: center; gap: 6px; }
.pipeline-actions select { height: 34px; padding: 0 9px; border: 1px solid #d9c373; border-radius: 7px; background: #fff; color: var(--ink); font-size: 11px; }
.money-input { display: flex; align-items: center; border: 1px solid #cfd3d9; border-radius: 8px; background: #fff; }
.money-input:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,25,29,.07); }
.money-input input { width: 100%; min-width: 0; padding: 9px 5px 9px 10px; border: 0; outline: 0; background: transparent; font-weight: 750; }
.money-input span { padding-right: 10px; color: var(--muted); }

.filter-panel {
  display: grid;
  grid-template-columns: minmax(230px, 1.6fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.field { display: grid; gap: 5px; }
.field > span, .sort-field > span { padding-left: 2px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.field select, .field input, .sort-field select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fff; color: var(--ink); }
.field select:focus, .field input:focus, .sort-field select:focus { border-color: #969ca6; box-shadow: 0 0 0 3px rgba(23,25,29,.06); }
.search-field > div { position: relative; }
.search-field svg { position: absolute; top: 12px; left: 11px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 37px; }
.extra-filter { display: none; }
.filter-panel.expanded .extra-filter { display: grid; }
.filter-toggle { align-self: end; border-color: var(--line); }
.filter-panel.expanded .filter-toggle span { display: none; }

.catalog-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 18px 2px 10px; }
.catalog-toolbar > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 9px; }
.catalog-toolbar strong { font-size: 16px; }
.catalog-toolbar #last-updated { color: var(--muted); font-size: 11px; }
.link-button { display: none; padding: 0; border: 0; background: none; color: var(--accent); font-size: 12px; text-decoration: underline; }
.link-button.visible { display: inline; }
.sort-field { display: grid; gap: 4px; min-width: 190px; }
.sort-field select { height: 38px; }

.catalog-list { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.catalog-head, .catalog-row {
  display: grid;
  grid-template-columns: minmax(265px, 1.35fr) 125px minmax(185px, .9fr) 135px minmax(390px, 1.75fr) 36px;
  gap: 14px;
  align-items: center;
}
.catalog-head { min-height: 40px; padding: 0 14px; border-bottom: 1px solid var(--line); background: #fafafa; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.catalog-row { position: relative; min-height: 112px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .13s; }
.catalog-row:last-child { border-bottom: 0; }
.catalog-row:hover { background: #fafafa; }
.catalog-row.is-new::before { position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--accent); content: ""; }
.car-identity { display: grid; grid-template-columns: 116px 1fr; align-items: center; gap: 13px; min-width: 0; }
.car-photo { position: relative; overflow: hidden; width: 116px; height: 86px; border-radius: 9px; background: #eceef1; }
.car-photo img { width: 100%; height: 100%; object-fit: cover; }
.car-photo.placeholder img { opacity: .25; object-fit: contain; }
.new-badge { position: absolute; top: 5px; left: 5px; padding: 3px 6px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.car-name { min-width: 0; }
.car-name h3 { overflow: hidden; margin: 0 0 5px; font-size: 17px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.car-trim { display: flex; min-width: 0; align-items: baseline; gap: 5px; margin-bottom: 7px; }
.car-trim span { color: var(--muted); font-size: 8px; font-weight: 750; text-transform: uppercase; }
.car-trim strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.car-name small { color: var(--muted); font-size: 10px; }
.car-meta-links { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; }
.source-row-link { position: relative; z-index: 1; color: var(--accent); font-size: 10px; text-decoration: none; white-space: nowrap; }
.source-row-link:hover { text-decoration: underline; }
.year-mileage { display: grid; gap: 7px; }
.year-mileage span { color: var(--muted); font-size: 11px; }
.year-mileage strong { font-size: 16px; }
.mileage-value { display: inline-flex; width: max-content; align-items: center; gap: 5px; padding: 5px 7px; border-radius: 6px; background: #eef4f1; color: var(--green); }
.mileage-value::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.row-specs { display: grid; gap: 5px; color: #3d424a; font-size: 11px; line-height: 1.25; }
.row-specs strong { color: var(--ink); font-size: 12px; }
.row-price { display: grid; gap: 5px; }
.row-price strong { font-size: 18px; }
.row-price span { color: var(--muted); font-size: 10px; }
.photo-row-button { position: relative; z-index: 1; width: max-content; padding: 5px 7px; border: 1px solid #d9c373; border-radius: 6px; background: #fff9df; color: #6c603b; font-size: 10px; font-weight: 750; }
.photo-row-button.approved, .photo-row-button.review { border-color: #b9d8c8; background: #eef8f3; color: var(--green); }
.photo-row-button.processing, .photo-row-button.queued { border-color: #b9cee3; background: #edf5fc; color: #28648f; }
.photo-row-button.failed { border-color: #e5b8af; background: var(--accent-soft); color: var(--accent); }
.row-payments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-payment { min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.mini-payment > span { display: flex; justify-content: space-between; gap: 3px; color: var(--muted); font-size: 9px; }
.mini-payment strong { display: block; margin-top: 5px; font-size: 12px; white-space: nowrap; }
.mini-payment small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.mini-payment.unavailable { display: grid; place-items: center; color: var(--muted); font-size: 10px; text-align: center; }
.favorite-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 19px; }
.favorite-button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.empty-state { display: grid; min-height: 250px; place-items: center; align-content: center; gap: 6px; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 20px; }
.load-more-wrap { display: flex; justify-content: center; padding-top: 18px; }

.modal { position: fixed; z-index: 50; inset: 0; display: none; align-items: center; justify-content: center; padding: 22px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 18, 22, .58); backdrop-filter: blur(5px); }
.car-panel, .selection-panel, .history-panel, .photo-review-panel { position: relative; overflow: auto; width: min(1060px, 100%); max-height: calc(100vh - 44px); padding: 24px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.modal-close { position: absolute; z-index: 2; top: 13px; right: 13px; display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 25px; line-height: 1; }
.car-detail-main { display: grid; grid-template-columns: 360px 1fr; align-items: start; gap: 25px; padding-right: 35px; }
.detail-gallery { min-width: 0; }
.detail-media { position: relative; overflow: hidden; height: 230px; border-radius: 12px; background: #eceef1; }
.gallery-main { width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-media span { position: absolute; bottom: 9px; left: 9px; padding: 5px 8px; border-radius: 6px; background: rgba(255,255,255,.92); color: var(--green); font-size: 10px; font-weight: 750; }
.detail-media .gallery-count { right: 9px; left: auto; color: var(--ink); }
.gallery-arrow { position: absolute; z-index: 2; top: 50%; display: grid; width: 34px; height: 42px; place-items: center; padding: 0 0 4px; border: 0; border-radius: 8px; background: rgba(255,255,255,.9); color: var(--ink); font-size: 30px; line-height: 1; transform: translateY(-50%); }
.gallery-arrow.previous { left: 8px; }
.gallery-arrow.next { right: 8px; }
.gallery-thumbnails { display: flex; overflow-x: auto; gap: 6px; margin-top: 7px; padding-bottom: 2px; scrollbar-width: thin; }
.gallery-thumbnail { flex: 0 0 58px; overflow: hidden; width: 58px; height: 43px; padding: 0; border: 2px solid transparent; border-radius: 7px; background: #eceef1; }
.gallery-thumbnail.active { border-color: var(--accent); }
.gallery-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.detail-heading { align-self: center; }
.detail-heading > span { color: var(--muted); font-size: 12px; }
.detail-heading h2 { margin: 7px 0 4px; font-size: 31px; letter-spacing: -.035em; }
.detail-heading p { margin: 0 0 20px; color: var(--muted); }
.detail-trim { display: grid; gap: 3px; }
.detail-trim span { font-size: 9px; font-weight: 750; text-transform: uppercase; }
.detail-trim strong { color: var(--ink); font-size: 14px; }
.detail-heading > strong { display: block; margin-bottom: 15px; font-size: 26px; }
.detail-heading a { color: var(--accent); font-size: 12px; }
.detail-specs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 18px; }
.detail-specs > div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.detail-specs span, .detail-specs strong { display: block; }
.detail-specs span { margin-bottom: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.detail-specs strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.detail-calculator { margin: 20px 0 16px; padding: 17px; border-radius: 12px; background: var(--soft); }
.calculator-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 25px; margin-bottom: 14px; }
.calculator-heading > div { display: grid; }
.calculator-heading > div > span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.calculator-heading > div > strong { margin-top: 3px; font-size: 20px; }
.calculator-heading > div > small { color: var(--muted); font-size: 9px; }
.calculator-heading label { width: 260px; }
.calculator-heading label > span { display: block; margin-bottom: 5px; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.calculator-heading label > small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }
.payment-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.payment-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.payment-table th, .payment-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; }
.payment-table th:first-child, .payment-table td:first-child { text-align: left; }
.payment-table th { background: #fafafa; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.payment-table td { font-size: 12px; }
.payment-table td strong { font-size: 14px; }
.payment-table tr:last-child td { border-bottom: 0; }
.payment-table .unavailable-row td { color: var(--muted); text-align: left; }
.calculator-note { margin: 10px 0 0; color: var(--muted); font-size: 10px; }
.modal-actions { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 9px; }
.modal-actions .button { min-height: 50px; }
.button.telegram { background: #229ed9; color: #fff; }
.button.telegram:hover { background: #178dc5; }

.lightbox { position: fixed; z-index: 100; inset: 0; display: none; align-items: center; justify-content: center; padding: 30px 74px; }
.lightbox.open { display: flex; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(5,7,10,.94); }
.lightbox figure { position: relative; z-index: 1; display: grid; max-width: min(1540px, 100%); max-height: 100%; justify-items: center; gap: 10px; margin: 0; }
.lightbox img { display: block; max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; }
.lightbox figcaption { color: #fff; font-size: 12px; }
.lightbox-close { position: absolute; z-index: 3; top: 18px; right: 18px; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; background: rgba(0,0,0,.35); color: #fff; font-size: 29px; }
.lightbox-arrow { position: absolute; z-index: 3; top: 50%; display: grid; width: 48px; height: 64px; place-items: center; padding: 0 0 6px; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; background: rgba(0,0,0,.35); color: #fff; font-size: 42px; transform: translateY(-50%); }
.lightbox-arrow.previous { left: 16px; }
.lightbox-arrow.next { right: 16px; }

.selection-panel { width: min(1200px, 100%); }
.selection-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-right: 42px; }
.selection-heading h2 { margin: 5px 0; font-size: 32px; }
.selection-list { display: grid; gap: 8px; margin: 20px 0; }
.selection-item { display: grid; grid-template-columns: 80px minmax(180px, 1.2fr) 110px 125px minmax(290px, 1.5fr) 34px; align-items: center; gap: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.selection-item img { width: 80px; height: 58px; border-radius: 7px; object-fit: cover; background: #eee; }
.selection-item > div { display: grid; gap: 3px; }
.selection-item small { color: var(--muted); font-size: 10px; }
.selection-item .row-payments { min-width: 0; }
.selection-remove { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 20px; }
.selection-empty { display: grid; min-height: 200px; place-items: center; align-content: center; color: var(--muted); }
.selection-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.selection-footer > span { font-size: 13px; }

.history-panel { width: min(1120px, 100%); }
.history-heading, .photo-review-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding-right: 42px; }
.history-heading h2, .photo-review-heading h2 { margin: 5px 0; font-size: 32px; }
.history-heading p, .photo-review-heading p { margin: 0; color: var(--muted); }
.history-stats { display: flex; gap: 8px; }
.history-stats span { display: grid; min-width: 92px; gap: 2px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 10px; }
.history-stats strong { color: var(--ink); font-size: 19px; }
.history-filters { display: flex; gap: 6px; margin: 20px 0 12px; }
.history-filters button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 11px; }
.history-filters button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.history-list { display: grid; gap: 7px; }
.history-item { display: grid; grid-template-columns: 86px minmax(220px, 1.3fr) minmax(150px, .8fr) 125px 110px; align-items: center; gap: 12px; padding: 9px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; }
.history-item.added { border-left-color: var(--green); }
.history-item.returned { border-left-color: #3978ac; }
.history-item.removed { border-left-color: var(--accent); background: #fffafa; }
.history-item > img { width: 86px; height: 64px; border-radius: 7px; background: #eee; object-fit: cover; }
.history-car, .history-price { display: grid; min-width: 0; gap: 4px; }
.history-car > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item small, .history-item time { color: var(--muted); font-size: 10px; }
.history-event-label { width: max-content; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.history-item.added .history-event-label { color: var(--green); }
.history-item.returned .history-event-label { color: #3978ac; }
.history-item .button { min-height: 34px; padding: 0 9px; font-size: 10px; text-decoration: none; }
.history-empty { display: grid; min-height: 220px; place-items: center; align-content: center; gap: 6px; color: var(--muted); }

.photo-review-panel { width: min(1180px, 100%); }
.photo-job-status { padding: 8px 11px; border-radius: 8px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 750; }
.photo-job-status.approved, .photo-job-status.review { background: #eef8f3; color: var(--green); }
.photo-job-status.processing, .photo-job-status.queued { background: #edf5fc; color: #28648f; }
.photo-job-status.failed { background: var(--accent-soft); color: var(--accent); }
.photo-review-note { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; padding: 10px 12px; border-radius: 9px; background: #fff9df; color: #6c603b; font-size: 11px; }
.photo-review-note strong { white-space: nowrap; }
.photo-review-note.configuration-required { border: 1px solid #e5b8af; background: var(--accent-soft); color: #8e3728; }
.pipeline-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 18px 0 12px; padding: 0; list-style: none; }
.pipeline-steps li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 10px; }
.pipeline-steps b { display: grid; flex: 0 0 23px; width: 23px; height: 23px; place-items: center; border-radius: 50%; background: var(--soft); }
.pipeline-steps li.active { border-color: #9eb9d0; background: #edf5fc; color: #28648f; }
.pipeline-steps li.complete { border-color: #b9d8c8; background: #eef8f3; color: var(--green); }
.pipeline-steps li.active b, .pipeline-steps li.complete b { background: currentColor; color: #fff; }
.photo-review-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; color: var(--muted); font-size: 11px; }
.photo-review-tools > div { display: grid; gap: 3px; }
.photo-review-tools strong { color: var(--ink); font-size: 13px; }
.photo-review-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.photo-review-card { position: relative; overflow: hidden; min-width: 0; border: 2px solid #b9d8c8; border-radius: 9px; background: var(--soft); }
.photo-review-card.excluded { border-color: #e5b8af; background: var(--accent-soft); }
.photo-review-card.excluded img { opacity: .28; filter: grayscale(1); }
.photo-review-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-review-card > div { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 7px 8px; }
.photo-review-card strong { font-size: 10px; }
.photo-review-card button, .photo-comparison > button { padding: 4px 6px; border: 1px solid #e5b8af; border-radius: 5px; background: #fff; color: var(--accent); font-size: 9px; font-weight: 750; }
.photo-review-card.excluded button { border-color: #b9d8c8; color: var(--green); }
.excluded-label { position: absolute; inset: 0 0 35px; display: grid; place-items: center; color: #8e3728; font-size: 10px; font-weight: 800; text-align: center; pointer-events: none; }
.photo-comparison-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo-comparison { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 2px solid #b9d8c8; border-radius: 10px; background: var(--soft); }
.photo-comparison.excluded { border-color: #e5b8af; opacity: .55; }
.photo-comparison > div { position: relative; min-width: 0; }
.photo-comparison img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-comparison > div > span { position: absolute; z-index: 1; top: 7px; left: 7px; padding: 4px 6px; border-radius: 5px; background: rgba(255,255,255,.9); font-size: 9px; font-weight: 750; }
.photo-comparison > button { grid-column: 1 / -1; margin: 7px; justify-self: end; }
.avito-copy-stage { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.avito-copy-stage > div { display: grid; gap: 3px; }
.avito-copy-stage > div span { color: var(--muted); font-size: 10px; }
.avito-copy-stage textarea { grid-column: 1 / -1; width: 100%; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fff; color: var(--ink); font: 12px/1.5 inherit; }
.avito-copy-stage textarea:focus { border-color: #969ca6; box-shadow: 0 0 0 3px rgba(23,25,29,.06); }
.photo-review-footer { position: sticky; bottom: -24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 16px -24px -24px; padding: 13px 24px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.photo-review-footer > span { color: var(--muted); font-size: 11px; }
.photo-review-footer > div { display: flex; gap: 7px; }
.photo-review-footer a { text-decoration: none; }

.toast { position: fixed; z-index: 80; right: 22px; bottom: 22px; display: grid; min-width: 290px; max-width: 420px; gap: 3px; padding: 13px 15px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast span { color: #c5c8ce; font-size: 11px; }
.modal-open { overflow: hidden; }

@media (min-width: 1181px) {
  .filter-panel.expanded { grid-template-columns: minmax(230px, 1.6fr) repeat(4, minmax(150px, 1fr)); }
  .filter-panel.expanded .filter-toggle { display: inline-flex; }
}

@media (max-width: 1350px) {
  .catalog-head, .catalog-row { grid-template-columns: minmax(250px, 1.35fr) 120px 150px 125px minmax(350px, 1.7fr) 36px; gap: 10px; }
  .row-specs .secondary-spec { display: none; }
}

@media (max-width: 1180px) {
  .filter-panel, .filter-panel.expanded { grid-template-columns: repeat(3, 1fr); }
  .filter-toggle { display: inline-flex !important; }
  .catalog-head, .catalog-row { grid-template-columns: minmax(240px, 1.4fr) 120px 125px minmax(340px, 1.8fr) 36px; }
  .catalog-head span:nth-child(3), .row-specs { display: none; }
  .detail-specs { grid-template-columns: repeat(4, 1fr); }
  .photo-review-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
  .app-header { grid-template-columns: auto 1fr; }
  .header-status { display: none; }
  .header-actions { justify-self: end; }
  .header-actions .button span:not(.counter) { display: none; }
  #photo-mode-button::after { content: "Фото"; }
  .workspace-title { align-items: stretch; }
  .payment-setting { min-width: 245px; }
  .catalog-head { display: none; }
  .catalog-row { grid-template-columns: minmax(250px, 1.5fr) 120px 125px 36px; }
  .row-payments { grid-column: 1 / -1; }
  .car-detail-main { grid-template-columns: 300px 1fr; }
  .detail-specs { grid-template-columns: repeat(3, 1fr); }
  .selection-item { grid-template-columns: 70px 1fr 100px 34px; }
  .selection-item img { width: 70px; }
  .selection-item .row-payments { grid-column: 1 / -1; }
  .modal-actions { grid-template-columns: 1fr 1fr; }
  .modal-actions .telegram { grid-column: 1 / -1; }
  .history-item { grid-template-columns: 74px 1fr 130px 100px; }
  .history-item > img { width: 74px; height: 56px; }
  .history-item .button { grid-column: 2 / -1; width: max-content; }
  .photo-review-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-comparison-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-header { min-height: 62px; padding: 8px 12px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .header-actions .button { min-height: 36px; padding: 0 10px; }
  .workspace { width: min(100% - 20px, 1600px); padding: 22px 0 60px; }
  .workspace-title { display: grid; gap: 16px; }
  .workspace-title h1 { font-size: 34px; }
  .payment-setting { min-width: 0; }
  .photo-mode-banner, .photo-mode-banner > div { align-items: stretch; flex-direction: column; }
  .filter-panel, .filter-panel.expanded { grid-template-columns: repeat(2, 1fr); padding: 10px; }
  .search-field { grid-column: 1 / -1; }
  .filter-toggle { grid-column: 1 / -1; }
  .catalog-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { justify-content: space-between; }
  .sort-field { flex: 1; min-width: 0; }
  .catalog-list { overflow: visible; border: 0; background: transparent; }
  #car-grid { display: grid; gap: 10px; }
  .catalog-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .car-identity { grid-column: 1 / -1; grid-template-columns: 112px 1fr; }
  .car-photo { width: 112px; height: 84px; }
  .year-mileage { grid-column: 1; grid-template-columns: auto 1fr; align-items: center; }
  .year-mileage > span { display: none; }
  .row-price { grid-column: 1; }
  .favorite-button { position: absolute; top: 12px; right: 12px; }
  .row-payments { grid-column: 1 / -1; }
  .mini-payment { padding: 7px 6px; }
  .mini-payment strong { font-size: 11px; }
  .modal { padding: 0; align-items: flex-end; }
  .car-panel, .selection-panel, .history-panel, .photo-review-panel { width: 100%; max-height: 94vh; padding: 18px 14px; border-radius: 16px 16px 0 0; }
  .car-detail-main { display: grid; grid-template-columns: 1fr; gap: 14px; padding-right: 0; }
  .detail-media { height: 210px; }
  .gallery-thumbnail { flex-basis: 64px; width: 64px; height: 48px; }
  .detail-heading h2 { font-size: 26px; }
  .detail-specs { grid-template-columns: repeat(2, 1fr); }
  .calculator-heading { align-items: stretch; flex-direction: column; gap: 12px; }
  .calculator-heading label { width: 100%; }
  .modal-actions { grid-template-columns: 1fr; }
  .lightbox { padding: 54px 10px 30px; }
  .lightbox-arrow { top: auto; bottom: 18px; width: 44px; height: 44px; transform: none; }
  .lightbox-arrow.previous { left: calc(50% - 52px); }
  .lightbox-arrow.next { right: calc(50% - 52px); }
  .lightbox img { max-height: calc(100vh - 120px); }
  .lightbox figcaption { padding-bottom: 50px; }
  .selection-heading { align-items: flex-start; flex-direction: column; }
  .selection-item { grid-template-columns: 64px 1fr 30px; }
  .selection-item img { width: 64px; height: 50px; }
  .selection-item > .year-mileage, .selection-item > .row-price { display: none; }
  .selection-item .row-payments { grid-column: 1 / -1; }
  .selection-footer { align-items: stretch; flex-direction: column; }
  .selection-footer .button { width: 100%; }
  .history-heading, .photo-review-heading { align-items: flex-start; flex-direction: column; padding-right: 38px; }
  .history-heading h2, .photo-review-heading h2 { font-size: 26px; }
  .history-stats { width: 100%; }
  .history-stats span { flex: 1; }
  .history-filters { overflow-x: auto; }
  .history-filters button { flex: 0 0 auto; }
  .history-item { grid-template-columns: 72px 1fr; }
  .history-item > img { width: 72px; height: 56px; }
  .history-item .history-price, .history-item time { grid-column: 2; }
  .history-item .button { grid-column: 2; }
  .photo-review-note { align-items: flex-start; flex-direction: column; }
  .photo-review-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline-steps { grid-template-columns: repeat(2, 1fr); }
  .photo-review-footer { bottom: -18px; align-items: stretch; flex-direction: column; margin: 14px -14px -18px; padding: 12px 14px; }
  .photo-review-footer > div { display: grid; grid-template-columns: 1fr 1fr; }
  .photo-review-footer .button { width: 100%; padding: 0 8px; }
  #prepare-selected-photos, #approve-listing { grid-column: 1 / -1; }
  .toast { right: 10px; bottom: 10px; left: 10px; min-width: 0; }
}

@media (max-width: 430px) {
  .brand > span:last-child { display: none; }
  .header-actions { gap: 5px; }
  .header-actions .button { padding: 0 8px; font-size: 11px; }
  #history-button { font-size: 0; }
  #history-button::before { content: "История"; font-size: 11px; }
  #selection-button { font-size: 0; }
  #selection-button::before { content: "Выбор"; font-size: 11px; }
  .counter { font-size: 10px; }
}
