:root {
  --navy-950: #0b1f33;
  --navy-900: #12314c;
  --blue-700: #17669a;
  --blue-100: #e8f3fa;
  --ink: #172330;
  --muted: #667584;
  --line: #dce4eb;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --danger: #b8323f;
  --danger-bg: #fff0f1;
  --warning: #9a5b08;
  --warning-bg: #fff7e8;
  --success: #14734b;
  --success-bg: #eaf7f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; font-size: 16px; line-height: 1.45; background: var(--canvas); }
a { color: var(--blue-700); }
button, input, select { font: inherit; }

.topbar {
  min-height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--navy-950);
  color: white;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; font-weight: 750; letter-spacing: -.01em; }
.brand-logo-wrap { width: 126px; height: 46px; display: grid; place-items: center; padding: 5px 8px; border-radius: 9px; background: white; box-shadow: 0 1px 4px rgb(0 0 0 / 18%); }
.brand-logo { display: block; width: 110px; height: auto; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: white; background: #ea4b71; font-size: 14px; font-weight: 800; letter-spacing: .04em; }
.main-nav { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.main-nav a { padding: 7px 10px; border-radius: 7px; color: #d7e6f2; text-decoration: none; font-size: 14px; font-weight: 650; }
.main-nav a:hover { color: white; background: rgb(255 255 255 / 9%); }
.user-menu { position: relative; flex: 0 0 auto; font-size: 14px; }
.user-dropdown { position: relative; }
.user-dropdown summary { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 9px; color: #e8f1f8; cursor: pointer; list-style: none; font-weight: 650; user-select: none; }
.user-dropdown summary::-webkit-details-marker { display: none; }
.user-dropdown summary:hover, .user-dropdown[open] summary { background: rgb(255 255 255 / 10%); }
.user-dropdown summary:focus-visible { outline: 3px solid rgb(255 255 255 / 24%); outline-offset: 2px; }
.user-avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--navy-950); background: #e9f3fa; font-size: 13px; font-weight: 850; }
.user-dropdown-arrow { width: 7px; height: 7px; border-right: 2px solid #a9bfd0; border-bottom: 2px solid #a9bfd0; transform: translateY(-2px) rotate(45deg); transition: transform .15s ease; }
.user-dropdown[open] .user-dropdown-arrow { transform: translateY(2px) rotate(225deg); }
.user-dropdown-panel { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: 230px; padding: 7px; border: 1px solid #d3dee6; border-radius: 11px; color: var(--ink); background: white; box-shadow: 0 12px 32px rgb(8 31 50 / 20%); }
.user-dropdown-panel a, .user-dropdown-panel button { width: 100%; min-height: 38px; display: flex; align-items: center; padding: 8px 10px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; text-align: left; text-decoration: none; font-size: 14px; cursor: pointer; }
.user-dropdown-panel a:hover, .user-dropdown-panel button:hover { color: var(--navy-900); background: var(--blue-100); }
.user-dropdown-panel form { margin: 0; }
.user-dropdown-caption { padding: 5px 10px 3px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.user-dropdown-separator { height: 1px; margin: 6px 4px; background: var(--line); }

.page-shell { width: min(1700px, 100%); margin: 0 auto; padding: 22px; }
.marketplace-tabs { display: inline-flex; gap: 4px; margin-bottom: 15px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.marketplace-tabs a { min-width: 122px; padding: 7px 14px; border-radius: 7px; color: var(--muted); text-align: center; text-decoration: none; font-size: 14px; font-weight: 750; }
.marketplace-tabs a:hover { color: var(--navy-900); background: var(--blue-100); }
.marketplace-tabs a.is-active { color: white; background: var(--blue-700); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.page-heading h1 { margin: 2px 0 4px; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.035em; line-height: 1.15; }
.page-heading p { margin: 0; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 10px; text-decoration: none; font-size: 14px; }

.page-actions { display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; }
.page-actions form { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.manual-sync-status { max-width: 330px; color: var(--muted); font-size: 12px; text-align: right; }
.summary-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; margin-bottom: 14px; }
.summary-grid-ozon { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.summary-card { min-height: 72px; padding: 10px 11px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 1px 2px rgb(12 36 56 / 4%); }
.summary-card span { color: var(--muted); font-size: 11px; line-height: 1.18; }
.summary-card strong { font-size: clamp(16px, 1.35vw, 21px); line-height: 1; white-space: nowrap; }
.summary-card .summary-date { font-size: clamp(14px, 1.2vw, 18px); }
.summary-alert { border-left: 4px solid #e0a13a; }
.summary-primary { border-left: 4px solid var(--blue-700); background: #f7fbfe; }

.filters { display: grid; grid-template-columns: 160px minmax(180px, 1fr) 210px minmax(220px, 1.25fr) auto; gap: 12px; align-items: end; padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.filters-range { grid-template-columns: 150px 150px minmax(240px, 1fr) auto; }
.ozon-filters { grid-template-columns: 150px 150px minmax(260px, 520px) auto; justify-content: start; }
.filters label, .login-form label { display: grid; gap: 6px; color: #435260; font-size: 14px; font-weight: 650; }
.filters .checkbox-label { grid-column: 1 / span 3; display: flex; align-items: center; align-self: center; gap: 9px; min-height: 42px; }
.checkbox-label input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.checkbox-label input[type="hidden"] { display: none; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd7e0; border-radius: 8px; background: white; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgb(23 102 154 / 16%); border-color: var(--blue-700); }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button-primary { background: var(--blue-700); color: white; }
.button-primary:hover { background: #105a89; }
.button-secondary { color: var(--navy-900); background: white; border-color: #bdccd8; }
.button-danger { color: var(--danger); background: white; border-color: #e5b8bd; }
.button-danger:hover { background: var(--danger-bg); }

.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 2px 8px rgb(12 36 56 / 4%); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 9px 9px; text-align: left; color: #50616f; background: #edf3f7; border-bottom: 1px solid #ccd8e1; font-weight: 750; line-height: 1.15; white-space: normal; }
td { padding: 10px 9px; border-bottom: 1px solid #e6ecf0; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
.number { text-align: right; white-space: nowrap; }
.sort-link { display: inline; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--blue-700); }
.toggle-column { width: 48px; min-width: 48px; padding-left: 12px; padding-right: 6px; text-align: center; }
.expand-button { width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0; border: 1px solid #afc2d0; border-radius: 7px; color: var(--navy-900); background: white; font-size: 21px; line-height: 1; cursor: pointer; }
.expand-button:hover, .expand-button:focus-visible { color: white; background: var(--blue-700); border-color: var(--blue-700); }
.expand-button:focus-visible { outline: 3px solid rgb(23 102 154 / 20%); outline-offset: 2px; }
.product-summary > td { vertical-align: middle; }
.products-table { table-layout: auto; }
.products-table th.number { white-space: normal; }
.products-table td.number { min-width: 88px; }
.product-name-cell { width: 31%; min-width: 225px; }
.product-name-cell > .product-title { display: block; max-width: 440px; color: var(--ink); font-weight: 750; text-decoration: none; }
.product-name-cell > .product-title:hover { color: var(--blue-700); }
.ozon-products-table .product-name-cell { width: 42%; }
.ozon-discount-pill { color: var(--navy-900); background: var(--blue-100); }
.product-meta { display: flex; flex-wrap: wrap; gap: 5px 8px; align-items: baseline; margin-top: 6px; color: var(--muted); font-size: 13px; }
.product-meta strong { color: var(--ink); }
.orders-panel > td { padding: 0; background: #f6f9fb; }
.orders-panel-inner { padding: 12px 18px 18px 58px; border-bottom: 1px solid #d9e3ea; }
.orders-table { min-width: 760px; border: 1px solid #d5e0e8; border-radius: 8px; background: white; overflow: hidden; }
.orders-table th { padding: 9px 11px; background: #e5eef4; font-size: 13px; }
.orders-table td { padding: 9px 11px; font-size: 13px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.product-cell { min-width: 260px; }
.product-cell > a:first-child { display: block; color: var(--ink); font-weight: 800; text-decoration: none; }
.product-cell > span { display: block; max-width: 380px; margin: 2px 0 4px; color: #475866; }
.external-link { font-size: 12px; text-decoration: none; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.muted { color: #8996a0; }
.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }
.delta { font-weight: 750; white-space: nowrap; }
.spp-pill { display: inline-flex; min-width: 48px; justify-content: center; align-items: center; gap: 4px; padding: 4px 8px; border: 0; border-radius: 999px; color: var(--navy-900); background: var(--blue-100); font-weight: 800; white-space: nowrap; }
.button.spp-pill, button.spp-pill { cursor: pointer; }
.spp-level-high { color: #075c39; background: #ccefdc; }
.spp-level-good { color: #246b37; background: #e8f6df; }
.spp-level-watch { color: #775500; background: #fff4c2; }
.spp-level-low { color: #923943; background: #ffe2e2; }
.spp-level-critical { color: #fff; background: #c93442; }
.spp-arrow { font-size: 16px; line-height: 1; }
.spp-history-wrap { position: relative; display: inline-block; text-align: left; }
.spp-history-popover { width: 205px; margin-top: 7px; padding: 9px 10px; border: 1px solid #cbd8e1; border-radius: 8px; background: white; box-shadow: 0 8px 22px rgb(12 36 56 / 13%); white-space: normal; }
.spp-history-popover > strong { display: block; margin-bottom: 5px; font-size: 12px; }
.spp-history-popover ol { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.spp-history-popover li { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.spp-history-popover li span { color: var(--ink); font-weight: 750; }
.spp-zero { color: var(--danger); background: var(--danger-bg); }
.spp-decrease { color: var(--warning); background: var(--warning-bg); }
.row-zero { box-shadow: inset 4px 0 var(--danger); }
.row-decrease { box-shadow: inset 4px 0 #e0a13a; }
.cancelled { opacity: .58; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); }
.footnote { margin: 12px 2px 0; color: var(--muted); font-size: 13px; }
.history-section { margin-top: 26px; }
.history-section h2 { margin: 0 0 10px; font-size: 20px; }

.login-shell { min-height: calc(100vh - 120px); display: grid; place-items: center; padding: 30px 0; }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 18px 50px rgb(12 36 56 / 12%); }
.login-mark { width: 48px; height: 48px; border-radius: 12px; }
.login-card h1 { margin: 20px 0 5px; font-size: 28px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 15px; }
.notice { margin: 0 0 18px; padding: 11px 13px; border-radius: 8px; font-size: 14px; }
.notice-error { color: var(--danger); background: var(--danger-bg); }
.notice-success { color: var(--success); background: var(--success-bg); }
.notice-info { color: var(--navy-900); background: var(--blue-100); }

.competitors-panel-inner { padding: 14px 18px 18px 58px; border-bottom: 1px solid #d9e3ea; }
.add-competitor-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(190px, 300px) auto; align-items: end; gap: 10px; margin-bottom: 14px; }
.add-competitor-form label { color: #435260; font-size: 14px; font-weight: 700; }
.add-competitor-form input { min-height: 38px; }
.add-competitor-form .button { min-height: 38px; }
.nested-table-scroll { overflow-x: auto; }
.competitors-table { min-width: 720px; }
.competitors-table .product-name-cell { width: 38%; }
.competitor-actions { width: 112px; text-align: right; white-space: nowrap; }
.competitor-actions form { margin: 0; }
.button-compact { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.price-history-button { padding: 3px 6px; border: 0; border-radius: 6px; color: var(--ink); background: transparent; font-weight: 800; cursor: pointer; white-space: nowrap; }
.price-history-button:hover { background: var(--blue-100); }
.price-history-popover { position: absolute; z-index: 5; right: 0; }
.empty-inline { margin: 8px 0 0; color: var(--muted); }
.competitor-filters { margin: -6px 0 14px; }
.competitor-filters .checkbox-label { display: inline-flex; align-items: center; gap: 9px; color: #435260; font-size: 14px; font-weight: 650; cursor: pointer; }
.competitor-filters input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.upd-heading form { margin: 0; }
.upd-total { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 24px; margin-bottom: 14px; padding: 14px 18px; border: 1px solid #b8d4e5; border-left: 5px solid var(--blue-700); border-radius: 10px; background: #f7fbfe; }
.upd-total span { color: #435260; font-size: 14px; font-weight: 700; }
.upd-total strong { grid-row: 1 / span 2; grid-column: 2; color: var(--navy-900); font-size: clamp(25px, 3vw, 34px); line-height: 1; white-space: nowrap; }
.upd-total small { color: var(--muted); }
.upd-filters { grid-template-columns: 160px 160px auto; justify-content: start; }
.upd-table { min-width: 960px; }
.upd-table .check-column { width: 48px; text-align: center; }
.upd-table input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.button-download { display: inline-block; padding: 5px 9px; border: 1px solid #bdccd8; border-radius: 6px; color: var(--navy-900); background: white; text-decoration: none; font-size: 12px; font-weight: 700; white-space: nowrap; }
.api-settings-form { display: grid; gap: 16px; max-width: 920px; }
.api-settings-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 2px 8px rgb(12 36 56 / 4%); }
.api-settings-heading { grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.api-settings-heading h2 { margin: 0 0 3px; font-size: 21px; }
.api-settings-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.api-settings-card label { display: grid; gap: 6px; color: #435260; font-size: 14px; font-weight: 700; }
.api-settings-card label small { color: var(--muted); font-size: 12px; font-weight: 400; }
.credential-status { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: var(--warning); background: var(--warning-bg); font-size: 12px; font-weight: 800; }
.credential-status.is-ready { color: var(--success); background: var(--success-bg); }
.api-settings-actions { display: flex; justify-content: flex-end; }
.field-error { color: #b42318 !important; font-weight: 700 !important; }
.notification-settings { display: grid; gap: 16px; max-width: 920px; }
.notification-card { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 2px 8px rgb(12 36 56 / 4%); }
.notification-card h2 { margin: 0 0 12px; font-size: 21px; }
.connection-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.connection-card p { margin: 0; color: var(--muted); }
.connection-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.connection-actions form { margin: 0; }
.notification-form { display: grid; gap: 14px; }
.subscription-toggle { display: flex; align-items: flex-start; gap: 10px; color: #435260; font-weight: 700; cursor: pointer; }
.subscription-toggle input { width: 19px; min-height: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--blue-700); }
.subscription-toggle span { display: grid; gap: 3px; }
.subscription-toggle small, .threshold-grid small { color: var(--muted); font-size: 12px; font-weight: 400; }
.threshold-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line); }
.threshold-grid label { display: grid; gap: 6px; color: #435260; font-size: 14px; font-weight: 700; }
.threshold-grid input { max-width: 180px; }
.notification-hint { margin: 0; padding: 11px 13px; border-radius: 8px; color: #435260; background: var(--blue-100); font-size: 13px; }
.comparison-summary { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 14px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: #435260; font-size: 14px; }
.comparison-summary strong { color: var(--navy-900); font-size: 17px; }
.comparison-filters { grid-template-columns: minmax(260px, 520px) auto; justify-content: start; }
.marketplace-comparison-table { min-width: 1320px; }
.marketplace-comparison-table .product-name-cell { min-width: 300px; }
.marketplace-comparison-table th.marketplace-group { text-align: center; color: var(--navy-900); border-bottom-color: #bdccd8; }
.comparison-difference { font-weight: 800; }
.comparison-difference.positive { color: #14733b; }
.comparison-difference.negative { color: #b42318; }

@media (max-width: 950px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .summary-grid-ozon { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .checkbox-label { grid-column: span 2; }
  .filters .button { grid-column: span 2; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .brand { gap: 8px; font-size: 14px; }
  .brand-logo-wrap { width: 108px; height: 40px; padding: 4px 7px; }
  .brand-logo { width: 94px; }
  .user-dropdown-name { display: none; }
  .topbar { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .main-nav { order: 3; width: 100%; }
  .page-shell { padding: 20px 14px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-actions { align-items: stretch; flex-direction: column; }
  .page-actions form { align-items: stretch; }
  .manual-sync-status { max-width: none; text-align: left; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid-ozon { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 84px; padding: 13px; }
  .summary-card strong { font-size: 23px; }
  .filters { grid-template-columns: 1fr; }
  .filters .checkbox-label { grid-column: auto; }
  .filters .button { grid-column: auto; }
  .orders-panel-inner { padding-left: 12px; }
  .competitors-panel-inner { padding-left: 12px; }
  .add-competitor-form { grid-template-columns: 1fr; }
  .login-card { padding: 26px 22px; }
  .api-settings-card { grid-template-columns: 1fr; padding: 16px; }
  .api-settings-heading { flex-direction: column; gap: 9px; }
  .connection-card { align-items: stretch; flex-direction: column; }
  .connection-actions { flex-wrap: wrap; }
  .threshold-grid { grid-template-columns: 1fr; }
}
