:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #ffffff;
  --wash: #f3f4f6;
  --accent: #2563eb;
  --good: #047857;
  --bad: #dc2626;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, #dbeafe 0, transparent 30rem), var(--wash); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 390px); padding: 30px 24px; border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: 0 24px 70px rgba(15,23,42,.14); }
.logo { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 14px; background: var(--ink); color: white; font-size: 26px; }
.auth-card h1 { margin: 0; text-align: center; font-size: 22px; }
.sub { margin: 8px 0 24px; color: var(--muted); text-align: center; font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 12px; background: var(--wash); }
.tab { flex: 1; padding: 9px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.tab.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); font-weight: 700; }
.auth-form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: #4b5563; font-size: 12px; font-weight: 700; }
input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 10px; background: white; color: var(--ink); }
input:focus { outline: 3px solid rgba(37,99,235,.16); border-color: var(--accent); }
.primary, .refresh-button { border: 0; background: var(--ink); color: white; font-weight: 800; }
.primary { min-height: 46px; margin-top: 4px; border-radius: 11px; }
.error { min-height: 18px; margin: 12px 0 0; color: var(--bad); text-align: center; font-size: 13px; }
.app-header { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px max(16px, env(safe-area-inset-left)); background: rgba(17,24,39,.95); color: white; backdrop-filter: blur(12px); }
.app-header h1 { margin: 2px 0 0; font-size: clamp(18px, 4vw, 23px); }
.eyebrow { margin: 0; color: #93c5fd; font-size: 9px; letter-spacing: .18em; font-weight: 800; }
.ghost { padding: 8px 10px; border: 1px solid rgba(255,255,255,.28); border-radius: 9px; background: transparent; color: white; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 7px; }
main { width: min(100%, 1100px); margin: 0 auto; padding: 16px; }
.control-panel { padding: 16px; border: 1px solid rgba(255,255,255,.8); border-radius: 18px; background: rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(15,23,42,.06); }
.control-top, .status-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.control-refresh-only { justify-content: flex-end; }
.control-label { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.segment { display: flex; padding: 3px; border-radius: 10px; background: var(--wash); }
.segment button { min-width: 72px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.segment button.active { background: white; color: var(--ink); font-weight: 800; box-shadow: 0 1px 5px rgba(0,0,0,.09); }
.refresh-button { min-height: 44px; padding: 0 16px; border-radius: 11px; }
.refresh-button:disabled { opacity: .55; cursor: wait; }
.refresh-button.loading span { display: inline-block; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-line { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.inventory-total { color: var(--ink); font-weight: 800; white-space: nowrap; }
.portfolio-summary { display: grid; grid-template-columns: minmax(110px,.7fr) minmax(180px,1.3fr); gap: 10px; margin-top: 12px; }
.summary-item { padding: 14px 16px; border: 1px solid rgba(255,255,255,.9); border-radius: 16px; background: rgba(255,255,255,.92); box-shadow: 0 8px 25px rgba(15,23,42,.05); }
.summary-item span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; }
.summary-item strong { display: block; margin-top: 5px; font-size: clamp(20px,5vw,30px); font-variant-numeric: tabular-nums; }
.summary-value { background: linear-gradient(135deg, #111827, #1e3a8a); color: white; }
.summary-value span, .summary-value small { color: #bfdbfe; }
.summary-value small { display: block; margin-top: 3px; font-size: 9px; }
.model-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0 10px; scrollbar-width: none; }
.model-tabs::-webkit-scrollbar { display: none; }
.model-tabs button { flex: 0 0 auto; padding: 9px 14px; border: 1px solid #d1d5db; border-radius: 999px; background: rgba(255,255,255,.8); color: #4b5563; font-size: 13px; font-weight: 700; }
.model-tabs button.active { border-color: var(--ink); background: var(--ink); color: white; }
.model-tabs button.active::before { content: "✓ "; color: #93c5fd; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-toolbar .model-tabs { flex: 1; min-width: 0; }
.view-switch { flex: 0 0 auto; }
.view-switch button { min-width: 62px; }
.muted-control { opacity: .48; }
.price-list { display: grid; gap: 14px; }
.empty { padding: 48px 20px; border: 1px dashed #cbd5e1; border-radius: 18px; background: rgba(255,255,255,.55); text-align: center; color: var(--muted); }
.storage-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 8px 25px rgba(15,23,42,.05); }
.storage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #f9fafb; }
.storage-head h2 { margin: 0; font-size: 17px; }
.storage-head span { color: var(--muted); font-size: 11px; }
.variant { border-bottom: 1px solid var(--line); }
.variant:last-child { border-bottom: 0; }
.variant-main { display: grid; grid-template-columns: minmax(110px,1fr) 100px 72px; gap: 10px; align-items: center; padding: 13px 14px 8px; }
.color-name { min-width: 0; font-weight: 800; font-size: 14px; }
.best-price { text-align: right; }
.best-price strong { display: block; font-size: 16px; }
.best-price small { color: var(--muted); font-size: 10px; }
.quantity-wrap { display: flex; align-items: center; gap: 5px; }
.quantity-wrap input { width: 52px; min-height: 44px; padding: 6px 4px; text-align: center; font-weight: 800; }
.quantity-wrap span { color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 14px 11px; }
.metric { padding: 8px; border-radius: 9px; background: var(--wash); }
.metric span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; }
.metric strong { display: block; margin-top: 3px; font-size: 13px; }
.positive { color: var(--good); }
.negative { color: var(--bad); }
.shops { border-top: 1px solid #f3f4f6; }
.shops summary { padding: 9px 14px 11px; color: #4b5563; font-size: 12px; font-weight: 700; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 7px; padding: 0 14px 14px; }
.shop { display: flex; justify-content: space-between; gap: 6px; padding: 8px 9px; border-radius: 8px; background: #f9fafb; font-size: 11px; }
.shop.best { background: #ecfdf5; color: #065f46; font-weight: 800; }
.shop a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.shops-empty { grid-column: 1 / -1; margin: 0; padding: 12px; color: var(--muted); text-align: center; }
.table-view main { width: min(100%, 1680px); }
.table-shell { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid #cfd4dc; border-radius: 12px; background: var(--paper); box-shadow: 0 8px 25px rgba(15,23,42,.05); }
.table-note { position: sticky; left: 0; z-index: 5; min-width: max-content; margin: 0; padding: 9px 12px; border-bottom: 1px solid #d8dee8; background: #f4f7ff; color: #315b98; font-size: 11px; font-weight: 800; }
.price-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.price-table th { position: sticky; top: 0; z-index: 3; padding: 8px 7px; border-right: 1px solid #d7dce4; border-bottom: 1px solid #c9d0db; background: #f6f7f9; color: #374151; text-align: center; white-space: nowrap; }
.price-table th:first-child { left: 0; z-index: 6; }
.price-table td { height: 48px; padding: 6px 7px; border-right: 1px solid #e0e4ea; border-bottom: 1px solid #dfe3e8; vertical-align: middle; }
.price-table tbody tr:last-child td { border-bottom: 0; }
.price-table tbody tr:nth-child(even) td { background-color: #fbfcfd; }
.price-table tbody tr:hover td { background-color: #f3f7fb; }
.nowrap, .number-cell { white-space: nowrap; }
.model-cell { min-width: 72px; background: #fff1f2; text-align: center; }
.model-label { font-weight: 900; white-space: nowrap; }
.color-cell { min-width: 94px; background: #f3f6fb; font-weight: 800; }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }
.table-price-main, .retail-pair { display: grid; justify-items: end; gap: 2px; }
.table-price-main strong, .retail-pair strong { font-size: 12px; }
.table-price-main small, .retail-pair small { color: var(--muted); font-size: 9px; }
.table-quantity { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.table-quantity select { width: 60px; min-height: 44px; padding: 5px 22px 5px 8px; border: 1px solid #cbd5e1; border-radius: 9px; background: white; color: var(--ink); text-align: center; font-weight: 800; }
.table-quantity span { color: var(--muted); font-size: 11px; }
.quantity-cell { min-width: 76px; }
.sticky-quantity { position: sticky; left: 0; z-index: 2; background: white; box-shadow: 1px 0 0 var(--line); }
.price-table tbody tr:nth-child(even) .sticky-quantity { background: #fbfcfd; }
.price-table tbody tr:hover .sticky-quantity { background: #f3f7fb; }
.vendor-header { min-width: 88px; background: #fffde8 !important; }
.vendor-header a { color: #2563a6; font-weight: 900; text-decoration: underline; text-underline-offset: 2px; }
.vendor-price-cell { min-width: 88px; text-align: center; color: #374151; }
.vendor-price-cell.row-best { background: #eadcff !important; color: #171125; font-weight: 900; box-shadow: inset 0 0 0 1px #d8c1fa; }
.vendor-price-cell.no-price { color: #b0b7c3; }
.vendor-dialog { width: min(92vw, 560px); max-height: min(82vh, 720px); padding: 0; border: 0; border-radius: 20px; background: white; box-shadow: 0 25px 80px rgba(15,23,42,.3); }
.vendor-dialog::backdrop { background: rgba(15,23,42,.62); backdrop-filter: blur(3px); }
.vendor-panel { padding: 20px; }
.vendor-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.vendor-head h2 { margin: 3px 0 0; font-size: 20px; }
.eyebrow.dark { color: var(--accent); }
.dialog-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--wash); color: var(--muted); font-size: 22px; }
.vendor-help { margin: 12px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.vendor-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.small-button, .secondary-button, .primary-button { border: 0; border-radius: 9px; font-weight: 800; }
.small-button { padding: 7px 10px; background: #e5e7eb; color: #374151; font-size: 11px; }
.vendor-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; max-height: 48vh; overflow-y: auto; padding: 2px; }
.vendor-option { display: flex; grid-template-columns: none; align-items: center; gap: 9px; min-height: 44px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-size: 13px; }
.vendor-option input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--accent); }
.vendor-error { min-height: 16px; margin: 8px 0 0; }
.dialog-actions { display: flex; gap: 9px; margin-top: 10px; }
.secondary-button, .primary-button { min-height: 44px; padding: 8px 14px; }
.secondary-button { flex: 1; background: var(--wash); color: #4b5563; }
.primary-button { flex: 2; background: var(--ink); color: white; }
.primary-button:disabled { opacity: .55; }
.sources { margin-top: 20px; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.72); color: var(--muted); font-size: 12px; }
.sources h2 { margin: 0 0 8px; color: var(--ink); font-size: 14px; }
.sources a { margin-right: 14px; color: var(--accent); }
.sources p { margin: 10px 0 0; line-height: 1.6; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px; background: #111827; color: white; opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: .2s; font-size: 13px; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) {
  main { padding: 24px; }
  .price-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 430px) {
  .control-top { align-items: end; }
  .refresh-button { padding: 0 11px; font-size: 13px; }
  .variant-main { grid-template-columns: minmax(92px,1fr) 92px 67px; padding-inline: 11px; }
  .metrics { padding-inline: 11px; }
  .list-toolbar { align-items: end; }
  .view-switch button { min-width: 55px; padding-inline: 7px; }
  .app-header { align-items: flex-start; }
  .header-actions { flex-direction: column; align-items: stretch; }
  .header-actions .ghost { padding: 7px 8px; }
  .portfolio-summary { grid-template-columns: 1fr 1.4fr; }
  .summary-item { padding: 12px; }
  .vendor-list { grid-template-columns: 1fr; }
  .table-view main { padding-inline: 8px; }
  .table-view .control-panel, .table-view .portfolio-summary { margin-inline: 8px; }
  .table-shell { max-height: calc(100vh - 170px); border-radius: 9px; }
  .price-table th, .price-table td { padding-inline: 6px; }
}
