/* WB Monitor — theme-safe Material UI */
@font-face {
  font-family: "Material Icons Round";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/MaterialIconsRound.woff2") format("woff2");
}

html[data-theme="dark"] {
  --md-bg: #0f1115;
  --md-bg-glow-a: rgba(79, 209, 197, 0.10);
  --md-bg-glow-b: rgba(100, 181, 246, 0.07);
  --md-surface: #171a21;
  --md-surface-2: #1e2330;
  --md-surface-3: #262c3b;
  --md-outline: rgba(232, 234, 237, 0.14);
  --md-text: #e8eaed;
  --md-muted: #9aa0a6;
  --md-primary: #4fd1c5;
  --md-on-primary: #003731;
  --md-danger: #ff8a80;
  --md-ok: #69f0ae;
  --md-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.28);
  --md-topbar: rgba(23, 26, 33, 0.92);
  --md-dialog-scrim: rgba(0, 0, 0, 0.62);
  --md-slider-knob: #ffffff;
  color-scheme: dark;
}

html[data-theme="light"] {
  --md-bg: #f3f5f7;
  --md-bg-glow-a: rgba(0, 137, 123, 0.08);
  --md-bg-glow-b: rgba(25, 118, 210, 0.06);
  --md-surface: #ffffff;
  --md-surface-2: #eef1f5;
  --md-surface-3: #e2e7ee;
  --md-outline: rgba(26, 29, 36, 0.12);
  --md-text: #1a1d24;
  --md-muted: #5f6673;
  --md-primary: #00897b;
  --md-on-primary: #ffffff;
  --md-danger: #c62828;
  --md-ok: #2e7d32;
  --md-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08);
  --md-topbar: rgba(255, 255, 255, 0.92);
  --md-dialog-scrim: rgba(15, 17, 21, 0.45);
  --md-slider-knob: #ffffff;
  color-scheme: light;
}

:root {
  --md-radius: 16px;
  --md-radius-sm: 12px;
  --page-pad: clamp(12px, 2vw, 32px);
  --content-max: 1280px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--md-bg);
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--md-bg);
  background-image:
    radial-gradient(1100px 520px at 8% -8%, var(--md-bg-glow-a), transparent 60%),
    radial-gradient(900px 480px at 100% 0%, var(--md-bg-glow-b), transparent 55%);
  /* fixed bg breaks paint on iOS Safari (white blank screen) */
  background-attachment: scroll;
  color: var(--md-text);
  /* system first — no layout jump when webfont arrives */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .15s ease;
}
@media (hover: hover) and (pointer: fine) {
  body { background-attachment: fixed; }
}

.material-icons-round {
  font-family: "Material Icons Round", sans-serif !important;
  font-weight: normal;
  font-style: normal;
  font-size: 22px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  width: 1em;
  height: 1em;
  overflow: hidden;
  white-space: nowrap;
  speak: never;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
  flex-shrink: 0;
}

a { color: var(--md-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }

.panel-surface,
.panel,
.auth-card,
.product-card,
.md-dialog {
  background: var(--md-surface);
  color: var(--md-text);
  border: 1px solid var(--md-outline);
  box-shadow: var(--md-shadow);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: var(--md-topbar);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--md-outline);
}

.top-bar-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--md-text);
  font-weight: 700;
  text-decoration: none;
}
.brand .material-icons-round { color: var(--md-primary); font-size: 26px; }
.brand-logo {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  color: var(--md-primary);
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
}
.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
}
.brand-logo-fill {
  background: linear-gradient(180deg, #0d9488, #0b6e66);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.brand-logo-fill img {
  /* full tile logo.svg already has bg */
}
.brand-logo-lg {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #0d9488, #0b6e66);
}
.brand-text { font-size: 1.05rem; }

.top-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--md-surface-2);
  color: var(--md-muted);
  font-size: 0.85rem;
  border: 1px solid var(--md-outline);
}
.chip .material-icons-round { font-size: 18px; color: var(--md-primary); }
.role-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--md-surface-3);
  color: var(--md-text);
}
.market-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--md-outline);
  background: var(--md-surface-2);
  color: var(--md-muted);
  vertical-align: middle;
}
.market-badge.wb { color: #7bc9a0; border-color: color-mix(in srgb, #7bc9a0 40%, var(--md-outline)); }
.market-badge.ozon { color: #6b9fff; border-color: color-mix(in srgb, #6b9fff 40%, var(--md-outline)); }
html[data-theme="light"] .market-badge.wb { color: #1b7a4a; }
html[data-theme="light"] .market-badge.ozon { color: #005bff; }

.icon-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease;
  flex-shrink: 0;
}
.icon-btn .material-icons-round { font-size: 22px; }
.icon-btn:hover { background: var(--md-surface-2); }
.icon-btn.danger { color: var(--md-danger); }
a.icon-btn { text-decoration: none; }

.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: calc(var(--page-pad) + 4px) var(--page-pad) 48px;
}

.page-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-areas: "add status" "products products";
  gap: 16px;
}
.page-grid > .panel:nth-child(1) { grid-area: add; }
.page-grid > .panel:nth-child(2) { grid-area: status; }
.page-grid > .panel:nth-child(3) { grid-area: products; }

.panel {
  border-radius: var(--md-radius);
  padding: 18px 18px 20px;
}

.panel-head h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 700; color: var(--md-text); }
.muted, .panel-head .muted { color: var(--md-muted); margin: 0; font-size: 0.9rem; }
.small { font-size: 0.82rem; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field span { font-size: 0.8rem; color: var(--md-muted); font-weight: 500; }
.field-hint {
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: -2px;
}
.field-hint:empty { display: none; }
.field input, .field textarea, .field select, .stack-form input, .stack-form select {
  width: 100%;
  border: 1px solid var(--md-outline);
  background: var(--md-surface-2);
  color: var(--md-text);
  border-radius: var(--md-radius-sm);
  padding: 12px 14px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-primary) 25%, transparent);
}

.add-form {
  display: grid;
  grid-template-columns:
    minmax(110px, 130px)
    minmax(180px, 1.8fr)
    minmax(110px, 140px)
    minmax(140px, 170px)
    minmax(140px, 170px)
    auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.add-form .field { min-width: 0; }
.add-form .grow { /* grid cell */ }
.add-form > .btn {
  height: 46px;
  min-height: 46px;
  padding-inline: 20px;
  white-space: nowrap;
  align-self: end;
}
.field input,
.field select {
  min-height: 46px;
}
.stack-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, filter .12s ease, background .15s, color .15s;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn .material-icons-round { font-size: 20px; }
.btn-filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn-tonal { background: var(--md-surface-3); color: var(--md-text); }
.btn-text { background: transparent; color: var(--md-primary); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }

.banner {
  border-radius: var(--md-radius-sm);
  padding: 12px 14px;
  margin: 12px 0 0;
  font-size: 0.92rem;
}
.banner-error { background: color-mix(in srgb, var(--md-danger) 16%, var(--md-surface)); color: var(--md-danger); }
.banner-ok { background: color-mix(in srgb, var(--md-ok) 16%, var(--md-surface)); color: var(--md-ok); }

.status-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 16px; }
.status-row {
  display: grid;
  grid-template-columns: 28px 1fr 10px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--md-radius-sm);
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline);
}
.status-row .material-icons-round { color: var(--md-primary); }
.status-row strong { display: block; font-size: 0.92rem; color: var(--md-text); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--md-muted); }
.dot.on { background: var(--md-ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-ok) 22%, transparent); }

.table-wrap {
  overflow: auto;
  margin-top: 12px;
  border-radius: var(--md-radius-sm);
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
}
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--md-outline);
  vertical-align: middle;
  color: var(--md-text);
  background: transparent;
}
.data-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--md-muted);
  background: var(--md-surface-2);
  position: sticky;
  top: 0;
}
.data-table tr.hit td { background: color-mix(in srgb, var(--md-ok) 10%, var(--md-surface)); }
.data-table tr:hover td { background: color-mix(in srgb, var(--md-primary) 7%, var(--md-surface)); }
.data-table tr.product-row.clickable { cursor: pointer; }
.data-table tr.product-row.clickable:hover td {
  background: color-mix(in srgb, var(--md-primary) 12%, var(--md-surface));
}

/* Products tracking table */
.products-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1080px;
}
.products-table th,
.products-table td {
  padding: 10px 12px;
  vertical-align: middle;
}
.products-table .col-status { width: 52px; }
.products-table .col-market { width: 64px; }
.products-table .col-article { width: 108px; }
.products-table .col-photo { width: 56px; padding-left: 8px; padding-right: 8px; }
.products-table .col-name { width: 22%; }
.products-table .col-seller { width: 12%; }
.products-table .col-num { width: 96px; }
.products-table .col-disc { width: 52px; }
.products-table .col-actions { width: 124px; }
.products-table .num {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", monospace;
  font-size: 0.88rem;
}
.products-table th.col-num,
.products-table th.col-disc,
.products-table th.col-actions {
  text-align: right;
}
.products-table th.col-disc { text-align: center; }
.products-table td.col-disc { text-align: center; white-space: nowrap; }
.products-table .col-article .mono {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.seller-cell {
  max-width: none;
  font-size: 0.86rem;
  min-width: 0;
}
.seller-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  line-height: 1.25;
}
.seller-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.scope-chip.count {
  color: var(--md-muted);
  background: color-mix(in srgb, var(--md-muted) 14%, transparent);
}
.products-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  width: 100%;
}
.products-actions .icon-btn {
  width: 36px;
  height: 36px;
}
.name-cell { max-width: none; }
.name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  max-width: 100%;
  line-height: 1.3;
}
.spark-cell {
  white-space: nowrap;
  width: auto;
}
.photo-cell {
  width: auto;
  padding-left: 8px !important;
  padding-right: 8px !important;
}
.thumb-fallback {
  width: 40px;
  height: 52px;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  color: var(--md-muted);
  background: var(--md-surface-2);
  border-radius: 8px;
  text-align: center;
  line-height: 1.1;
  padding: 4px;
}
.scope-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.scope-chip.this {
  color: var(--md-muted);
  background: color-mix(in srgb, var(--md-muted) 16%, transparent);
}
.scope-chip.any {
  color: var(--md-primary);
  background: color-mix(in srgb, var(--md-primary) 16%, transparent);
}
.block { display: block; }

/* --- Sellers modal --- */
.sellers-dialog {
  width: min(1040px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  border: 1px solid var(--md-outline);
}
.sellers-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 20px);
  min-height: 0;
}
.sellers-form > header {
  align-items: flex-start;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--md-outline);
  flex-shrink: 0;
}
.sellers-head {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 8px;
}
.sellers-head h3 {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sellers-meta {
  margin: 0;
  font-size: 0.84rem;
  color: var(--md-muted);
  line-height: 1.35;
}
.sellers-meta code {
  font-family: "Roboto Mono", monospace;
  font-size: 0.82rem;
  color: var(--md-text);
}
.sellers-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.sellers-loading { padding: 28px 4px; text-align: center; }
.sellers-table-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  max-height: min(58vh, 560px);
  overflow: auto;
  margin: 0;
  border-radius: var(--md-radius-sm);
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
  -webkit-overflow-scrolling: touch;
}
.sellers-table {
  width: 100%;
  min-width: 0 !important;
  border-collapse: collapse;
  table-layout: fixed;
}
.sellers-table th,
.sellers-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-outline);
  border-left: 0 !important;
  border-right: 0 !important;
  vertical-align: middle;
  background: transparent;
}
.sellers-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--md-muted);
  background: var(--md-surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.sellers-table th.num,
.sellers-table td.num { text-align: right; }
.sellers-table col.col-seller { width: 34%; }
.sellers-table th:nth-child(1),
.sellers-table td:nth-child(1) { width: 44px; }
.sellers-table th:nth-child(2),
.sellers-table td:nth-child(2) { width: 30%; }
.sellers-table th:nth-child(3),
.sellers-table td:nth-child(3) { width: 15%; }
.sellers-table th:nth-child(4),
.sellers-table td:nth-child(4),
.sellers-table th:nth-child(5),
.sellers-table td:nth-child(5) { width: 13%; }
.sellers-table th:nth-child(6),
.sellers-table td:nth-child(6) { width: 10%; }
.sellers-table th:nth-child(7),
.sellers-table td:nth-child(7) { width: 12%; text-align: right; }
.col-check {
  width: 44px !important;
  text-align: center !important;
  padding-left: 10px !important;
  padding-right: 6px !important;
}
.seller-check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  min-width: 28px;
  min-height: 28px;
}
.seller-check-label input[type="checkbox"],
.seller-check {
  width: 18px;
  height: 18px;
  accent-color: var(--md-primary);
  cursor: pointer;
  margin: 0;
}
.seller-check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
  text-align: left;
}
.seller-check-card .seller-line { flex: 1; min-width: 0; }
.sellers-table tr.tracked td {
  background: color-mix(in srgb, var(--md-primary) 7%, var(--md-surface));
}
.sellers-table tr.best td:first-child {
  box-shadow: inset 3px 0 0 var(--md-ok);
}
.sellers-table tr:hover td {
  background: color-mix(in srgb, var(--md-primary) 6%, var(--md-surface));
}
.seller-cell-modal {
  min-width: 0;
}
.seller-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}
.seller-name-full {
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.seller-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.seller-tags .scope-chip {
  margin-left: 0;
}
.stock-ok { color: var(--md-ok); font-weight: 600; }
.stock-no { color: var(--md-danger); font-weight: 600; }
.sellers-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px 16px !important;
  border-top: 1px solid var(--md-outline);
  background: var(--md-surface);
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}
.sellers-scope-field {
  margin: 0;
  flex: 0 1 260px;
  min-width: min(220px, 100%);
}
.sellers-scope-field select {
  min-height: 44px;
}
.sellers-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}
.sellers-footer-actions .btn {
  min-height: 44px;
  height: 44px;
}
.sellers-cards {
  display: none;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  max-height: min(58vh, 560px);
  -webkit-overflow-scrolling: touch;
}
.seller-card {
  padding: 14px;
  border-radius: var(--md-radius-sm);
  border: 1px solid var(--md-outline);
  background: var(--md-surface-2);
  display: grid;
  gap: 10px;
}
.seller-card.tracked {
  border-color: color-mix(in srgb, var(--md-primary) 45%, var(--md-outline));
}
.seller-card.best {
  box-shadow: inset 3px 0 0 var(--md-ok);
}
.seller-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.seller-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.seller-card-metrics span {
  display: block;
  font-size: 0.72rem;
  color: var(--md-muted);
}
.seller-card-metrics strong {
  font-family: "Roboto Mono", monospace;
  font-size: 0.95rem;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
  min-height: 36px;
  height: auto;
}
.num { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", monospace; font-size: 0.92rem; }
.accent { color: var(--md-ok); font-weight: 700; }
.mono { font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", monospace; font-size: 0.88rem; }
.link { color: var(--md-primary); }
.actions { white-space: nowrap; }
.actions-inner {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  vertical-align: middle;
}
.thumb-btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  line-height: 0;
  overflow: hidden;
  display: inline-block;
}
.thumb-btn:disabled { cursor: default; opacity: 1; }
.thumb-btn:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}
.product-thumb {
  width: 40px;
  height: 52px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline);
}
.product-thumb-lg { width: 56px; height: 72px; }
.thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 52px;
  border-radius: 8px;
  border: 1px dashed var(--md-outline);
  background: var(--md-surface-2);
  color: var(--md-muted);
  font-size: 0.58rem;
  line-height: 1.15;
  text-align: center;
  padding: 4px;
  box-sizing: border-box;
}
.thumb-fallback-lg {
  width: 56px;
  height: 72px;
  font-size: 0.65rem;
}
.pc-head-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0 10px;
}
.pc-head-row h3 { margin: 0; flex: 1; min-width: 0; }

.gallery-dialog { width: min(920px, calc(100vw - 16px)); }
.gallery-form { background: var(--md-surface); }
.gallery-body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 16px;
  min-height: min(70vh, 560px);
}
.gallery-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(62vh, 520px);
  background: #0a0b0e;
  border-radius: 12px;
  overflow: hidden;
}
.gallery-stage img {
  max-width: 100%;
  max-height: min(62vh, 520px);
  object-fit: contain;
  display: block;
}
.gallery-counter {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 0.8rem;
  font-family: "Roboto Mono", monospace;
}
.gallery-nav {
  appearance: none;
  border: 1px solid var(--md-outline);
  background: var(--md-surface-2);
  color: var(--md-text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.gallery-nav .material-icons-round { font-size: 28px; }
.gallery-nav:hover { background: color-mix(in srgb, var(--md-primary) 18%, var(--md-surface-2)); }
@media (max-width: 720px) {
  .gallery-body { grid-template-columns: 1fr; gap: 10px; }
  .gallery-nav { width: 100%; height: 40px; border-radius: 10px; }
}

.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--md-surface-3);
  border: 1px solid var(--md-outline);
  border-radius: 999px;
  cursor: pointer;
  transition: .2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 2px;
  background: var(--md-slider-knob);
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--md-primary); border-color: var(--md-primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.card-list { display: none; gap: 12px; margin-top: 12px; }
.product-card { border-radius: var(--md-radius); padding: 14px; }
.product-card.hit { outline: 1px solid color-mix(in srgb, var(--md-ok) 50%, transparent); }
.pc-top { display: flex; align-items: center; gap: 10px; }
.pc-actions { margin-left: auto; display: flex; }
.product-card h3 { margin: 12px 0 10px; font-size: 1rem; font-weight: 600; color: var(--md-text); }
.pc-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pc-metrics span { display: block; font-size: 0.75rem; }
.pc-metrics strong { font-family: "Roboto Mono", monospace; font-size: 0.95rem; color: var(--md-text); }

.module-chip {
  font-family: "Roboto Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: .02em;
}
.module-chip.on {
  color: #7bc9a0;
  border-color: color-mix(in srgb, #7bc9a0 45%, var(--md-outline));
}
.module-chip.off {
  color: var(--md-muted);
  opacity: .9;
}
html[data-theme="light"] .module-chip.on { color: #1b7a4a; }

.sys-chip {
  font-family: "Roboto Mono", monospace;
  font-size: 0.72rem;
  max-width: min(420px, 48vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  gap: 6px;
}
.sys-chip .material-icons-round { font-size: 16px; opacity: 0.85; }
.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.logs-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.logs-pre {
  margin: 0;
  max-height: min(62vh, 520px);
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--md-radius-sm);
  border: 1px solid var(--md-outline);
  background: #0a0c10;
  color: #c8d0dc;
  font-family: "Roboto Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
html[data-theme="light"] .logs-pre {
  background: #1a1d24;
  color: #e8ecf2;
}
.danger-tonal { color: var(--md-danger, #ef5350); }

.sparkline {
  color: var(--md-primary);
  display: block;
  opacity: .9;
  pointer-events: none;
}
.sparkline-wide {
  width: 100%;
  height: 36px;
}
.history-btn {
  gap: 4px;
  white-space: nowrap;
  vertical-align: middle;
}
.history-btn .material-icons-round { font-size: 16px; }
.history-btn-sm {
  padding: 4px 8px;
  min-height: 28px;
  font-size: 0.78rem;
  border-radius: 8px;
}
.history-btn-block {
  width: 100%;
  margin-top: 12px;
  justify-content: center;
}
.history-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.history-stat {
  background: var(--md-surface-2);
  border: 1px solid var(--md-outline);
  border-radius: 12px;
  padding: 10px 12px;
}
.history-stat span {
  display: block;
  font-size: 0.75rem;
  color: var(--md-muted);
  margin-bottom: 4px;
}
.history-stat strong {
  font-family: "Roboto Mono", monospace;
  font-size: 0.95rem;
  color: var(--md-text);
  font-weight: 600;
}
.history-stat strong.up { color: #e57373; }
.history-stat strong.down { color: #81c784; }
.history-chart-wrap {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--md-outline);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--md-primary) 8%, transparent), transparent 42%),
    var(--md-surface-2);
  padding: 8px 4px 4px;
  overflow: hidden;
}
.history-chart {
  width: 100%;
  height: auto;
  display: block;
  min-height: 220px;
}
.history-chart .axis { stroke: var(--md-outline); stroke-width: 1; }
.history-chart .grid { stroke: var(--md-outline); stroke-width: 1; opacity: .45; stroke-dasharray: 3 4; }
.history-chart .area { fill: color-mix(in srgb, var(--md-primary) 22%, transparent); }
.history-chart .line { fill: none; stroke: var(--md-primary); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.history-chart .dot { fill: var(--md-primary); }
.history-chart .target { stroke: #ffb74d; stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .9; }
.history-chart .lbl { fill: var(--md-muted); font-size: 11px; font-family: "Roboto Mono", monospace; }
.history-chart .lbl-strong { fill: var(--md-text); font-size: 11px; font-family: "Roboto Mono", monospace; }

@media (max-width: 720px) {
  .history-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.empty { text-align: center; padding: 40px 16px; color: var(--md-muted); }
.empty .material-icons-round { font-size: 42px; opacity: .5; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.auth-card {
  width: min(420px, 100%);
  border-radius: calc(var(--md-radius) + 4px);
  padding: 28px 24px 24px;
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand h1 { margin: 8px 0 4px; font-size: 1.45rem; color: var(--md-text); }
.auth-brand p { margin: 0; color: var(--md-muted); font-size: 0.9rem; }
.brand-icon { font-size: 42px; color: var(--md-primary); }
.auth-brand .brand-logo-lg { color: var(--md-primary); }
.theme-fab {
  position: absolute;
  top: 16px; right: 16px;
  width: 46px; height: 46px;
  border: 1px solid var(--md-outline);
  border-radius: 50%;
  background: var(--md-surface);
  color: var(--md-text);
  box-shadow: var(--md-shadow);
  cursor: pointer;
}

.fieldset {
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-sm);
  padding: 14px;
  margin: 0;
  background: var(--md-surface-2);
}
.fieldset legend {
  padding: 0 8px;
  font-weight: 600;
  color: var(--md-muted);
  font-size: 0.85rem;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--md-text);
}
.check-row input { width: 18px; height: 18px; accent-color: var(--md-primary); }

.md-dialog {
  border-radius: var(--md-radius);
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  color: var(--md-text);
}
.md-dialog.wide { width: min(720px, calc(100vw - 24px)); }
.md-dialog.wide-xl { width: min(1080px, calc(100vw - 24px)); }
.md-dialog::backdrop { background: var(--md-dialog-scrim); }
.dialog-form header, .dialog-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--md-surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.dialog-form header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--md-text);
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dialog-form header .dialog-close,
.dialog-form header .icon-btn {
  flex-shrink: 0;
  position: relative;
  z-index: 3;
}
.dialog-form footer {
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--md-outline);
  position: sticky;
  bottom: 0;
}
.sellers-form > footer.sellers-footer {
  justify-content: space-between;
  align-items: flex-end;
}
.dialog-body { padding: 8px 16px 16px; background: var(--md-surface); }

.user-create-row {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 0.9fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.users-table-wrap {
  overflow: visible;
}
.users-table-wrap .data-table {
  min-width: 0;
  width: 100%;
}
.pass-field {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pass-field input {
  flex: 1;
  min-width: 0;
}
.pass-field .icon-btn {
  flex-shrink: 0;
}
.pass-cell .pass-field input {
  min-width: 120px;
}
.users-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.view-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--md-radius-sm);
  border: 1px solid color-mix(in srgb, var(--md-primary) 35%, var(--md-outline));
  background: color-mix(in srgb, var(--md-primary) 10%, var(--md-surface));
  color: var(--md-text);
}
.view-banner .material-icons-round { color: var(--md-primary); }
.view-banner > div { flex: 1; min-width: 140px; }
.view-banner strong { display: block; }
.view-banner .muted { font-size: 0.85rem; }
.install-steps { margin: 0; padding-left: 18px; color: var(--md-text); }
.install-steps li { margin: 8px 0; }

@media (max-width: 900px) {
  .add-form {
    grid-template-columns: 1fr 1fr;
  }
  .add-form .grow { grid-column: 1 / -1; }
  .add-form > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 720px) {
  :root { --topbar-h: 56px; --page-pad: 12px; }
  .user-chip span:not(.material-icons-round):not(.role-badge) { display: none; }
  .sys-chip { max-width: 42vw; font-size: 0.65rem; }
  .page-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "add" "status" "products";
  }
  .table-wrap { display: none; }
  .card-list { display: grid; }
  .user-create-row { grid-template-columns: 1fr; }
  .pc-metrics { grid-template-columns: 1fr 1fr; }
  .add-form { grid-template-columns: 1fr; }
  .sellers-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    margin: auto;
    border-radius: 14px;
  }
  .sellers-table-wrap { display: none !important; }
  .sellers-cards:not(.hidden) { display: flex; }
  .sellers-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .sellers-scope-field { flex: 1 1 auto; width: 100%; }
  .sellers-footer-actions {
    margin-left: 0;
    width: 100%;
  }
  .sellers-footer-actions .btn {
    flex: 1;
  }
  .sellers-form > header,
  .sellers-body,
  .sellers-footer {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }
}

@media (min-width: 721px) and (max-width: 1365px) {
  :root { --content-max: 1100px; }
  .card-list { display: none; }
}
@media (min-width: 1366px) and (max-width: 1919px) {
  :root { --content-max: 1280px; }
}
@media (min-width: 1920px) and (max-width: 2559px) {
  :root { --content-max: 1560px; --page-pad: 28px; }
  body { font-size: 16px; }
  .sellers-dialog { width: min(1200px, calc(100vw - 48px)); }
  .sellers-table-wrap { max-height: min(62vh, 680px); }
  .page-grid { grid-template-columns: 1fr 300px; }
  .products-table { min-width: 1180px; }
  .products-table .col-num { width: 108px; }
  .products-table .col-actions { width: 132px; }
}
@media (min-width: 2560px) {
  :root { --content-max: 1920px; --page-pad: 40px; --topbar-h: 76px; }
  body { font-size: 17px; }
  .sellers-dialog { width: min(1400px, calc(100vw - 64px)); }
  .sellers-table-wrap { max-height: min(64vh, 760px); }
  .sellers-table th,
  .sellers-table td { padding: 16px 18px; font-size: 0.98rem; }
  .page-grid { grid-template-columns: 1fr 320px; gap: 20px; }
  .add-form { gap: 14px; }
  .products-table { min-width: 1360px; }
  .products-table th,
  .products-table td { padding: 12px 14px; }
  .products-table .col-num { width: 120px; }
  .products-table .col-actions { width: 140px; }
  .products-table .num { font-size: 0.95rem; }
}
/* iPhone 16 / narrow phones */
@media (max-width: 430px) {
  .top-actions .user-chip { display: none; }
  .sys-chip { display: none; }
  .pc-metrics { grid-template-columns: 1fr 1fr; }
  .brand-text { font-size: 0.95rem; }
}
