:root {
  --sidebar-width: clamp(168px, 12vw, 220px);
  --page-padding: clamp(12px, 1.4vw, 24px);
  --panel-radius: 8px;
  --bg: #edf4f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe4f0;
  --blue: #2563eb;
  --blue-soft: #eaf2ff;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 18px 48px rgba(15, 23, 42, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #f6fbff 0, var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
}

body:not(.authenticated) .sidebar,
body:not(.authenticated) .sidebar-toggle,
body:not(.authenticated) .sidebar-resize-handle,
body:not(.authenticated) .main {
  display: none;
}

body.authenticated .login-screen {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.login-screen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #edf4f8;
}

.login-card {
  width: min(400px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.login-brand {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
}

.login-card h1 {
  margin: 6px 0 0;
  font-size: 22px;
  text-align: center;
}

.login-card p {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.login-card label {
  display: block;
  margin-bottom: 16px;
}

.login-card input {
  height: 48px;
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
}

.login-card .btn {
  width: 100%;
  height: 52px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  font-size: 17px;
  box-shadow: none;
}

.login-card .btn:hover {
  background: #1d4ed8;
  box-shadow: none;
}

@media (max-width: 900px) {
  .login-screen {
    padding: 20px;
  }
}

@media (max-width: 520px) {
  .login-screen {
    padding: 16px;
  }

  .login-card {
    border-radius: 8px;
    padding: 22px;
  }
}

.login-error {
  margin-top: 12px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  padding: 10px 12px;
  color: var(--red);
  font-weight: 800;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0, #f8fbff 100%);
  overflow-y: auto;
  padding-bottom: 18px;
  overflow-x: hidden;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.035);
  transition: transform 0.18s ease;
}

.brand {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.09), rgba(5, 150, 105, 0.06)),
    #fff;
}

.brand-title {
  font-size: 19px;
  font-weight: 900;
}

.brand-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

nav {
  padding: 12px 10px 18px;
}

.nav-group-title {
  margin: 16px 10px 7px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

nav a {
  position: relative;
  display: flex;
  height: 40px;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

nav a:hover {
  background: #f1f6fb;
  color: #0f172a;
  transform: translateX(1px);
}

nav a.active {
  background: linear-gradient(90deg, var(--blue-soft), #f8fbff);
  color: #1d4ed8;
  box-shadow: inset 3px 0 0 var(--blue), 0 8px 18px rgba(37, 99, 235, 0.08);
}

nav a.permission-hidden {
  display: none;
}

.main {
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: var(--page-padding);
  transition: margin-left 0.18s ease, width 0.18s ease;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 2px 0 4px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.topbar p,
.panel-head p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-guide-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #2563eb;
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.help-guide-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.help-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.34);
}

.help-guide-modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(76vh, 720px);
  overflow-y: auto;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 22px;
}

.help-guide-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.help-guide-close:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.help-guide-kicker {
  margin-bottom: 8px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 900;
}

.help-guide-modal h2 {
  padding-right: 40px;
  font-size: 22px;
}

.help-guide-modal p {
  margin-top: 8px;
  color: #475569;
  line-height: 1.65;
}

.help-guide-steps {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.help-guide-step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.help-guide-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.help-guide-step strong {
  display: block;
  color: #0f172a;
  font-size: 14px;
}

.help-guide-step span {
  display: block;
  margin-top: 4px;
  color: #475569;
  font-size: 13px;
  line-height: 1.55;
}

.top-actions {
  display: flex;
  flex: 1 1 360px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.auth-user {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.btn {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 16px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  color: #1d4ed8;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.btn.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.btn.primary:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
}

.install-app-btn {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: #047857;
}

.install-app-btn:hover {
  border-color: #86efac;
  background: #dcfce7;
  color: #065f46;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 12vw, 190px), 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 16px;
}

.date-shortcuts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  align-self: end;
}

.date-shortcuts button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-weight: 800;
  cursor: pointer;
}

.date-shortcuts button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 11px;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 40px;
}

textarea {
  min-height: 82px;
  padding-top: 10px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.notice {
  max-width: 100%;
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.notice.ok {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.notice.error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.assignment-alert,
.final-price-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  padding: 12px 14px;
  color: #9a3412;
  font-size: 14px;
  font-weight: 800;
}

.assignment-alert .sub,
.final-price-alert .sub {
  margin-top: 5px;
  color: #9a3412;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.assignment-alert .btn,
.final-price-alert .btn {
  flex: 0 0 auto;
  height: 34px;
  border-color: #fdba74;
}

.assignment-alert {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.assignment-alert .sub {
  color: #1e40af;
}

.assignment-alert .btn {
  border-color: #93c5fd;
}

.assignment-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 310px;
  overflow: auto;
}

.assignment-item {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 0.9fr);
  gap: 10px;
  align-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.assignment-meta {
  min-width: 0;
}

.assignment-meta strong {
  display: block;
  overflow: hidden;
  color: #0f172a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-meta span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-bind {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.assignment-bind input {
  width: 100%;
  height: 34px;
}

.hidden {
  display: none !important;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 12vw, 190px), 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.config-panel {
  margin-bottom: 16px;
}

.diagnostic-panel {
  margin-bottom: 16px;
}

.diagnostic-body {
  padding: 16px 18px;
}

.diagnostic-summary {
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 14px;
}

.diagnostic-summary b {
  display: block;
  margin-bottom: 8px;
  color: #1e40af;
  font-size: 16px;
}

.diagnostic-summary ul {
  margin: 0;
  padding-left: 20px;
  color: #334155;
}

.diagnostic-summary li + li {
  margin-top: 4px;
}

.visible-accounts {
  margin-top: 14px;
}

.visible-accounts h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.account-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.account-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  font-size: 13px;
}

.account-chip b {
  display: block;
  margin-bottom: 4px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  padding: 18px;
}

.config-grid .wide {
  grid-column: 1 / -1;
}

.field-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.config-actions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.config-actions span {
  color: var(--muted);
  font-size: 13px;
}

.main > .config-panel,
.main > .log-panel,
.main > .permission-panel {
  margin-bottom: 16px;
}

.permission-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.permission-form,
.permission-right {
  min-width: 0;
}

.permission-form h3,
.permission-right h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.permission-form label {
  display: block;
  margin-bottom: 12px;
}

.permission-form .inline-check {
  display: flex;
  gap: 8px;
  align-items: center;
}

.permission-form .inline-check input {
  width: auto;
}

.permission-form .inline-check span {
  margin: 0;
}

.permission-actions {
  display: flex;
  gap: 10px;
}

.permission-actions .btn {
  flex: 1;
}

.permission-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.permission-checks label {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 0 10px;
  font-weight: 800;
}

.permission-checks input {
  width: auto;
}

.permission-checks span {
  margin: 0;
}

.permission-table-wrap {
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 820px) {
  .permission-layout {
    grid-template-columns: 1fr;
  }
}

.config-section-label {
  border-top: 1px solid var(--line);
  padding: 14px 18px 0;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.config-panel .panel-head + .config-section-label {
  border-top: 0;
}

.config-log-table {
  max-height: min(62vh, 640px);
  overflow: auto;
}

.meta-usage-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: 0 18px 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  padding: 10px 12px;
  color: #166534;
  font-size: 13px;
  line-height: 1.45;
}

.meta-usage-panel.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.meta-usage-panel.danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.meta-usage-panel.muted {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #475569;
}

.meta-usage-badge {
  display: inline-flex;
  align-items: center;
  min-width: 68px;
  justify-content: center;
  border-radius: 999px;
  background: #dcfce7;
  padding: 3px 8px;
  color: #166534;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.meta-usage-badge.warning {
  background: #fef3c7;
  color: #92400e;
}

.meta-usage-badge.danger {
  background: #fee2e2;
  color: #b91c1c;
}

.meta-usage-badge.muted {
  background: #f1f5f9;
  color: #64748b;
}


.sidebar .config-panel,
.sidebar .log-panel {
  margin: 12px;
  border-radius: 8px;
  box-shadow: none;
}

.sidebar .config-panel .panel-head,
.sidebar .log-panel .panel-head {
  display: block;
  padding: 14px;
}

.sidebar .config-panel h2,
.sidebar .log-panel h2 {
  font-size: 16px;
}

.sidebar .config-panel .panel-head p,
.sidebar .log-panel .panel-head p {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.45;
}

.sidebar .config-panel .account-info {
  max-width: none;
  margin-top: 8px;
  text-align: left;
  font-size: 12px;
}

.sidebar .config-grid {
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
}

.sidebar .config-grid .wide,
.sidebar .config-actions {
  grid-column: auto;
}

.sidebar .config-actions {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.sidebar .config-actions .btn {
  width: 100%;
}

.sidebar .config-actions span {
  font-size: 12px;
  line-height: 1.45;
}

.sidebar label span {
  margin-bottom: 5px;
  font-size: 12px;
}

.sidebar input,
.sidebar select {
  height: 34px;
}

.sidebar textarea {
  min-height: 62px;
}

.sidebar #accountIdsInput {
  min-height: 58px;
}

.sidebar #coupangMatchRules {
  min-height: 86px;
}

.sidebar .config-section-label {
  border-top: 1px solid var(--line);
  padding: 12px 14px 0;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.sidebar .config-panel .panel-head + .config-section-label {
  border-top: 0;
}

.sidebar .config-log-table {
  max-height: 360px;
  margin-top: 10px;
  overflow: auto;
}

.sidebar .config-log-table table {
  min-width: 640px;
  table-layout: fixed;
  font-size: 12px;
}

.sidebar .config-log-table th,
.sidebar .config-log-table td {
  overflow: hidden;
  padding: 8px;
  text-overflow: ellipsis;
}

.sidebar .config-log-table th:nth-child(1) { width: 120px; }
.sidebar .config-log-table th:nth-child(2) { width: 42px; }
.sidebar .config-log-table th:nth-child(3) { width: 56px; }
.sidebar .config-log-table th:nth-child(4) { width: 52px; }
.sidebar .config-log-table th:nth-child(5) { width: 66px; }
.sidebar .config-log-table th:nth-child(6) { width: 88px; }
.sidebar .config-log-table th:nth-child(7) { width: 216px; }

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0, #fbfdff 100%);
  padding: clamp(12px, 1vw, 16px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.035);
}

.card span {
  color: var(--muted);
  font-size: 13px;
}

.card b {
  display: block;
  margin-top: 9px;
  font-size: clamp(18px, 1.45vw, 24px);
  line-height: 1.1;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0, #fbfdff 100%);
  padding: 16px 18px;
}

.account-info {
  max-width: 420px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

body[data-view-mode="ads"] .product-frozen-head {
  position: sticky;
  top: 0;
  z-index: 55;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.product-roi-panel {
  margin: 12px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.product-roi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.product-roi-title {
  color: #0f172a;
  font-size: 14px;
  font-weight: 900;
}

.product-roi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px 14px;
}

.product-roi-cards > div {
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.product-roi-cards > div.product-roi-primary {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
}

.product-roi-cards span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-roi-cards b {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 19px;
  line-height: 1.1;
}

.product-roi-primary b {
  color: #1d4ed8;
}

.product-roi-periods {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.product-roi-period-card {
  min-width: 0;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.product-roi-period-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.product-roi-period-card b {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 20px;
  line-height: 1.1;
}

.product-roi-period-card small {
  display: block;
  margin-top: 7px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.product-roi-chart {
  margin: 0 14px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.product-roi-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.product-roi-chart-head strong {
  display: block;
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.product-roi-chart-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-roi-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: flex-end;
}

.product-roi-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #334155;
  white-space: nowrap;
}

.product-roi-chart-legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.product-roi-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
}

.product-roi-chart-grid {
  stroke: #e2e8f0;
  stroke-width: 1;
}

.product-roi-chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product-roi-chart-label {
  fill: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.product-roi-sections {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  padding: 0 14px 14px;
}

.product-roi-section {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.product-roi-section-title {
  border-bottom: 1px solid #e2e8f0;
  padding: 9px 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.product-roi-table {
  min-width: 560px;
  font-size: 12px;
}

.product-roi-table th,
.product-roi-table td {
  padding: 8px 10px;
}

.manual-spend-cell {
  min-width: 180px;
}

.manual-spend-editor {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.manual-ad-spend-input {
  width: 86px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 1900px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th {
  border-bottom: 1px solid var(--line);
  background: #f7fafd;
  padding: 11px 12px;
  color: #475569;
  font-weight: 900;
  text-align: left;
  white-space: nowrap;
}

.has-tip {
  cursor: help;
  text-decoration: underline dotted rgba(71, 85, 105, 0.55);
  text-underline-offset: 3px;
}

.hover-tip {
  position: fixed;
  z-index: 99999;
  max-width: min(320px, calc(100vw - 24px));
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
  color: #fff;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.hover-tip.show {
  opacity: 1;
  transform: translateY(0);
}

td {
  border-bottom: 1px solid #edf2f7;
  padding: 11px 12px;
  vertical-align: middle;
  white-space: nowrap;
}

tr:hover td {
  background: #f8fbff;
}

.name {
  max-width: 320px;
  white-space: normal;
  font-weight: 800;
}

.sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.status.active {
  background: #dcfce7;
  color: var(--green);
}

.status.paused {
  background: #fef3c7;
  color: var(--amber);
}

.status.deleted,
.status.archived {
  background: #fee2e2;
  color: var(--red);
}

.num {
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.compact table {
  min-width: 1050px;
}

.trend-panel {
  margin-bottom: 16px;
}

.external-system-panel {
  margin-bottom: 16px;
}

.robot-design-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
}

.robot-design-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: #fff;
}

.robot-design-grid b {
  display: block;
  margin-bottom: 6px;
  color: #0f172a;
  font-size: 13px;
}

.robot-design-grid span {
  display: block;
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}

.external-system-frame {
  display: block;
  width: 100%;
  height: calc(100dvh - 170px);
  min-height: min(680px, calc(100dvh - 150px));
  border: 0;
  background: #fff;
}

.daily-trend-table table {
  min-width: 1220px;
}

.returns-table table {
  min-width: 1180px;
}





.sidebar-toggle {
  position: fixed;
  z-index: 50;
  top: 18px;
  left: calc(var(--sidebar-width) - 13px);
  width: 26px;
  height: 54px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #1d4ed8;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  transition: left 0.18s ease, background 0.15s ease, border-color 0.15s ease;
}

.sidebar-toggle:hover {
  border-color: var(--blue);
  background: #eff6ff;
}

.sidebar-resize-handle {
  position: fixed;
  z-index: 45;
  top: 0;
  bottom: 0;
  left: calc(var(--sidebar-width) - 3px);
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: left 0.18s ease, background 0.15s ease;
}

.sidebar-resize-handle:hover,
body.sidebar-resizing .sidebar-resize-handle {
  background: rgba(37, 99, 235, 0.18);
}

body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

body.sidebar-resizing .main,
body.sidebar-resizing .sidebar-toggle,
body.sidebar-resizing .sidebar-resize-handle {
  transition: none;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
  pointer-events: none;
}

body.sidebar-collapsed .main {
  width: 100%;
  margin-left: 0;
}

body.sidebar-collapsed .sidebar-toggle {
  left: 8px;
}

body.sidebar-collapsed .sidebar-resize-handle {
  left: 0;
  width: 12px;
}

body.sidebar-collapsed .sidebar-toggle {
  color: var(--blue);
}

@media (max-width: 1100px) {
  .sidebar-toggle,
  .sidebar-resize-handle {
    display: none;
  }
}

@media (min-width: 1501px) {
  .cards {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

@media (max-width: 1366px) {
  :root {
    --sidebar-width: 172px;
    --page-padding: 12px;
  }

  h1 {
    font-size: 24px;
  }

  .brand {
    padding-inline: 14px;
  }

  nav {
    padding-inline: 8px;
  }

  nav a {
    padding-inline: 10px;
    font-size: 13px;
  }

  .filters {
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 10px;
    padding: 14px;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
  }

  .card span {
    font-size: 12px;
  }

  .btn {
    padding-inline: 12px;
  }

  th,
  td {
    padding: 9px 10px;
    font-size: 12px;
  }

  .external-system-frame {
    height: calc(100dvh - 145px);
    min-height: 540px;
  }
}

@media (max-width: 1100px) {
  .main {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .top-actions {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .external-system-frame {
    height: calc(100dvh - 190px);
    min-height: 460px;
  }

  .robot-design-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
  }

  .brand {
    padding: 14px 16px 8px;
  }

  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px;
  }

  .nav-group-title {
    display: flex;
    flex: 0 0 auto;
    height: 36px;
    align-items: center;
    margin: 0 2px;
    padding: 0 4px;
  }

  nav a {
    flex: 0 0 auto;
    height: 36px;
  }

  .main {
    max-width: none;
    margin-left: 0;
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 22px;
  }

  .page-title-row {
    gap: 6px;
  }

  .help-guide-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .help-guide-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .help-guide-modal {
    max-height: 82vh;
    padding: 18px;
  }

  .notice {
    margin-bottom: 12px;
    padding: 9px 10px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
  }

  .filters,
  .cards,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .config-grid .wide,
  .config-actions {
    grid-column: 1 / -1;
  }

  .panel-head,
  .assignment-alert,
  .final-price-alert {
    align-items: flex-start;
    flex-direction: column;
  }

  .assignment-item,
  .assignment-bind {
    grid-template-columns: 1fr;
  }

  .account-info {
    max-width: none;
    text-align: left;
  }

  .btn {
    min-width: 0;
  }
}

@media (min-width: 1101px) and (max-width: 1500px) {
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


.product-group-row {
  cursor: pointer;
}

.product-group-row:hover {
  background: #f8fbff;
}

.product-group-row.expanded {
  background: #eff6ff;
}

.product-detail-row > td {
  background: #f8fafc;
  padding: 14px;
}

.product-detail {
  display: grid;
  gap: 10px;
}

.detail-title {
  color: #142033;
  font-weight: 800;
}

.detail-table {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #d8e1eb;
  border-radius: 8px;
  overflow: hidden;
}

.detail-table th,
.detail-table td {
  border-bottom: 1px solid #e7edf4;
  padding: 8px 10px;
  text-align: left;
}

.group-editor {
  min-width: 250px;
}

.manual-product-input {
  width: 170px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #142033;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.manual-product-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.mini-btn {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #d8e1eb;
  border-radius: 8px;
  background: #fff;
  color: #142033;
  font-weight: 800;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.mini-btn:disabled {
  cursor: wait;
  opacity: 0.55;
}

.save-manual-product {
  margin-left: 6px;
}

.product-picker-portal {
  position: fixed;
  z-index: 10000;
  max-height: min(420px, 70vh);
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 6px;
}

.product-picker-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  padding: 6px 8px;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.manual-replenishment-picker-option {
  display: flex;
  align-items: flex-start;
  width: 100%;
  min-height: 66px;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.product-picker-option:hover,
.product-picker-option:focus,
.manual-replenishment-picker-option:hover,
.manual-replenishment-picker-option:focus {
  background: #eff6ff;
  outline: none;
}

.product-picker-thumb {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  object-fit: cover;
}

.product-picker-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 14px;
  font-weight: 800;
}

.product-picker-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.product-picker-text strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-picker-text small {
  color: #64748b;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
}

.manual-replenishment-picker-text {
  gap: 4px;
}

.manual-replenishment-picker-text strong,
.manual-replenishment-picker-text small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-replenishment-picker-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.manual-replenishment-meta-chip {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef2ff;
  color: #475569;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-picker-empty {
  padding: 12px;
  color: #64748b;
  font-size: 13px;
}

.detail-note {
  margin-bottom: 8px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
}

body[data-view-mode="daily"] #diagnoseBtn,
body[data-view-mode="daily"] #exportBtn {
  display: none;
}

body[data-view-mode="daily"] #dailyReportPanel {
  margin-top: 0;
}

body[data-view-mode="logs"] #refreshBtn,
body[data-view-mode="logs"] #diagnoseBtn,
body[data-view-mode="logs"] #exportBtn,
body[data-view-mode="config"] #refreshBtn,
body[data-view-mode="config"] #diagnoseBtn,
body[data-view-mode="config"] #exportBtn {
  display: none;
}

.manual-detail-row td {
  background: #fffdf5;
}

.manual-detail-new td {
  border-top: 2px solid #f59e0b;
}

.manual-detail-actions {
  min-width: 150px;
}

.manual-detail-actions .mini-btn {
  margin-left: 6px;
}

.manual-detail-input {
  width: 112px;
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.manual-detail-input.wide {
  width: 170px;
}

.manual-detail-input.num {
  width: 88px;
  text-align: right;
}

.creative-panel {
  margin-bottom: 16px;
}

.creative-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.creative-leaderboard {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.creative-leaderboard-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.creative-leaderboard-head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
}

.creative-leaderboard-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.creative-rank-table {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.creative-rank-table table {
  min-width: 940px;
}

.creative-table table {
  min-width: 2400px;
}

.creative-editor-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 168px;
}

.creative-editor-input {
  width: 112px;
  height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 8px;
  background: #fff;
  color: #0f172a;
  font-size: 12px;
}

.creative-editor-input[readonly] {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #334155;
}

.creative-editor-input.is-editing {
  background: #fff;
  border-color: #2563eb;
}

.creative-save-editor {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
}

.creative-score {
  min-width: 86px;
  color: #0f172a;
  font-weight: 900;
}

.creative-score .sub {
  margin-top: 2px;
  font-weight: 700;
}

.creative-commission {
  color: #b45309;
  font-weight: 900;
}

.creative-hit {
  background: #fff7ed;
  color: #c2410c;
}

.creative-reason {
  display: inline-block;
  margin: 2px 5px 2px 0;
  border-radius: 999px;
  background: #eff6ff;
  padding: 3px 8px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}


.metric-stack {
  max-width: 190px;
  color: #334155;
  font-size: 12px;
  line-height: 1.55;
  white-space: normal;
}

.creative-trend {
  min-width: 260px;
  color: #334155;
  font-size: 12px;
  line-height: 1.55;
  white-space: normal;
}

.creative-trend div + div {
  margin-top: 2px;
}

.budget-trend {
  min-width: 190px;
  white-space: normal;
  line-height: 1.45;
}

.budget-trend strong {
  display: block;
  font-size: 12px;
  font-weight: 900;
}

.budget-trend span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.budget-trend-good strong {
  color: var(--green);
}

.budget-trend-bad strong {
  color: var(--red);
}

.budget-trend-watch strong,
.budget-trend-stable strong {
  color: var(--amber);
}

.budget-trend-neutral strong {
  color: #64748b;
}

.replenishment-panel {
  margin-bottom: 16px;
}

.replenishment-cards {
  padding: 16px 18px 0;
}

.manual-replenishment-entry {
  margin: 14px 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.manual-replenishment-picker {
  max-height: min(520px, 74vh);
}

.manual-replenishment-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.manual-replenishment-title h3 {
  margin: 0;
  font-size: 15px;
}

.manual-replenishment-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.manual-replenishment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.manual-replenishment-grid label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.manual-replenishment-grid label.wide {
  grid-column: span 2;
  min-width: 220px;
}

.manual-replenishment-grid input,
.manual-replenishment-grid select {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.manual-replenishment-grid .btn {
  min-height: 34px;
}

.purchase-entry {
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.purchase-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  padding: 16px 18px 18px;
}

.panel-subhead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 8px;
  border-top: 1px solid var(--line);
}

.panel-subhead h3 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
}

.panel-subhead p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.purchase-replenishment-table {
  margin-top: 0;
}

.purchase-replenishment-table table {
  min-width: 1840px;
}

.purchase-replenishment-input {
  width: 100%;
  min-width: 112px;
  height: 34px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 12px;
}

.purchase-replenishment-input.product-name-input {
  min-width: 180px;
}

.purchase-replenishment-input.purchase-url-input,
.purchase-replenishment-input.purchase-note-input {
  min-width: 170px;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

.muted-cell {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.logistics-replenishment-table {
  margin-top: 0;
}

.logistics-replenishment-table table {
  min-width: 2480px;
}

.logistics-replenishment-table td {
  vertical-align: middle;
}

.logistics-replenishment-input {
  min-width: 104px;
  height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.logistics-note-input {
  min-width: 180px;
}

.tracking-status-cell {
  min-width: 220px;
}

.tracking-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  max-width: 300px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.tracking-status b {
  color: var(--text);
  font-size: 12px;
}

.tracking-status small {
  color: var(--muted);
}

.tracking-status.success b {
  color: #059669;
}

.tracking-status.info b {
  color: #2563eb;
}

.tracking-status.warning b {
  color: #d97706;
}

.tracking-status.danger b {
  color: #dc2626;
}

.tracking-status.muted,
.tracking-status.muted b {
  color: #94a3b8;
}

.manual-replenishment-sku-detail {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.manual-replenishment-sku-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.manual-replenishment-sku-head strong,
.manual-replenishment-sku-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-replenishment-sku-head strong {
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.manual-replenishment-sku-head small,
.manual-replenishment-sku-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-replenishment-sku-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}

.manual-replenishment-sku-option {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 10px;
  padding: 8px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  text-align: left;
  cursor: pointer;
}

.manual-replenishment-sku-option:hover,
.manual-replenishment-sku-option:focus {
  border-color: #93c5fd;
  background: #eff6ff;
  outline: none;
}

.manual-replenishment-sku-option.selected {
  border-color: var(--blue);
  background: #eaf2ff;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.manual-replenishment-selected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  max-width: 420px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manual-replenishment-selected.selected {
  color: #0f172a;
}

.manual-replenishment-selected img {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

.manual-replenishment-selected small {
  color: var(--muted);
}

.replenishment-table table {
  min-width: 1880px;
}

.replenishment-product-table {
  margin-top: 12px;
}

.replenishment-product-table table {
  min-width: 2260px;
}

.replenishment-panel > .replenishment-table {
  display: none;
}

.replenishment-product-table td:nth-child(6),
.replenishment-product-table td:nth-child(11),
.replenishment-product-table td:nth-child(12),
.replenishment-product-table td:nth-child(13),
.replenishment-product-table td:nth-child(14),
.replenishment-table td:nth-child(9) {
  font-weight: 800;
}

.replenishment-table .progress-cell,
.replenishment-product-table .progress-cell {
  min-width: 230px;
}

.replenishment-table .text-cell,
.replenishment-product-table .text-cell {
  max-width: 240px;
  white-space: normal;
  line-height: 1.45;
}

.replenishment-table a {
  color: var(--blue);
  font-weight: 800;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-right: 6px;
  padding: 3px 7px;
  border-radius: 6px;
  color: #475569;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.source-badge.manual {
  color: #2563eb;
  background: #dbeafe;
}

.source-badge.sample {
  color: #9333ea;
  background: #f3e8ff;
}

.mini-btn.danger {
  color: #dc2626;
  border-color: #fecaca;
}

.mini-btn.danger:hover {
  background: #fee2e2;
}

.replenishment-product {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.replenishment-product.compact {
  min-width: 220px;
}

.replenishment-product img,
.replenishment-product-placeholder {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef4fb;
  object-fit: cover;
}

.replenishment-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.replenishment-status.linked {
  color: #059669;
  background: #d1fae5;
}

.replenishment-status.unmatched {
  color: #b45309;
  background: #fef3c7;
}

.replenishment-status.missing {
  color: #dc2626;
  background: #fee2e2;
}

.replenishment-progress {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.replenishment-progress.danger {
  color: #dc2626;
  background: #fee2e2;
}

.replenishment-progress.warning {
  color: #b45309;
  background: #fef3c7;
}

.replenishment-progress.info {
  color: #2563eb;
  background: #dbeafe;
}

.replenishment-progress.success {
  color: #059669;
  background: #d1fae5;
}

.replenishment-progress.neutral {
  color: #475569;
  background: #f1f5f9;
}

.replenishment-progress-card {
  display: grid;
  gap: 5px;
  min-width: 220px;
  max-width: 320px;
}

.replenishment-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.replenishment-progress-head span:last-child {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.replenishment-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(18px, 1fr));
  gap: 4px;
}

.replenishment-track span {
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
}

.replenishment-track.step-1 span:nth-child(-n+1),
.replenishment-track.step-2 span:nth-child(-n+2),
.replenishment-track.step-3 span:nth-child(-n+3),
.replenishment-track.step-4 span:nth-child(-n+4),
.replenishment-track.step-5 span:nth-child(-n+5) {
  background: #2563eb;
}

.replenishment-progress-card.success .replenishment-track span,
.replenishment-progress-card.success .replenishment-track.step-5 span {
  background: #10b981;
}

.replenishment-progress-card.status-problem .replenishment-track span:nth-child(-n+5) {
  background: #ef4444;
}

.replenishment-track-labels {
  display: grid;
  grid-template-columns: repeat(5, minmax(18px, 1fr));
  color: #64748b;
  font-size: 11px;
  line-height: 1.2;
}

.replenishment-track-labels span {
  text-align: center;
}

.replenishment-current {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.replenishment-next {
  font-weight: 800;
  color: #0f172a;
}

.replenishment-product-row.is-expanded {
  background: #eff6ff;
}

.replenishment-expand-row > td {
  padding: 0;
  background: #f8fbff;
}

.replenishment-detail-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.replenishment-detail-section {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.replenishment-detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 900;
}

.replenishment-detail-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nested-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.nested-table th,
.nested-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: middle;
}

.nested-table th {
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.nested-table .text-cell {
  max-width: 260px;
  white-space: normal;
  line-height: 1.45;
}

.compact-empty {
  padding: 14px;
}

.replenishment-sku-risk,
.replenishment-suggestion {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.replenishment-sku-risk.danger,
.replenishment-suggestion.danger {
  color: #dc2626;
  background: #fee2e2;
}

.replenishment-sku-risk.warning,
.replenishment-suggestion.warning {
  color: #b45309;
  background: #fef3c7;
}

.replenishment-sku-risk.ok,
.replenishment-suggestion.ok {
  color: #059669;
  background: #d1fae5;
}

.replenishment-sku-risk.neutral,
.replenishment-suggestion.neutral {
  color: #475569;
  background: #f1f5f9;
}

.finance-panel {
  margin-bottom: 16px;
}

.finance-cards {
  padding: 16px 18px 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.finance-summary-card {
  min-height: 92px;
  border-top: 4px solid #dbeafe;
}

.finance-summary-card.income {
  border-top-color: #10b981;
}

.finance-summary-card.expense {
  border-top-color: #f59e0b;
}

.finance-summary-card.net {
  border-top-color: #2563eb;
}

.finance-summary-card small {
  display: block;
  margin-top: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.finance-negative {
  color: #dc2626 !important;
}

.finance-workspace {
  display: grid;
  grid-template-columns: minmax(440px, 1.15fr) minmax(360px, 0.85fr);
  gap: 14px;
  margin: 14px 18px 0;
  align-items: start;
}

.finance-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.finance-entry {
  padding: 14px;
  margin: 0;
}

.finance-entry-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.finance-sources {
  padding: 14px;
  margin: 0;
}

.finance-records {
  margin: 14px 18px 0;
  overflow: hidden;
}

.finance-records .panel-subhead {
  padding: 14px 14px 10px;
}

.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.finance-grid label {
  display: grid;
  gap: 5px;
  color: #102a43;
  font-size: 12px;
  font-weight: 800;
}

.finance-grid label.wide {
  grid-column: 1 / -1;
  min-width: 0;
}

.finance-mode-hidden {
  display: none !important;
}

.finance-grid input,
.finance-grid select {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.finance-grid .btn {
  min-height: 38px;
}

.finance-source-list {
  display: grid;
  gap: 10px;
}

.finance-source-item {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.finance-source-item.income {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.finance-source-item.expense {
  border-color: #fde68a;
  background: #fffbeb;
}

.finance-source-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.finance-source-top strong {
  display: block;
  margin-top: 8px;
  color: #0f172a;
  font-size: 14px;
}

.finance-source-top small {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
}

.finance-source-top b {
  color: #0f172a;
  font-size: 20px;
  white-space: nowrap;
}

.finance-source-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.finance-source-meta span {
  padding: 7px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: #0f172a;
  font-size: 12px;
  line-height: 1.35;
}

.finance-source-meta em {
  display: block;
  margin-bottom: 2px;
  color: #64748b;
  font-size: 11px;
  font-style: normal;
}

.finance-source-item p {
  margin: 10px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.finance-source-empty {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  text-align: center;
}

.finance-table table {
  min-width: 1180px;
}

.finance-table {
  margin: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
}

.finance-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.finance-badge.income {
  color: #047857;
  background: #d1fae5;
}

.finance-badge.expense {
  color: #b45309;
  background: #fef3c7;
}

.finance-source-detail,
.finance-table .text-cell {
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

@media (max-width: 1200px) {
  .finance-cards {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .finance-workspace {
    grid-template-columns: 1fr;
  }

  .finance-entry-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .finance-grid,
  .finance-source-meta {
    grid-template-columns: 1fr;
  }
}

.traffic-panel {
  margin-bottom: 16px;
}

.traffic-safe-note {
  display: flex;
  gap: 8px;
  margin: 14px 18px 0;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.5;
}

.traffic-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 18px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.traffic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
}

.traffic-toggle input {
  width: 16px;
  height: 16px;
}

.traffic-entry {
  margin: 14px 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.traffic-builder {
  margin: 14px 18px 0;
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
}

.traffic-plan-grid,
.traffic-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}

.traffic-plan-grid label,
.traffic-rule-grid label {
  display: grid;
  gap: 5px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.traffic-plan-grid label.wide,
.traffic-rule-grid label.wide {
  grid-column: span 2;
  min-width: 260px;
}

.traffic-plan-grid input,
.traffic-plan-grid select,
.traffic-plan-grid textarea,
.traffic-rule-grid input,
.traffic-rule-grid select,
.traffic-rule-grid textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.traffic-plan-grid textarea,
.traffic-rule-grid textarea {
  resize: vertical;
}

.traffic-rule-grid .traffic-toggle {
  align-self: end;
  justify-content: center;
  min-height: 34px;
  background: #fff;
}

.traffic-plan-grid .btn,
.traffic-rule-grid .btn {
  min-height: 34px;
}

.traffic-plan-table,
.traffic-rule-table,
.traffic-candidate-table,
.traffic-log-table {
  margin-top: 14px;
}

.traffic-plan-table table {
  min-width: 1280px;
}

.traffic-rule-table table {
  min-width: 1080px;
}

.traffic-candidate-table table {
  min-width: 1180px;
}

.traffic-log-table table {
  min-width: 1120px;
}

.traffic-panel .text-cell {
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.btn.danger {
  color: #fff;
  background: #dc2626;
}

.btn.danger:hover {
  background: #b91c1c;
}

.btn.ghost {
  color: #334155;
  background: #fff;
}

@media (max-width: 1400px) {
  .manual-replenishment-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .manual-replenishment-grid label.wide {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .manual-replenishment-title {
    flex-direction: column;
  }

  .manual-replenishment-grid {
    grid-template-columns: 1fr;
  }

  .manual-replenishment-grid label.wide {
    grid-column: auto;
  }

  .traffic-plan-grid,
  .traffic-rule-grid {
    grid-template-columns: 1fr;
  }

  .traffic-plan-grid label.wide,
  .traffic-rule-grid label.wide {
    grid-column: auto;
    min-width: 0;
  }
}



@media (max-height: 760px) and (min-width: 1101px) {
  .external-system-frame {
    height: calc(100dvh - 120px);
    min-height: 480px;
  }

  .topbar {
    margin-bottom: 12px;
  }
}


.product-table-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  border-right: 1px solid var(--line);
  scrollbar-gutter: stable;
  background: #fff;
}

.product-table-wrap table {
  width: var(--product-table-width, 100%);
  min-width: 0;
  table-layout: fixed;
  font-size: clamp(11px, 0.62vw, 13px);
}

.product-table-wrap th,
.product-table-wrap td {
  padding: clamp(6px, 0.42vw, 10px) clamp(4px, 0.34vw, 8px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.product-table-wrap .name {
  max-width: none;
}

.product-table-wrap .sub {
  font-size: clamp(10px, 0.55vw, 12px);
}

.product-table-wrap .manual-spend-cell {
  min-width: 0;
}

.product-table-wrap .manual-spend-editor {
  flex-wrap: wrap;
}

.product-table-wrap .manual-ad-spend-input {
  width: min(86px, 100%);
}

.product-table-wrap th.sortable {
  cursor: pointer;
  position: relative;
  padding-right: 18px;
  user-select: none;
}

.product-table-wrap th.sortable::after {
  color: #94a3b8;
  content: "↕";
  font-size: 10px;
  line-height: 1;
  opacity: 0.75;
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
}

.product-table-wrap th.sortable:hover {
  background: #eff6ff;
  color: var(--primary);
}

.product-table-wrap th.sortable.sorted-asc,
.product-table-wrap th.sortable.sorted-desc {
  color: var(--primary);
}

.product-table-wrap th.sortable.sorted-asc::after {
  color: var(--primary);
  content: "↑";
  opacity: 1;
}

.product-table-wrap th.sortable.sorted-desc::after {
  color: var(--primary);
  content: "↓";
  opacity: 1;
}

.product-table-wrap thead th {
  position: sticky;
  top: var(--product-table-sticky-offset, 0px);
  z-index: 18;
}

#productGroupTable > thead th:first-child,
#productGroupTable > tbody > tr.product-group-row > td:first-child {
  position: sticky;
  left: 0;
  z-index: 12;
  width: 7.5%;
  min-width: 0;
  max-width: none;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

#productGroupTable > thead th:first-child {
  top: var(--product-table-sticky-offset, 0px);
  z-index: 28;
  background: #f8fafc;
}

#productGroupTable > tbody > tr.product-group-row:hover > td:first-child {
  background: #f8fafc;
}

.product-table-head-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  overscroll-behavior-x: contain;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.product-table-head-wrap table {
  width: var(--product-table-width, 100%);
  min-width: 0;
  table-layout: fixed;
  font-size: clamp(11px, 0.62vw, 13px);
}

.product-table-head-wrap th {
  padding: clamp(6px, 0.42vw, 10px) clamp(4px, 0.34vw, 8px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.product-table-head-wrap th.sortable {
  cursor: pointer;
  position: relative;
  padding-right: 18px;
  user-select: none;
}

.product-table-head-wrap th.sortable::after {
  position: absolute;
  right: 5px;
  top: 50%;
  color: #94a3b8;
  content: "\2195";
  font-size: 10px;
  line-height: 1;
  opacity: 0.75;
  transform: translateY(-50%);
}

.product-table-head-wrap th.sortable:hover {
  background: #eff6ff;
  color: var(--primary);
}

.product-table-head-wrap th.sortable.sorted-asc,
.product-table-head-wrap th.sortable.sorted-desc {
  color: var(--primary);
}

.product-table-head-wrap th.sortable.sorted-asc::after {
  color: var(--primary);
  content: "\2191";
  opacity: 1;
}

.product-table-head-wrap th.sortable.sorted-desc::after {
  color: var(--primary);
  content: "\2193";
  opacity: 1;
}

.product-table-wrap thead.product-body-head {
  display: none;
}

#productHeaderTable > thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 28;
  width: 7.5%;
  min-width: 0;
  max-width: none;
  background: #f8fafc;
  box-shadow: 1px 0 0 var(--line);
}

.product-table-resize-handle {
  position: absolute;
  z-index: 35;
  top: 0;
  right: 0;
  bottom: 0;
  width: 9px;
  cursor: ew-resize;
  background: transparent;
}

.product-table-resize-handle::after {
  position: absolute;
  top: 0;
  right: 3px;
  bottom: 0;
  width: 2px;
  background: rgba(37, 99, 235, 0.18);
  content: "";
  opacity: 0;
}

.product-table-resize-handle:hover::after,
body.product-table-resizing .product-table-resize-handle::after {
  opacity: 1;
}

body.product-table-resizing {
  cursor: ew-resize;
  user-select: none;
}

body.product-table-resizing .product-table-wrap {
  transition: none;
}

.product-archive-panel {
  margin-bottom: 16px;
}

.product-archive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.product-archive-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.product-archive-toolbar label {
  display: grid;
  gap: 6px;
}

.product-archive-table-wrap {
  max-height: calc(100vh - 360px);
  overflow: auto;
}

.product-archive-table {
  min-width: 1160px;
}

.product-archive-table th,
.product-archive-table td {
  vertical-align: middle;
}

.product-archive-group-row {
  background: #fff;
}

.product-archive-group-row:hover {
  background: #f8fbff;
}

.product-archive-thumb {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #f8fafc;
}

.product-archive-thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.product-archive-name {
  display: grid;
  gap: 3px;
  max-width: 460px;
}

.product-archive-name b {
  color: var(--text);
  line-height: 1.35;
}

.product-archive-price-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.product-final-price-input {
  width: 132px;
  height: 34px;
}

.product-archive-status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.product-archive-status.ok {
  color: #047857;
  background: #d1fae5;
}

.product-archive-status.missing {
  color: #b91c1c;
  background: #fee2e2;
}

.product-archive-status.partial {
  color: #92400e;
  background: #fef3c7;
}

.product-archive-group-price {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.product-archive-group-price > span:last-child {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.product-archive-detail-row > td {
  padding: 0;
  background: #f8fafc;
}

.product-archive-sku-detail {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.product-archive-detail-title {
  margin-bottom: 10px;
  font-weight: 800;
  color: var(--text);
}

.product-archive-sku-detail table {
  width: 100%;
  min-width: 980px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.product-archive-sku-detail th,
.product-archive-sku-detail td {
  padding: 9px 10px;
}

.product-archive-sku-detail th {
  background: #f1f5f9;
}

@media (max-width: 900px) {
  .product-archive-toolbar {
    grid-template-columns: 1fr;
  }

  .product-archive-actions {
    justify-content: flex-start;
  }

  .product-roi-cards,
  .product-roi-sections {
    grid-template-columns: 1fr;
  }

  .product-table-wrap {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
  }

  .product-table-wrap table {
    min-width: 1100px;
  }

  .product-table-resize-handle {
    display: none;
  }
}

@media (max-width: 720px) {
  body {
    background: #eef5f8;
  }

  .sidebar {
    overscroll-behavior-x: contain;
  }

  .brand {
    padding: 10px 12px 6px;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-sub {
    margin-top: 3px;
  }

  nav {
    gap: 6px;
    padding: 7px 10px 9px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group-title {
    height: 34px;
    font-size: 10px;
  }

  nav a {
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    white-space: nowrap;
  }

  .main {
    padding: 10px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .topbar p,
  .panel-head p {
    font-size: 12px;
    line-height: 1.45;
  }

  .top-actions {
    display: grid;
    width: 100%;
    flex-basis: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .top-actions .auth-user {
    grid-column: 1 / -1;
    min-height: 36px;
    justify-content: center;
  }

  .top-actions .btn {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  .top-actions .install-app-btn {
    grid-column: 1 / -1;
  }

  .filters {
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px;
  }

  input,
  select,
  textarea {
    min-height: 42px;
  }

  .date-shortcuts {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .date-shortcuts .btn {
    height: 36px;
    padding: 0 4px;
    font-size: 12px;
  }

  .cards,
  .creative-cards,
  .replenishment-cards,
  .finance-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .card {
    padding: 10px;
  }

  .card span {
    font-size: 12px;
  }

  .card b {
    font-size: 20px;
  }

  .panel-head {
    padding: 12px;
  }

  .table-wrap,
  .product-table-wrap,
  .product-archive-table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  .external-system-frame {
    height: calc(100dvh - 150px);
    min-height: 420px;
  }
}

@media (max-width: 420px) {
  .cards,
  .creative-cards,
  .replenishment-cards,
  .finance-cards {
    grid-template-columns: 1fr;
  }
}
