:root {
  font-family: "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
  color: #edf1ff;
  background: #121727;
  --surface: #1a2134;
  --raised: #242d46;
  --line: #34405e;
  --muted: #a9b5d0;
  --accent: #ae9aff;
  --accent-hover: #c7baff;
}
* { box-sizing: border-box; }
body { min-height: 100vh; margin: 0; background: #121727; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.app { max-width: 1220px; margin: auto; padding: 34px 28px 55px; }
.header { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; }
.header h1 { margin: 7px 0 6px; font-size: clamp(31px, 3.8vw, 42px); font-weight: 650; letter-spacing: -.045em; line-height: 1.07; }
.header p { margin: 0; color: #b8c4dc; font-size: 14px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.primary, .secondary { min-height: 42px; padding: 0 17px; border-radius: 7px; font-size: 13px; font-weight: 650; white-space: nowrap; transition: background .15s, border-color .15s; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid #9685f0; background: #7d6bdf; color: #fff; }
.primary:hover:not(:disabled) { background: #927ff2; }
.primary:disabled { opacity: .75; cursor: progress; }
.primary:disabled::before { content: ""; width: 13px; height: 13px; border: 2px solid #ffffff55; border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.secondary { border: 1px solid #506083; background: #202a42; color: #e4eaff; }
.secondary:hover { border-color: #8f9ac3; background: #2a3654; }
.presence-button { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 5px 12px 5px 6px; border: 1px solid #576891; border-radius: 7px; background: #252f4c; color: #eef2ff; text-align: left; }
.presence-button:hover { border-color: #a394f2; background: #2c3859; }
.presence-avatar, .user-avatar { display: inline-grid; flex: 0 0 auto; place-items: center; border-radius: 6px; background: #5b54ac; color: white; font-weight: 750; }
.presence-avatar { width: 30px; height: 30px; font-size: 13px; }
.presence-label { display: flex; flex-direction: column; gap: 1px; line-height: 1.15; }
.presence-label > span { max-width: 120px; overflow: hidden; color: #b5c2df; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.presence-label strong { font-size: 11px; font-weight: 700; white-space: nowrap; }

.workspace { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.loading-line { position: absolute; z-index: 3; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; opacity: 0; }
.loading-line::after { content: ""; display: block; width: 35%; height: 100%; background: var(--accent); animation: loading-slide 1.25s ease-in-out infinite; }
.workspace.is-loading .loading-line { opacity: 1; }
.workspace-top { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 0 25px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 27px; }
.tab { display: inline-flex; align-items: center; gap: 9px; padding: 19px 2px 17px; border: 0; border-bottom: 2px solid transparent; background: none; color: #aebbd7; font-size: 14px; font-weight: 600; white-space: nowrap; }
.tab:hover { color: #f2f5ff; }
.tab[aria-selected=true] { border-bottom-color: #83adff; color: #f2f5ff; }
.tab-count { min-width: 25px; padding: 2px 6px; border: 1px solid #536184; border-radius: 5px; color: #b9c7e1; font-size: 11px; font-weight: 700; text-align: center; }
.tab[aria-selected=true] .tab-count { border-color: #7098e2; color: #a8c5ff; }
.view-hint { margin: 0 0 19px; color: #a2afc9; font-size: 12px; text-align: right; }
.controls { display: grid; grid-template-columns: minmax(330px, 2.2fr) repeat(2, minmax(145px, 1fr)) auto; gap: 13px; align-items: end; padding: 22px 25px; border-bottom: 1px solid var(--line); background: #202940; }
.controls:has(#material-field:not([hidden])) { grid-template-columns: minmax(330px, 2fr) minmax(115px, .8fr) minmax(140px, 1fr) minmax(140px, 1fr) auto; }
.search-control { display: flex; align-items: end; gap: 9px; min-width: 0; }
.search-control .search-field { flex: 1; min-width: 0; }
.search-refresh { min-height: 44px; padding: 0 10px; font-size: 11px; }
.search-refresh:disabled { opacity: .75; cursor: progress; }
.search-refresh:disabled::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 6px; border: 2px solid #ffffff55; border-top-color: #fff; border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
.controls label { display: flex; flex-direction: column; gap: 8px; color: #d4def2; font-size: 12px; font-weight: 600; }
.controls input[type=search], .controls select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #506080; border-radius: 6px; outline: none; background: #171e30; color: #f1f4ff; font-size: 13px; }
.controls input::placeholder { color: #8493af; }
.controls input:focus, .controls select:focus { border-color: #a28df0; box-shadow: 0 0 0 2px #a28df035; }
.controls select { cursor: pointer; }
.controls .available { flex-direction: row; align-items: center; gap: 8px; height: 44px; white-space: nowrap; font-size: 12px; font-weight: 500; }
.available input { width: 16px; height: 16px; accent-color: var(--accent); }

.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 25px 16px; color: var(--muted); font-size: 12px; }
.results-bar > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 15px; }
.results-bar strong { color: #f4f6ff; font-size: 18px; font-weight: 650; letter-spacing: -.025em; }
.results-bar #source-count { text-align: right; }
.results-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.export-csv { padding: 7px 11px; border: 1px solid #586995; border-radius: 6px; color: #dcd6ff; font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.export-csv:hover { border-color: #9f91e8; background: #2c3454; }
.notice { display: flex; align-items: center; gap: 9px; margin: 0 25px 17px; padding: 11px 13px; border: 1px solid #536aa0; border-radius: 6px; background: #24365a; color: #cfe0ff; font-size: 12px; }
.notice.loading::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.5s ease-out infinite; }
.notice.error { border-color: #875b82; background: #372a43; color: #e8c6e5; }

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 0 25px 25px; background: var(--surface); }
.card { display: grid; grid-template-columns: 105px minmax(0, 1fr); grid-template-rows: 1fr auto; gap: 9px 16px; min-height: 190px; padding: 16px; border: 1px solid #3b496b; border-radius: 9px; background: #222b43; transition: background .18s, border-color .18s, transform .18s; }
.card:hover { border-color: #7b82cc; background: #27324e; transform: translateY(-2px); }
.product-image { display: flex; grid-row: 1 / 3; align-items: center; justify-content: center; width: 105px; height: 105px; overflow: hidden; border: 1px solid #d9d8d5; border-radius: 4px; background: #f2f1ee; }
.product-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.product-image.no-image, .no-image { color: #787672; font-size: 11px; text-align: center; }
.card-info { min-width: 0; }
.store-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.store-name { color: #c9d4ed; font-size: 12px; font-weight: 700; }
.method-badge { color: #9daad0; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.card h3 { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; margin: 7px 0 9px; color: #f2f4ff; font-size: 14px; font-weight: 650; line-height: 1.38; }
.card-meta { display: flex; flex-wrap: wrap; gap: 9px; font-size: 11px; }
.stock.yes { color: #a6c7a9; }
.stock.no { color: #e1aa98; }
.stock.unknown { color: #b6c2d9; }
.rating { color: #c7b5ff; }
.choose, .compatibility-toggle, .compatibility-more { border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 600; }
.choose { padding: 9px 0 0; }
.compatibility-toggle { display: block; padding: 7px 0 0; }
.choose:hover, .compatibility-toggle:hover, .compatibility-more:hover { text-decoration: underline; }
.card-price { display: flex; grid-column: 2; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding-top: 10px; border-top: 1px solid #3c4a69; }
.card-price strong { color: #f5f7ff; font-size: 21px; font-weight: 700; letter-spacing: -.035em; white-space: nowrap; }
.card-price small { order: 3; width: 100%; color: #a9b8d5; font-size: 10px; }
.shop-link { font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.shop-link:hover { text-decoration: underline; }
.empty { grid-column: 1 / -1; padding: 50px 20px; border: 1px solid #465678; border-radius: 8px; background: #222b43; text-align: center; }
.empty strong { font-size: 16px; }
.empty p { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.switch-view, .more { padding: 10px 14px; border: 1px solid #807cc9; border-radius: 6px; background: #252d49; color: var(--accent); font-size: 12px; font-weight: 600; }
.switch-view { margin-top: 16px; }
.more { display: block; margin: 0 auto 25px; padding: 11px 20px; }
.switch-view:hover, .more:hover { background: #303a5e; }
.more:disabled { opacity: .6; cursor: progress; }

.compatibility-panel { grid-column: 1 / -1; margin-top: 4px; padding: 14px 0 2px; border-top: 1px solid #465576; color: #c3d0eb; font-size: 12px; }
.compatibility-panel > strong { display: block; margin-bottom: 8px; color: #eef2ff; font-size: 12px; }
.material-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.material-tags span { padding: 4px 7px; border: 1px solid #6b72b7; border-radius: 4px; color: #c8bcff; font-size: 10px; font-weight: 700; }
.compatibility-evidence { margin: 10px 0 5px; line-height: 1.5; }
.compatibility-note { margin: 0 0 12px; color: #a6b5d1; font-size: 10px; line-height: 1.5; }
.compatible-group { margin: 11px 0; }
.compatible-group-title { display: block; color: #d7e1f7; font-size: 11px; font-weight: 700; }
.compatible-list { display: grid; gap: 5px; margin-top: 8px; }
.compatible-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid #465678; border-radius: 5px; font-size: 11px; text-decoration: none; }
.compatible-item:hover { background: #303b5b; }
.compatible-item small { color: #b2c0d9; font-size: 10px; white-space: nowrap; }
.compatibility-more { padding: 8px 0 0; }

.compare { margin: 0 25px 18px; padding: 16px; border: 1px solid #626aa5; border-radius: 8px; background: #242d49; }
.compare-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.compare-heading > div { display: flex; flex-direction: column; gap: 4px; }
.compare-heading strong { font-size: 14px; }
.compare-heading span { color: #b9c7e0; font-size: 11px; }
.compare-heading button { border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 600; }
.compare-content { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.compare-item { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid #4c5c80; border-radius: 6px; background: #202a44; }
.compare-item small { color: #b5c1db; font-size: 10px; }
.compare-item strong { font-size: 12px; line-height: 1.35; }
.compare-price { color: #f5f7ff; font-size: 17px; font-weight: 700; }
.compare-diff, .compare-item a { font-size: 11px; }
.compare-diff { color: #aebdd8; }
.compare-item a { text-decoration: none; }
.footnote { margin: 18px 2px 0; color: #a4b0c9; font-size: 12px; line-height: 1.55; }

.sources-dialog { width: min(650px, calc(100% - 30px)); max-height: min(84vh, 850px); padding: 0; overflow: auto; border: 1px solid #526080; border-radius: 10px; background: #1d263d; color: #eef2ff; box-shadow: 0 24px 75px #050713aa; }
.sources-dialog::backdrop { background: #080c1ccc; }
.sources-dialog[open], .overlay-dialog[open] { animation: modal-in .2s ease-out both; }
.sources-dialog[open]::backdrop, .overlay-dialog[open]::backdrop { animation: backdrop-in .2s ease-out both; }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; padding: 24px 25px 19px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0 0 5px; font-size: 24px; font-weight: 650; letter-spacing: -.035em; }
.dialog-head p { margin: 0; color: #afbdd9; font-size: 12px; }
.dialog-close { align-self: flex-start; width: 32px; height: 32px; border: 1px solid #58688a; border-radius: 6px; background: #26314d; color: #e5eaff; font-size: 23px; line-height: 1; }
.dialog-close:hover { background: #344265; }
.sources-updated { padding: 15px 25px 5px; color: #afbdd9; font-size: 12px; }
.sources-list { padding: 8px 25px 20px; }
.source-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 15px; padding: 12px 0; border-bottom: 1px solid #3e4c6b; }
.source-row-main { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.source-row-main a { color: #ecf1ff; font-size: 13px; font-weight: 650; text-decoration: none; }
.source-row-main a:hover { color: var(--accent); text-decoration: underline; }
.source-method { color: #b8b5ff; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.source-row small { grid-column: 1; color: #aab8d4; font-size: 11px; }
.source-state { grid-column: 2; grid-row: 1 / 3; color: #b4c0d8; font-size: 11px; font-weight: 600; text-align: right; }
.source-state.ok { color: #a6c7a9; }
.source-state.stale { color: #c7b5ff; }
.source-state.error, .source-state.blocked { color: #e1aa98; }
.overlay-dialog { width: min(440px, calc(100% - 28px)); max-height: min(85vh, 700px); padding: 0; overflow: auto; border: 1px solid #60719a; border-radius: 11px; background: #1d263d; color: #eef2ff; box-shadow: 0 26px 80px #030716b8; }
.overlay-dialog::backdrop { background: #080c1ccc; }
.login-dialog form { display: flex; flex-direction: column; padding: 28px; }
.login-dialog h2 { margin: 0 0 22px; font-size: 27px; font-weight: 680; letter-spacing: -.035em; }
.login-dialog input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid #63729a; border-radius: 7px; outline: none; background: #121b2e; color: #f4f6ff; }
.login-dialog input:focus { border-color: #a991ff; box-shadow: 0 0 0 2px #ae9aff35; }
.login-dialog .primary { width: 100%; margin-top: 15px; }
.login-dialog .login-error { margin: 10px 0 0; color: #f0bbd5; font-size: 12px; }
.users-dialog { width: min(520px, calc(100% - 28px)); }
.users-list { display: grid; gap: 8px; min-height: 85px; padding: 18px 24px; }
.user-row { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border: 1px solid #425274; border-radius: 7px; background: #25304b; animation: row-in .2s ease-out both; }
.user-avatar { width: 37px; height: 37px; font-size: 15px; }
.user-info { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.user-info strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.user-info small { color: #a8b8d8; font-size: 11px; }
.online-indicator { color: #9dd6be; font-size: 11px; white-space: nowrap; }
.online-indicator::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #7dd5ac; }
.users-empty { margin: 12px 0; color: #adbbd7; font-size: 13px; }

.skeleton-card { pointer-events: none; }
.skeleton-image, .skeleton-line { position: relative; overflow: hidden; border-radius: 4px; background: #3a4768; }
.skeleton-image { grid-row: 1 / 3; width: 105px; height: 105px; }
.skeleton-copy { display: flex; flex-direction: column; gap: 11px; padding: 7px 0; }
.skeleton-line { display: block; width: 80%; height: 11px; }
.skeleton-line.short { width: 37%; }
.skeleton-line.medium { width: 63%; }
.skeleton-price { grid-column: 2; padding-top: 11px; border-top: 1px solid #465576; }
.skeleton-price .skeleton-line { width: 39%; height: 21px; }
.skeleton-image::after, .skeleton-line::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, #ffffff13, transparent); transform: translateX(-100%); animation: shimmer 1.5s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes loading-slide { from { transform: translateX(-110%); } to { transform: translateX(400%); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes row-in { from { opacity: .45; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 930px) {
  .controls, .controls:has(#material-field:not([hidden])) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-control { grid-column: 1 / -1; }
  .view-hint { display: none; }
  .product-grid { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 620px) {
  .app { padding: 22px 13px 42px; }
  .header { align-items: flex-start; flex-direction: column; gap: 19px; margin-bottom: 22px; }
  .header h1 { font-size: 31px; }
  .header p { font-size: 13px; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions .presence-button { width: 100%; }
  .header-actions .secondary, .header-actions .primary { flex: 1; padding: 0 9px; font-size: 12px; }
  .workspace-top { padding: 0 15px; }
  .tabs { width: 100%; gap: 14px; }
  .tab { flex: 1; justify-content: center; padding: 16px 0 14px; font-size: 12px; }
  .controls, .controls:has(#material-field:not([hidden])) { grid-template-columns: 1fr 1fr; gap: 12px; padding: 17px 15px; }
  .search-control { grid-column: 1 / -1; flex-wrap: wrap; }
  .search-control .search-field, .search-refresh { width: 100%; flex-basis: 100%; }
  .controls .available { grid-column: 1 / -1; height: auto; margin-top: 1px; }
  .results-bar { align-items: flex-start; padding: 18px 15px 14px; }
  .results-bar > div:first-child { flex-direction: column; gap: 4px; }
  .results-actions { flex-wrap: wrap; gap: 7px; }
  .product-grid { padding: 0 15px 15px; }
  .card { grid-template-columns: 80px minmax(0, 1fr); gap: 8px 11px; min-height: 0; padding: 12px; }
  .product-image, .skeleton-image { width: 80px; height: 80px; }
  .card h3 { font-size: 13px; }
  .card-price, .skeleton-price { grid-column: 1 / -1; }
  .card-price strong { font-size: 19px; }
  .compare { margin: 0 15px 15px; }
  .compare-content { grid-template-columns: 1fr; }
  .notice { margin: 0 15px 15px; }
  .compatible-item { flex-direction: column; gap: 3px; }
  .compatible-item small { white-space: normal; }
  .dialog-head { padding: 21px 17px 17px; }
  .sources-updated { padding: 14px 17px 4px; }
  .sources-list { padding: 8px 17px 18px; }
  .login-dialog form { padding: 24px 20px; }
  .users-list { padding: 16px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  dialog::backdrop { animation-duration: .01ms !important; }
}
