:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #667085;
  --line: #d9e0e8;
  --line-strong: #c5ced9;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b45309;
  --red: #b42318;
  --purple: #6d28d9;
  --shadow: 0 14px 32px rgba(19, 31, 53, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f1f5f9;
}

.login-screen.is-hidden {
  display: none;
}

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

.login-card h1 {
  margin: 0 0 6px;
}

.login-card .brand-mark {
  width: 46px;
  height: 46px;
}

.remember-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.remember-login input {
  width: auto;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.is-locked {
  visibility: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #111827;
  color: #e5e7eb;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f97316;
  color: #111827;
  font-weight: 800;
  font-size: 20px;
}

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

.brand-subtitle {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #93a4b8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-group-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.18s ease;
}

.nav-group.is-collapsed .nav-group-toggle svg {
  transform: rotate(-90deg);
}

.nav-group-items {
  display: grid;
  gap: 6px;
}

.nav-group.is-collapsed .nav-group-items {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: #243244;
  color: #ffffff;
}

.nav-item svg,
.topbar svg,
button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.main-panel {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 86px;
  padding: 18px 26px;
  background: rgba(244, 246, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-title {
  flex: 0 0 auto;
  min-width: 190px;
}

.ai-task-monitor-host {
  flex: 1 1 360px;
  min-width: 260px;
  max-width: 620px;
}

.ai-task-monitor-host[hidden] {
  display: none;
}

.ai-task-monitor {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.ai-task-monitor.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.ai-task-monitor-top,
.ai-task-monitor-main,
.ai-task-monitor-meta,
.ai-task-list {
  display: flex;
  align-items: center;
  min-width: 0;
}

.ai-task-monitor-top {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-task-monitor-top strong {
  color: var(--ink);
}

.ai-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #94a3b8;
}

.ai-task-monitor.is-active .ai-task-dot {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.ai-task-monitor-main {
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.ai-task-monitor-main span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-task-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.ai-task-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #0f766e);
  transition: width 220ms ease;
}

.ai-task-monitor-meta,
.ai-task-list {
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.ai-task-list {
  padding-top: 2px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.16;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 4px;
  font-size: 15px;
}

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

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 28vw);
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-clear-button {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #edf2f7;
  color: var(--muted);
}

.search-clear-button:hover {
  background: #e2e8f0;
  color: var(--ink);
}

.search-clear-button svg {
  width: 15px;
  height: 15px;
}

select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

select {
  padding: 0 34px 0 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"] {
  width: 100%;
  padding: 0 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-button {
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button,
.ghost-button,
.icon-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-button {
  padding: 0 12px;
}

.ghost-button {
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.tiny-button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.content-region {
  padding: 24px 26px 40px;
}

.view {
  display: none;
}

.view.is-visible {
  display: grid;
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.section-block,
.store-card,
.order-card,
.integration-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 116px;
  padding: 18px;
}

.ops-briefing {
  display: grid;
  gap: 18px;
}

.ops-briefing-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.38fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.ops-score-panel {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 128px;
  padding: 8px 18px 8px 0;
  border-right: 1px solid var(--line);
}

.ops-score-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: conic-gradient(var(--score-color, var(--green)) var(--score-angle, 0deg), #e5e7eb 0deg);
}

.ops-score-ring::after {
  position: absolute;
  inset: 10px;
  content: "";
  border-radius: 50%;
  background: #fff;
}

.ops-score-ring span {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.ops-score-panel h2,
.ops-score-panel p {
  margin: 0;
}

.ops-score-panel h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.ops-task-list {
  display: grid;
  align-content: start;
}

.ops-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.ops-task:last-child {
  border-bottom: 0;
}

.ops-task-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ops-task-icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--blue);
}

.ops-task-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.ops-task-title strong {
  font-size: 15px;
}

.ops-task-count {
  color: var(--blue-dark);
  font-size: 20px;
  font-weight: 800;
}

.ops-task.is-critical .ops-task-icon {
  background: #fee2e2;
  color: var(--red);
}

.ops-task.is-critical .ops-task-count {
  color: var(--red);
}

.ops-task.is-warning .ops-task-icon {
  background: #fef3c7;
  color: var(--amber);
}

.ops-task.is-warning .ops-task-count {
  color: var(--amber);
}

.ops-task.is-good .ops-task-icon {
  background: #dcfce7;
  color: var(--green);
}

.ops-task.is-good .ops-task-count {
  color: var(--green);
}

.metric-card .metric-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue);
}

.metric-value {
  margin: 6px 0 2px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.section-block {
  padding: 18px;
}

.section-heading,
.table-toolbar,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.order-stack,
.store-stack,
.activity-list {
  display: grid;
  gap: 10px;
}

.order-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  box-shadow: none;
}

.order-meta,
.store-meta,
.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

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

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

.pill.red {
  background: #fee2e2;
  color: var(--red);
}

.pill.purple {
  background: #f3e8ff;
  color: var(--purple);
}

.store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.store-row:last-child {
  border-bottom: 0;
}

.store-logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fff7ed;
  color: #c2410c;
  font-weight: 800;
}

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

.compact-table-wrap,
.table-wrap,
.wide-table-wrap {
  overflow-x: auto;
}

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

.table-wrap {
  min-height: 460px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

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

.operations-table {
  min-width: 1880px;
  font-size: 12px;
}

.operations-table th,
.operations-table td {
  white-space: nowrap;
}

.operations-table th:first-child,
.operations-table .product-info-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.operations-table th:first-child {
  z-index: 2;
}

.operations-table tr.is-selected td {
  background: #eff6ff;
}

.operations-table tr.is-selected .product-info-cell {
  background: #eff6ff;
}

.product-info-cell {
  min-width: 280px;
  max-width: 320px;
  white-space: normal;
}

.link-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  line-height: 1.35;
}

.link-button:hover {
  color: var(--blue);
}

.guide-text {
  color: #ea580c;
  font-weight: 800;
  line-height: 1.45;
}

.data-table th,
.data-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
}

.sort-button:hover,
.sort-button.is-active {
  color: var(--blue);
  border-color: var(--blue);
  background: #dbeafe;
}

.sort-indicator {
  display: inline-grid;
  place-items: center;
  min-width: 12px;
  color: var(--blue);
  font-size: 12px;
}

.sort-hint {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.check-cell {
  width: 44px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segmented button {
  min-height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  font-weight: 700;
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

.product-toolbar {
  min-width: 280px;
}

.product-toolbar label span,
.date-range-control label span {
  margin-bottom: 6px;
}

.analytics-filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.date-range-control {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.date-range-control input[type="date"] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.sales-chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  margin-top: 18px;
}

.sales-chart-panel,
.sales-summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.compact-heading {
  margin-bottom: 8px;
}

.sales-chart {
  min-height: 300px;
  overflow-x: auto;
}

.sales-chart-svg {
  width: 100%;
  min-width: 640px;
  height: auto;
}

.sales-chart-area {
  fill: rgba(37, 99, 235, 0.08);
  stroke: none;
}

.sales-chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sales-chart-dot {
  fill: #fff;
  stroke: var(--blue);
  stroke-width: 2;
}

.chart-grid {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child {
  border-bottom: 0;
}

.summary-item span {
  color: var(--muted);
}

.quantity-control,
.price-control {
  display: grid;
  grid-template-columns: 96px auto;
  gap: 8px;
  align-items: center;
  max-width: 198px;
}

.quantity-control input,
.price-control input {
  min-height: 36px;
}

.quantity-control button,
.price-control button {
  min-height: 36px;
}

.store-grid,
.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.store-card {
  padding: 16px;
  box-shadow: none;
}

.store-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.store-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.egress-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.egress-box .metric-note {
  margin: 6px 0 0;
  max-width: 260px;
  overflow-wrap: anywhere;
}

.store-permission-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.store-permission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.store-permission-group {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-top: 8px;
}

.store-permission-group > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 24px;
}

.store-permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.store-permission-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #334155;
  font-size: 12px;
  line-height: 1.35;
}

.store-stat {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.store-stat strong {
  display: block;
  margin-bottom: 3px;
}

.store-stat span {
  color: var(--muted);
  font-size: 12px;
}

.integration-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.integration-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  box-shadow: none;
}

.amazon-books-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.reference-crawler-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.reference-crawler-card h3 {
  margin: 4px 0 6px;
  font-size: 18px;
}

.cover-generator-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.cover-generator-summary h3 {
  margin: 4px 0 6px;
  font-size: 18px;
}

.cover-generator-table th:nth-child(2),
.cover-generator-table td:nth-child(2) {
  padding-right: 22px;
}

.cover-generator-table th:nth-child(3),
.cover-generator-table td:nth-child(3) {
  padding-left: 22px;
  border-left: 2px solid #cbd5e1;
}

.cover-generator-table td:nth-child(2),
.cover-generator-table td:nth-child(3) {
  min-width: 300px;
  vertical-align: top;
}

.cover-generator-table .cover-generator-queue-row:not(:first-child) > td {
  border-top: 4px solid #cbd5e1;
}

.cover-generator-table .cover-generator-queue-row > td {
  padding-top: 24px;
  padding-bottom: 24px;
}

.cover-generator-table .cover-generator-output-row > td {
  padding: 0 0 30px;
  border-top: 0;
}

.inline-cover-generator-output {
  margin: 0 0 12px;
  box-shadow: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 18px;
}

.inline-cover-generator-output .cover-set-meta,
.inline-cover-generator-output .cover-set-grid {
  grid-column: 1;
}

.inline-cover-generator-output .cover-generator-output-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  justify-content: center;
  min-width: 96px;
}

.cover-title-divider {
  width: 100%;
  height: 1px;
  margin: 10px 0;
  background: #e2e8f0;
}

.amazon-search-form,
.amazon-link-import {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.amazon-login-inline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.amazon-login-inline strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 14px;
}

.amazon-link-import textarea {
  min-height: 168px;
  resize: vertical;
}

.amazon-result-actions,
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.amazon-job-status-box {
  display: grid;
  gap: 6px;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
}

.amazon-job-status-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.amazon-job-status-box p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.amazon-book-table-wrap {
  margin-top: 16px;
}

.amazon-job-table-wrap {
  max-height: 760px;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.amazon-job-table-wrap .data-table {
  min-width: 1040px;
}

.amazon-job-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 0 1px 0 var(--line);
}

.amazon-job-category-list {
  display: grid;
  gap: 6px;
  max-width: 340px;
  white-space: normal;
  line-height: 1.55;
}

.amazon-job-category-preview,
.amazon-job-category-more div {
  display: grid;
  gap: 2px;
}

.amazon-job-category-preview span,
.amazon-job-category-more span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.amazon-job-category-more {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.amazon-job-category-more summary {
  width: fit-content;
  cursor: pointer;
  color: var(--blue);
}

.amazon-job-category-more summary::marker {
  color: var(--blue);
}

.amazon-job-category-more div {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.amazon-book-group-row td {
  padding: 10px 12px;
  background: #f8fafc;
}

.amazon-book-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.amazon-book-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
}

.amazon-book-group-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.amazon-category-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category-panel-head span:first-child {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.amazon-category-search {
  display: grid;
  gap: 6px;
  margin: 0;
}

.amazon-category-search span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.amazon-category-tree {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.amazon-category-group {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.amazon-category-parent,
.amazon-category-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.amazon-category-parent input,
.amazon-category-child input {
  width: auto;
}

.amazon-category-children {
  display: grid;
  gap: 4px;
  padding-left: 18px;
}

.amazon-category-child {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

a.secondary-button {
  text-decoration: none;
}

a.secondary-button[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.cover-workbench {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(480px, 1.28fr);
  gap: 18px;
  align-items: start;
}

.cover-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.cover-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.cover-form textarea {
  resize: vertical;
  min-height: 96px;
}

.translation-note {
  margin: -2px 0 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.45;
}

.cover-title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cover-title-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cover-title-inline-actions .compact-button {
  min-height: 32px;
}

.ebook-upload-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
}

.file-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  font-weight: 800;
  cursor: pointer;
}

.file-upload-button span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: 14px;
}

#ebookExtractPreview {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.6;
  resize: vertical;
}

.cover-preview-card {
  display: grid;
  gap: 14px;
}

.cover-preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 2 / 3;
  max-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fafc, #e0f2fe);
}

.cover-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.cover-placeholder {
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.cover-placeholder svg {
  width: 48px;
  height: 48px;
  color: var(--blue);
}

.cover-preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cover-prompt-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.cover-prompt-box p:last-child {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.cover-set-preview {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.cover-generator-output {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.cover-generator-output:not(.inline-cover-generator-output) {
  position: relative;
  padding-right: 164px;
}

.cover-generator-output[hidden] {
  display: none;
}

.cover-set-meta strong {
  display: block;
  margin-bottom: 4px;
  font-size: 20px;
}

.cover-set-meta p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.cover-set-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.cover-generator-output .cover-set-grid {
  grid-template-columns: repeat(2, minmax(0, 560px));
  column-gap: 56px;
  row-gap: 18px;
  justify-content: start;
  align-items: start;
}

.cover-generator-output-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.cover-generator-output:not(.inline-cover-generator-output) .cover-generator-output-actions {
  position: absolute;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
}

.cover-side-card {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.cover-side-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.cover-side-toolbar-title {
  color: var(--text);
  font-weight: 800;
}

.cover-side-toolbar .compact-button {
  min-height: 32px;
  white-space: nowrap;
}

.cover-side-toolbar .compact-button i {
  width: 15px;
  height: 15px;
}

.cover-generator-output .cover-side-card {
  width: 100%;
  max-width: min(500px, 100%);
}

.cover-generator-output .cover-side-frame {
  display: block;
  aspect-ratio: auto !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
  background: #fff;
}

.cover-generator-output .cover-side-frame img {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center;
}

.cover-side-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 2224 / 3152;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #e2e8f0);
}

.cover-side-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.cover-click-image {
  cursor: zoom-in;
}

.cover-click-image:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.42);
  outline-offset: -3px;
}

.modal.cover-editor-modal {
  width: min(1540px, calc(100vw - 32px));
}

.modal-body.cover-editor-body {
  height: min(940px, calc(100vh - 32px));
  max-height: calc(100vh - 32px);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.cover-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 460px);
  gap: 22px;
  min-height: 0;
  min-width: 0;
  align-items: stretch;
}

.cover-editor-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
}

.cover-editor-stage img,
.cover-editor-stage canvas {
  grid-area: 1 / 1;
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cover-editor-stage img {
  background: #fff;
}

.cover-editor-stage canvas {
  height: auto;
  touch-action: none;
  cursor: none;
}

.cover-brush-preview {
  position: absolute;
  z-index: 3;
  width: 64px;
  height: 64px;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.9), 0 4px 18px rgba(15, 23, 42, 0.35);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.cover-editor-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
}

.cover-editor-tools input[type="range"] {
  width: 100%;
}

.cover-editor-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: auto;
}

.cover-editor-prompt-field textarea,
#coverEditorPrompt {
  width: 100%;
  min-height: 96px;
  height: 112px;
  box-sizing: border-box;
  resize: vertical;
}

.cover-editor-actions {
  justify-content: stretch;
}

.cover-editor-actions .secondary-button,
.cover-editor-actions .primary-button {
  width: 100%;
}

.ai-panel {
  min-height: calc(100vh - 170px);
}

.ai-readonly-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
}

.ai-readonly-banner svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.ai-readonly-banner div {
  display: grid;
  gap: 4px;
}

.ai-context-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-context-bar h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.ai-permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 760px;
}

.ai-permission-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 700;
}

.ai-chat-shell {
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
  gap: 14px;
  min-height: 520px;
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 360px;
  max-height: calc(100vh - 430px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-empty {
  margin: auto;
  max-width: 520px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.ai-message {
  max-width: min(820px, 88%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.65;
  word-break: break-word;
}

.ai-message.is-user {
  align-self: flex-end;
  border-color: #2563eb;
  background: #eff6ff;
}

.ai-message.is-assistant {
  align-self: flex-start;
}

.ai-message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-download-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ai-download-button {
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
}

.ai-download-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ai-download-modal {
  width: min(760px, calc(100vw - 28px));
}

.ai-download-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-download-dialog-list {
  display: grid;
  gap: 8px;
  max-height: min(360px, calc(100vh - 320px));
  margin-top: 12px;
  overflow: auto;
}

.ai-download-dialog-item {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ai-download-dialog-item span {
  color: var(--muted);
  font-size: 12px;
}

.ai-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.ai-chat-form textarea {
  min-height: 92px;
  max-height: 220px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  line-height: 1.6;
}

.ai-chat-form .primary-button {
  min-width: 116px;
}

.ecommerce-images-wrap {
  overflow-x: auto;
}

.ecommerce-images-table {
  min-width: 1540px;
  table-layout: fixed;
}

.ecommerce-images-table th:nth-child(1),
.ecommerce-images-table td:nth-child(1) {
  width: 72px;
  min-width: 72px;
}

.ecommerce-images-table th:nth-child(2),
.ecommerce-images-table td:nth-child(2) {
  width: 330px;
}

.ecommerce-images-table th:nth-child(3),
.ecommerce-images-table td:nth-child(3) {
  width: 240px;
}

.ecommerce-images-table th:nth-child(4),
.ecommerce-images-table td:nth-child(4) {
  width: 120px;
}

.ecommerce-images-table th:nth-child(5),
.ecommerce-images-table td:nth-child(5) {
  width: 420px;
}

.ecommerce-images-table th:nth-child(6),
.ecommerce-images-table td:nth-child(6) {
  width: 168px;
}

.ecommerce-images-table th:nth-child(7),
.ecommerce-images-table td:nth-child(7) {
  width: 92px;
  white-space: normal;
}

.ecommerce-images-table th:nth-child(8),
.ecommerce-images-table td:nth-child(8) {
  width: 140px;
  min-width: 140px;
  padding-right: 8px;
  padding-left: 8px;
}

.ecommerce-images-table td {
  vertical-align: top;
}

.ecommerce-images-table td:nth-child(6) .pill {
  display: inline-flex;
  margin: 0 0 6px;
}

.ecommerce-title-block {
  display: grid;
  gap: 4px;
  min-width: 260px;
  max-width: 440px;
}

.ecommerce-title-block p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.ecommerce-cover-pair {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 220px;
}

.ecommerce-cover-thumb {
  display: grid;
  gap: 6px;
  justify-items: center;
  width: 98px;
  color: var(--muted);
  font-size: 12px;
}

.ecommerce-cover-thumb img {
  width: 98px;
  height: 138px;
  object-fit: contain;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
}

.ecommerce-cover-thumb img,
.white-image-thumb,
.scene-thumb {
  cursor: zoom-in;
}

.ecommerce-cover-empty {
  display: grid;
  place-items: center;
  width: 98px;
  height: 138px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.white-image-slot {
  display: grid;
  place-items: center;
  width: 96px;
  min-width: 96px;
}

.asset-slot {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.white-image-placeholder,
.white-image-thumb {
  width: 88px;
  height: 96px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.white-image-placeholder {
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.white-image-thumb {
  object-fit: cover;
  border-style: solid;
}

.scene-placeholder-grid {
  display: grid;
  grid-template-columns: repeat(5, 72px);
  gap: 8px;
  min-width: 392px;
}

.scene-placeholder {
  display: grid;
  place-items: center;
  min-height: 96px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.scene-thumb {
  width: 72px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
}

.image-lightbox-modal {
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  background: transparent;
  box-shadow: none;
}

.image-lightbox-body {
  display: grid;
  gap: 12px;
}

.image-lightbox-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px 8px 14px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-lightbox-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-lightbox-delete-button {
  z-index: 1;
  justify-self: center;
}

.image-lightbox-close-button {
  justify-self: end;
}

.image-lightbox-frame {
  position: relative;
  display: grid;
  place-items: center;
  max-height: calc(100vh - 120px);
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  overflow: auto;
}

.image-lightbox-frame img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: 8px;
}

.image-lightbox-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 72px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  transform: translateY(-50%);
  cursor: pointer;
}

.image-lightbox-nav:hover {
  background: #fff;
  border-color: #94a3b8;
}

.image-lightbox-nav-left {
  left: 18px;
}

.image-lightbox-nav-right {
  right: 18px;
}

.image-lightbox-nav svg {
  width: 28px;
  height: 28px;
}

.prompt-preview-modal {
  width: min(860px, calc(100vw - 28px));
}

.prompt-preview-textarea {
  width: 100%;
  min-height: 280px;
  max-height: min(560px, calc(100vh - 220px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  line-height: 1.55;
  resize: vertical;
}

.ecommerce-status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.ecommerce-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  width: 124px;
}

.ecommerce-actions .compact-button {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .modal.cover-editor-modal {
    width: min(760px, calc(100vw - 28px));
  }

  .modal-body.cover-editor-body {
    height: auto;
    max-height: calc(100vh - 28px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .cover-editor-layout {
    grid-template-columns: 1fr;
  }

  .cover-editor-sidebar {
    overflow: visible;
  }

  .cover-editor-stage {
    height: min(70vh, 720px);
  }
}

.cover-history-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact-heading {
  margin-bottom: 12px;
}

.compact-heading h3 {
  margin: 0;
  font-size: 18px;
}

.cover-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.cover-history-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.cover-history-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.cover-history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-history-card strong {
  display: block;
  margin-bottom: 4px;
}

.cover-history-card .pill {
  margin-bottom: 6px;
}

.cover-history-card p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

.cover-history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-button {
  border-color: #fecaca;
  color: #b91c1c;
}

.danger-button:hover {
  background: #fef2f2;
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.45fr) minmax(0, 1fr);
  gap: 16px;
}

.account-table-wrap {
  min-height: 280px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.permission-option input {
  width: auto;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.access-line,
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.access-line:last-child,
.activity-item:last-child {
  border-bottom: 0;
}

.activity-item {
  align-items: flex-start;
}

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

.modal {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.26);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.cover-regenerate-prompt-modal {
  width: min(760px, calc(100vw - 28px));
}

.cover-title-edit-modal {
  width: min(560px, calc(100vw - 28px));
}

.cover-title-edit-field {
  display: grid;
  gap: 8px;
}

.cover-title-edit-field input,
.cover-title-edit-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.cover-title-edit-field textarea {
  min-height: 86px;
  line-height: 1.5;
  resize: vertical;
}

.cover-title-edit-field input:focus,
.cover-title-edit-field textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.12);
}

.cover-regenerate-prompt-modal .field {
  display: grid;
  gap: 8px;
}

.cover-regenerate-prompt-textarea {
  width: 100%;
  min-height: 96px;
  max-height: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.5;
  resize: vertical;
}

.cover-regenerate-prompt-textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(37, 99, 235, 0.12);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: none;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
}

.toast.is-visible {
  display: block;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .brand {
    justify-content: center;
    padding-bottom: 14px;
  }

  .brand > div:not(.brand-mark),
  .nav-group-toggle span,
  .nav-item span,
  .sidebar-footer span {
    display: none;
  }

  .nav-group-toggle {
    justify-content: center;
    min-height: 34px;
    padding: 0;
  }

  .nav-item {
    justify-content: center;
  }

  .metric-grid,
  .store-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .integration-grid,
  .sales-chart-layout,
  .account-layout,
  .cover-workbench,
  .cover-generator-summary,
  .amazon-books-layout,
  .ops-briefing-grid {
    grid-template-columns: 1fr;
  }

  .ops-score-panel {
    padding: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    padding: 12px;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(12, minmax(42px, 1fr));
  }

  .nav-item {
    min-height: 42px;
    padding: 0;
  }

  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .topbar-title,
  .ai-task-monitor-host {
    flex: none;
    width: 100%;
    max-width: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
  }

  .search-box {
    grid-column: 1 / -1;
    width: 100%;
  }

  .content-region {
    padding: 18px;
  }

  .metric-grid,
  .store-grid {
    grid-template-columns: 1fr;
  }

  .table-toolbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .bulk-actions {
    justify-content: stretch;
  }

  .analytics-filter-bar,
  .cover-form-grid,
  .cover-set-grid,
  .date-range-control,
  .amazon-category-tree,
  .ai-context-bar,
  .ai-chat-form {
    grid-template-columns: 1fr;
  }

  .ai-context-bar {
    display: grid;
  }

  .ai-permission-chips {
    justify-content: flex-start;
  }

  .cover-generator-output .cover-set-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cover-generator-output:not(.inline-cover-generator-output) {
    padding-right: 16px;
  }

  .cover-generator-output:not(.inline-cover-generator-output) .cover-generator-output-actions {
    position: static;
    transform: none;
    justify-content: stretch;
  }

  .inline-cover-generator-output {
    grid-template-columns: minmax(0, 1fr);
  }

  .inline-cover-generator-output .cover-set-meta,
  .inline-cover-generator-output .cover-set-grid,
  .inline-cover-generator-output .cover-generator-output-actions {
    grid-column: 1;
    grid-row: auto;
  }

  .cover-generator-output-actions .compact-button {
    width: 100%;
    justify-content: center;
  }

  .analytics-filter-bar,
  .date-range-control {
    align-items: stretch;
    flex-direction: column;
  }

  .bulk-actions button {
    flex: 1;
  }

  .ops-score-panel,
  .ops-task {
    grid-template-columns: 1fr;
  }

  .ops-task .compact-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .topbar-actions {
    grid-template-columns: 1fr 40px;
  }

  .topbar-actions select,
  .topbar-actions .primary-button {
    grid-column: 1 / -1;
  }

  .nav-list {
    overflow-x: auto;
    grid-template-columns: repeat(12, 54px);
  }

  h1 {
    font-size: 24px;
  }

  .section-block,
  .metric-card {
    padding: 14px;
  }
}
