@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@500;600;700;800&display=swap");

:root {
  --bg: #f2f4f8;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --ink: #1d2838;
  --muted: #607086;
  --line: #d6dde8;
  --accent: #4a7de0;
  --accent-soft: rgba(74, 125, 224, 0.14);
  --green: #2f9867;
  --green-soft: rgba(47, 152, 103, 0.12);
  --red: #cc5959;
  --red-soft: rgba(204, 89, 89, 0.12);
  --amber: #b38427;
  --shadow: 0 10px 26px rgba(23, 33, 48, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Manrope", "Segoe UI", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-small: "Inter", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --bg: #0e1117;
  --panel: rgba(22, 26, 34, 0.96);
  --panel-strong: #171c24;
  --ink: #e6ebf3;
  --muted: #9aa6b7;
  --line: #2a313d;
  --accent: #7ea8ff;
  --accent-soft: rgba(126, 168, 255, 0.18);
  --green: #69c897;
  --green-soft: rgba(105, 200, 151, 0.16);
  --red: #de8c8c;
  --red-soft: rgba(222, 140, 140, 0.18);
  --amber: #d6bf7a;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 460px at 12% -12%, rgba(120, 144, 182, 0.14), transparent 62%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(1200px 500px at 10% -15%, rgba(75, 96, 130, 0.2), transparent 62%),
    linear-gradient(180deg, #0d1117 0%, #0b0f14 100%);
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.page-shell {
  width: min(1800px, calc(100vw - 28px));
  margin: 14px auto 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.hero {
  padding: 24px 28px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 12px;
}

.hero h1,
.panel__header h2 {
  margin: 0;
  font-family: var(--font-display);
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 2.6rem);
  line-height: 1;
}

.brand-nav {
  display: grid;
  gap: 10px;
}

.hero-tools {
  min-width: 170px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
}

.theme-toggle__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-toggle__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.theme-toggle__icon {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.theme-toggle__track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #e4e8ef;
  position: relative;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.theme-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 0.16s ease;
}

.theme-toggle__input:checked + .theme-toggle__label .theme-toggle__track {
  background: rgba(126, 168, 255, 0.28);
  border-color: #7ea8ff;
}

.theme-toggle__input:checked + .theme-toggle__label .theme-toggle__thumb {
  transform: translateX(20px);
}

.theme-toggle__input:focus-visible + .theme-toggle__label .theme-toggle__track {
  box-shadow: 0 0 0 3px rgba(126, 168, 255, 0.18);
}

.brand-nav__menu {
  position: relative;
  width: fit-content;
}

.brand-nav__trigger {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f5f8ff;
  color: #1b57c5;
  padding: 7px 12px;
  min-height: 34px;
  cursor: pointer;
  font-weight: 700;
}

.brand-nav__menu:hover .brand-nav__trigger {
  background: #eaf1ff;
}

.brand-nav__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(35, 53, 81, 0.16);
  padding: 6px;
  z-index: 20;
}

.brand-nav__menu:hover .brand-nav__dropdown {
  display: grid;
  gap: 4px;
}

.brand-nav__dropdown a {
  display: block;
  text-decoration: none;
  color: #2a3d5e;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 600;
}

.brand-nav__dropdown a:hover,
.brand-nav__dropdown a.is-active {
  background: #eaf1ff;
  color: #1a57c3;
}

.panel__header p,
.items-meta {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-family: var(--font-small);
}

.filters-panel,
.system-panel,
.metrics-panel,
.summary-panel,
.items-panel {
  padding: 18px 20px 20px;
  margin-bottom: 14px;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.panel__actions {
  display: flex;
  gap: 8px;
}

.panel-hidden {
  display: none;
}

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.toolbar-grid--top {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.toolbar-grid--main {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.9rem;
  font-weight: 600;
  color: #49556d;
  font-family: var(--font-small);
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #f9fbff;
  color: var(--ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select {
  background: #111b2b;
  color: var(--ink);
  border-color: var(--line);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(47, 110, 232, 0.45);
  box-shadow: 0 0 0 4px rgba(47, 110, 232, 0.12);
  background: #ffffff;
}

html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field select:focus {
  background: #182232;
}

.access-box {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: #f9fbff;
}

html[data-theme="dark"] .access-box {
  background: #151c27;
  border-color: #303947;
}

.access-box__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.credentials-hidden {
  display: none;
}

.toolbar-actions,
.action-group,
.system-panel__row,
.items-filters,
.toggle-row,
.threshold-control,
.tag-editor,
.tag-editor__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-actions {
  justify-content: space-between;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-group {
  flex-wrap: wrap;
}

.action-group--compact {
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: none;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.compact-button {
  min-height: 32px;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, #4f79bb, #3f6398);
  color: #ffffff;
}

.secondary-button {
  background: var(--accent-soft);
  color: #35598f;
}

.ghost-button {
  background: transparent;
  color: #4a5b76;
  border: 1px solid var(--line);
}

.toggle-row {
  position: relative;
  padding-right: 58px;
  min-height: 32px;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: absolute;
  right: 0;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #c9d3e5;
  transition: background 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  transition: transform 0.15s ease;
}

.toggle-row input:checked + .switch {
  background: var(--accent);
}

.toggle-row input:checked + .switch::after {
  transform: translateX(20px);
}

.threshold-control {
  padding: 0 8px;
}

.threshold-control input {
  width: 120px;
}

.status-banner,
.notice-card {
  border-radius: 16px;
  padding: 14px 16px;
}

.notice-card {
  position: relative;
  padding-right: 38px;
}

.notice-card__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: #5a6d8e;
  padding: 0;
  line-height: 1;
  font-size: 16px;
  cursor: pointer;
}

.status-banner {
  flex: 1;
  background: #f7f9fc;
  border: 1px solid var(--line);
  font-family: var(--font-small);
}

.status-banner.is-loading,
.notice-card.is-info {
  background: rgba(47, 110, 232, 0.08);
  border: 1px solid rgba(47, 110, 232, 0.18);
}

.status-banner.is-success {
  background: var(--green-soft);
  border: 1px solid rgba(31, 159, 95, 0.18);
}

.status-banner.is-error,
.notice-card.is-warning {
  background: rgba(217, 74, 74, 0.08);
  border: 1px solid rgba(217, 74, 74, 0.18);
}

.status-banner.is-loading {
  position: relative;
  padding-left: 44px;
}

.status-banner.is-loading::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(47, 110, 232, 0.25);
  border-top-color: var(--accent);
  animation: spin-loader 0.8s linear infinite;
}

@keyframes spin-loader {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

.notices-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.notice-card__title {
  font-weight: 700;
  margin-bottom: 4px;
}

.metrics-manager {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric-plan-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f9fbff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.plan-chip.is-active {
  background: rgba(31, 159, 95, 0.14);
  border-color: rgba(31, 159, 95, 0.38);
}

.plan-chip__label {
  font-weight: 700;
}

.plan-chip__hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.metric-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #f9fbff;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.metric-option.is-enabled {
  background: rgba(31, 159, 95, 0.14);
  border-color: rgba(31, 159, 95, 0.42);
}

.metric-option.is-disabled-premium {
  background: #f1f3f8;
  border-color: #d7dee9;
  color: #8593a8;
  cursor: not-allowed;
}

.metric-option.is-disabled-premium .metric-option__check span {
  color: #7f8da4;
  font-weight: 500;
}

.metric-option.is-disabled-premium .metric-order,
.metric-option.is-disabled-premium .metric-kind {
  opacity: 0.7;
}

.metric-option.is-enabled .metric-option__check span {
  font-weight: 800;
}

.metric-option:not(.is-enabled) .metric-option__check span {
  font-weight: 500;
}

.metric-drop-placeholder {
  border: 2px dashed #96b7ff;
  border-radius: 10px;
  background: rgba(47, 110, 232, 0.08);
}

.metric-option__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.metric-option__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.76rem;
}

.metric-order {
  display: inline-flex;
  min-width: 24px;
  justify-content: center;
  border-radius: 999px;
  background: #eef3fb;
  color: #36517f;
  font-weight: 700;
  padding: 1px 7px;
}

.metric-kind {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
}

.metric-kind.is-direct {
  background: var(--accent-soft);
  color: #1d57c3;
}

.metric-kind.is-calculated {
  background: var(--green-soft);
  color: var(--green);
}

.metric-plan-badge {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: #eef3fb;
  color: #48607f;
}

.metric-plan-badge.is-standard {
  background: #eef3fb;
  color: #48607f;
}

.metric-plan-badge.is-premium {
  background: rgba(255, 205, 120, 0.2);
  color: #9a5e00;
}

.metric-plan-badge.is-plus {
  background: rgba(111, 148, 255, 0.18);
  color: #3658c6;
}

.metric-plan-badge.is-pro {
  background: rgba(187, 128, 255, 0.18);
  color: #7241b6;
}

.summary-wrap,
.items-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  position: relative;
  overscroll-behavior: contain;
}

.summary-wrap {
  max-height: 62vh;
}

.items-wrap {
  max-height: 72vh;
}

.campaigns-wrap {
  max-height: 74vh;
}

.summary-table,
.items-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td,
.items-table th,
.items-table td {
  border-bottom: 1px solid #e7ecf4;
  padding: 8px 8px;
  text-align: left;
  vertical-align: top;
}

.summary-table thead th,
.items-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #f5f8fc;
  color: #69758d;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}

.items-table thead th {
  font-family: var(--font-small);
  font-size: 0.74rem;
}

.summary-table thead th:first-child,
.summary-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #fbfcfe;
}

.summary-table thead th:first-child {
  z-index: 14;
}

.metric-cell {
  min-width: 220px;
}

.head-cell-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 100%;
  position: relative;
  padding-right: 10px;
}

.head-filter-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #3f5171;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.head-filter-button.is-active {
  border-color: #9ab9ff;
  background: #eaf1ff;
  color: #1d57c3;
}

.head-filter-button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.col-resizer {
  position: absolute;
  right: -2px;
  top: -8px;
  width: 9px;
  height: calc(100% + 16px);
  cursor: col-resize;
  z-index: 8;
}

.col-resizer::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 8px;
  width: 1px;
  height: calc(100% - 16px);
  background: rgba(118, 136, 168, 0.4);
}

.is-resizing-columns,
.is-resizing-columns * {
  cursor: col-resize !important;
  user-select: none;
}

.metric-name {
  font-weight: 700;
}

.metric-source {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  font-family: var(--font-small);
}

.metric-pill {
  display: inline-flex;
  margin-top: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: #eef3fb;
  color: #4f6282;
}

.metric-pill.is-unavailable {
  background: rgba(217, 74, 74, 0.08);
  color: var(--red);
}

.metric-pill.is-calculated {
  background: rgba(31, 159, 95, 0.1);
  color: var(--green);
}

.metric-pill[title] {
  cursor: help;
}

.metric-dot {
  display: inline-flex;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  margin-top: 8px;
  background: #b9c5da;
  cursor: help;
}

.metric-dot.is-direct {
  background: #4b86ff;
}

.metric-dot.is-calculated {
  background: #2cbf74;
}

.metric-dot.is-unavailable {
  background: #ff7575;
}

.total-cell {
  min-width: 130px;
  font-weight: 700;
}

.spark-cell {
  min-width: 140px;
}

.sparkline {
  width: 118px;
  height: 38px;
}

.day-head {
  min-width: 98px;
}

.day-head__date {
  font-weight: 700;
  color: var(--ink);
}

.day-head__weekday {
  margin-top: 1px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-small);
}

.day-cell {
  min-width: 98px;
}

.day-card {
  display: grid;
  gap: 4px;
  min-height: 56px;
  padding: 7px;
  border-radius: 10px;
  background: #fbfcfe;
  border: 1px solid transparent;
  transition: background 0.12s ease;
}

.day-card[title] {
  cursor: help;
}

.day-card:hover {
  background: #e8edf6;
}

html[data-theme="dark"] .day-card {
  background: #1b222d;
}

html[data-theme="dark"] .day-card:hover {
  background: #242d3a;
}

.day-card.is-up {
  background: rgba(31, 159, 95, 0.05);
}

.day-card.is-up:hover {
  background: rgba(31, 159, 95, 0.15);
}

.day-card.is-down {
  background: rgba(217, 74, 74, 0.05);
}

.day-card.is-down:hover {
  background: rgba(217, 74, 74, 0.15);
}

.day-card.is-anomaly-up {
  border-color: rgba(31, 159, 95, 0.42);
}

.day-card.is-anomaly-down {
  border-color: rgba(217, 74, 74, 0.42);
}

.day-card.is-critical-low {
  border-color: rgba(217, 74, 74, 0.58);
  background: rgba(217, 74, 74, 0.12);
}

.day-card.is-critical-low:hover {
  background: rgba(217, 74, 74, 0.18);
}

.day-card.anomalies-off {
  border-color: transparent;
}

.day-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.delta-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.66rem;
  background: #eef2f7;
  color: var(--muted);
  font-family: var(--font-small);
}

.delta-chip.is-up {
  background: var(--green-soft);
  color: var(--green);
}

.delta-chip.is-down {
  background: var(--red-soft);
  color: var(--red);
}

.delta-chip.is-zero-base {
  background: rgba(195, 138, 23, 0.12);
  color: var(--amber);
}

.items-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 6px 0 10px;
}

.items-metric-filters {
  display: grid;
  grid-template-columns: 1.2fr repeat(2, minmax(0, 0.7fr)) auto;
  gap: 10px;
  margin: 0 0 10px;
  align-items: end;
}

.metric-filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.items-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 10px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  font-weight: 600;
  color: #3c4d69;
}

.check-chip input[type="checkbox"] {
  margin: 0;
}

.tag-editor {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

.columns-manager {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #f9fbff;
  margin-bottom: 10px;
}

.columns-manager__title {
  font-weight: 700;
  margin-bottom: 8px;
}

.columns-manager__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.columns-manager__head .columns-manager__title {
  margin: 0;
}

.check-chip--small {
  padding: 4px 10px;
  font-size: 0.84rem;
}

.items-columns-manager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff;
}

.column-option input[type="checkbox"] {
  margin: 0;
}

.pin-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 2px 6px;
  background: #fff;
  cursor: pointer;
}

.pin-toggle.is-active {
  border-color: #96b8ff;
  background: #eaf1ff;
  color: #1f57be;
}

.items-table {
  min-width: max-content;
}

.metric-group-title {
  text-align: center;
  font-weight: 700;
  color: #51617c;
}

.items-table tbody tr.item-start-row:not(:first-child) td {
  border-top: 2px solid #d5e0f4;
}

.sticky-col {
  position: sticky;
  background: #ffffff;
  z-index: 11;
  background-clip: padding-box;
  box-shadow: 1px 0 0 #e7edf8;
}

.sticky-head {
  top: 0;
  z-index: 22;
  background: #f5f8fc;
}

.sticky-col-metric {
  z-index: 14;
}

.items-table thead th[data-col-key="photo"],
.items-table thead th[data-col-key="sellerArticle"],
.items-table thead th[data-col-key="metric"] {
  z-index: 24;
  text-align: center;
}

.col-item-small {
  min-width: 130px;
}

.col-item-photo {
  min-width: 92px;
  width: 92px;
}

.col-item-medium {
  min-width: 180px;
}

.col-item-name {
  min-width: 320px;
}

.items-table tbody tr:hover td {
  background: rgba(47, 110, 232, 0.06);
}

.items-table tbody tr:hover td.sticky-col {
  background: #edf4ff;
}

.items-table td[data-col-key="sellerArticle"] {
  text-align: center;
}

.metric-sort-button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.metric-sort-button:hover {
  color: #1f57be;
}

.metric-sort-button.is-active {
  color: #1d57c3;
}

.metric-sort-indicator {
  font-size: 0.76rem;
  color: #607292;
}

.metric-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-metric-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-row-drag-handle {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #586985;
  cursor: grab;
  padding: 0;
  line-height: 1;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.summary-metric-row {
  cursor: grab;
}

.summary-metric-row.is-dragging {
  opacity: 0.4;
}

.summary-drop-placeholder td {
  padding: 0 !important;
  border-bottom: 0;
}

.summary-drop-placeholder div {
  height: 10px;
  margin: 0 4px;
  border: 2px dashed #96b7ff;
  border-radius: 8px;
  background: rgba(47, 110, 232, 0.08);
}

.metric-filter-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #3f5171;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.metric-filter-button.is-active {
  border-color: #94b5ff;
  background: #eaf1ff;
  color: #1b57c2;
}

.metric-filter-button svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.campaign-state-filter {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
  flex-wrap: wrap;
}

.state-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #3f5171;
  border-radius: 999px;
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
  font-family: var(--font-small);
}

.state-chip.is-active {
  border-color: #9ab9ff;
  background: #eaf1ff;
  color: #1d57c3;
}

.campaign-state-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  font-size: 0.68rem;
  font-family: var(--font-small);
  font-weight: 600;
  white-space: nowrap;
}

.campaign-state-badge.is-active {
  background: rgba(33, 163, 102, 0.14);
  color: #1f8a58;
}

.campaign-state-badge.is-inactive {
  background: rgba(248, 221, 159, 0.38);
  color: #876114;
}

.campaign-state-badge.is-archived {
  background: rgba(146, 159, 178, 0.25);
  color: #5f6f84;
}

.item-photo {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid #d4deef;
  background: #f0f4fb;
}

.column-filter-popover {
  position: fixed;
  width: min(330px, calc(100vw - 16px));
  max-height: 58vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(36, 54, 84, 0.24);
  z-index: 40;
  padding: 10px;
  display: grid;
  gap: 8px;
  overflow: hidden;
}

html[data-theme="dark"] .panel {
  border-color: #2a313d;
}

html[data-theme="dark"] .brand-nav__trigger {
  background: #1a2029;
  color: #d3dbe8;
  border-color: #303947;
}

html[data-theme="dark"] .theme-toggle__icon {
  color: #aab6c9;
}

html[data-theme="dark"] .theme-toggle__track {
  background: #2a313d;
  border-color: #3a4352;
}

html[data-theme="dark"] .theme-toggle__thumb {
  background: #d8dee9;
}

html[data-theme="dark"] .theme-toggle__input:checked + .theme-toggle__label .theme-toggle__track {
  background: rgba(126, 168, 255, 0.24);
  border-color: #7ea8ff;
}

html[data-theme="dark"] .brand-nav__dropdown {
  background: #1b212b;
  border-color: #303947;
}

html[data-theme="dark"] .brand-nav__dropdown a {
  color: #d1d9e7;
}

html[data-theme="dark"] .status-banner {
  background: #1a2029;
  border-color: #303947;
  color: #d5deeb;
}

html[data-theme="dark"] .status-banner.is-loading,
html[data-theme="dark"] .notice-card.is-info {
  background: rgba(126, 168, 255, 0.1);
  border-color: rgba(126, 168, 255, 0.26);
}

html[data-theme="dark"] .status-banner.is-success {
  background: rgba(105, 200, 151, 0.12);
  border-color: rgba(105, 200, 151, 0.26);
}

html[data-theme="dark"] .status-banner.is-error,
html[data-theme="dark"] .notice-card.is-warning {
  background: rgba(222, 140, 140, 0.14);
  border-color: rgba(222, 140, 140, 0.3);
}

html[data-theme="dark"] .metric-option {
  background: #1a2029;
  border-color: #303947;
  color: #dce4f1;
}

html[data-theme="dark"] .metric-option.is-enabled {
  background: rgba(105, 200, 151, 0.16);
  border-color: rgba(105, 200, 151, 0.34);
}

html[data-theme="dark"] .metric-order {
  background: #262e3a;
  color: #d1d9e7;
}

html[data-theme="dark"] .metric-kind.is-direct {
  background: rgba(126, 168, 255, 0.16);
  color: #b6ccf5;
}

html[data-theme="dark"] .metric-kind.is-calculated {
  background: rgba(105, 200, 151, 0.16);
  color: #9dddbf;
}

html[data-theme="dark"] .brand-nav__dropdown a:hover,
html[data-theme="dark"] .brand-nav__dropdown a.is-active {
  background: #262f3b;
  color: #e6ebf3;
}

html[data-theme="dark"] .summary-table thead th,
html[data-theme="dark"] .items-table thead th,
html[data-theme="dark"] .sticky-head {
  background: #1d242e;
  color: #b8c3d5;
}

html[data-theme="dark"] .summary-table thead th:first-child,
html[data-theme="dark"] .summary-table tbody td:first-child,
html[data-theme="dark"] .sticky-col {
  background: #1a2029;
}

html[data-theme="dark"] .items-table tbody tr:hover td {
  background: rgba(126, 168, 255, 0.1);
}

html[data-theme="dark"] .items-table tbody tr:hover td.sticky-col {
  background: #222b37;
}

html[data-theme="dark"] .column-filter-popover,
html[data-theme="dark"] .metric-filter-popover {
  background: #1a2029;
  border-color: #323c4a;
}

html[data-theme="dark"] .column-filter-popover__list {
  background: #151b24;
  border-color: #323c4a;
}

html[data-theme="dark"] .check-chip,
html[data-theme="dark"] .head-filter-button,
html[data-theme="dark"] .metric-filter-button,
html[data-theme="dark"] .state-chip {
  background: #1a2029;
  border-color: #333d4b;
  color: #d4dbe8;
}

html[data-theme="dark"] .summary-row-drag-handle {
  background: #1a2029;
  border-color: #333d4b;
  color: #d4dbe8;
}

html[data-theme="dark"] .summary-drop-placeholder div {
  border-color: #6a87b9;
  background: rgba(106, 135, 185, 0.16);
}

html[data-theme="dark"] .notice-card__close {
  background: #1d242e;
  border-color: #323c4a;
  color: #d4dbe8;
}

html[data-theme="dark"] .metric-option.is-disabled-premium {
  background: #1d242e;
  border-color: #323c4a;
  color: #8a96a9;
}

html[data-theme="dark"] .metric-option.is-disabled-premium .metric-option__check span {
  color: #93a0b4;
}

html[data-theme="dark"] .plan-chip {
  background: #1a2029;
  border-color: #303947;
  color: #dce4f1;
}

html[data-theme="dark"] .plan-chip.is-active {
  background: rgba(105, 200, 151, 0.16);
  border-color: rgba(105, 200, 151, 0.34);
}

html[data-theme="dark"] .plan-chip__hint {
  color: #93a0b4;
}

html[data-theme="dark"] .metric-plan-badge.is-standard {
  background: #262e3a;
  color: #cfd7e4;
}

html[data-theme="dark"] .metric-plan-badge.is-premium {
  background: rgba(255, 205, 120, 0.16);
  color: #ffd88c;
}

html[data-theme="dark"] .metric-plan-badge.is-plus {
  background: rgba(111, 148, 255, 0.18);
  color: #bfd0ff;
}

html[data-theme="dark"] .metric-plan-badge.is-pro {
  background: rgba(187, 128, 255, 0.2);
  color: #d6b7ff;
}

.stocks-cluster-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stocks-cluster-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f9fbff;
}

html[data-theme="dark"] .stocks-cluster-pill {
  background: #1a2029;
  border-color: #303947;
}

html[data-theme="dark"] .campaign-state-badge.is-active {
  background: rgba(87, 218, 152, 0.18);
  color: #71e7aa;
}

html[data-theme="dark"] .campaign-state-badge.is-inactive {
  background: rgba(255, 219, 130, 0.22);
  color: #ffe090;
}

html[data-theme="dark"] .campaign-state-badge.is-archived {
  background: rgba(122, 141, 169, 0.28);
  color: #b7c8e0;
}

.metric-filter-popover {
  width: 360px;
}

.metric-filter-popover__body {
  display: grid;
  gap: 10px;
}

.metric-filter-popover__inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-filter-popover__ranges {
  display: grid;
  gap: 8px;
}

.metric-filter-popover__ranges input[type="range"] {
  width: 100%;
}

.metric-filter-popover__hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.rowspan-cell {
  vertical-align: middle !important;
}

.rowspan-photo,
.rowspan-article {
  text-align: center;
}

.rowspan-photo .item-photo {
  margin-left: auto;
  margin-right: auto;
}

.column-filter-popover__head,
.column-filter-popover__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.column-filter-popover__list {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  overflow: auto;
  max-height: 38vh;
  background: #f8fbff;
}

.popover-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px;
  font-size: 0.9rem;
}

.popover-check input {
  margin-top: 2px;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  white-space: nowrap;
}

.num {
  white-space: nowrap;
}

.num.is-critical-low,
.total-cell.is-critical-low {
  color: var(--red);
  background: rgba(217, 74, 74, 0.1);
  border-radius: 8px;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 26px 16px;
}

@media (max-width: 1600px) {
  .toolbar-grid--top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-grid,
  .toolbar-grid--main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-manager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .toolbar-grid--top,
  .toolbar-grid,
  .toolbar-grid--main,
  .items-filters,
  .items-metric-filters,
  .tag-editor {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .system-panel__row,
  .action-group,
  .action-group--compact {
    flex-direction: column;
    align-items: stretch;
  }

  .metrics-manager {
    grid-template-columns: 1fr;
  }

  .threshold-control {
    justify-content: space-between;
    width: 100%;
  }

  .threshold-control input {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .page-shell {
    width: min(100vw - 16px, 1800px);
  }

  .hero {
    flex-direction: column;
  }

  .hero-tools {
    width: 100%;
  }
}
