/* ===== Design Tokens ===== */
:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #4a5568;
  --muted: #8896a8;
  --line: #e2e8f0;
  --primary: #4f6ef7;
  --primary-hover: #3b5de7;
  --primary-light: #eef2ff;
  --green: #22c55e;
  --green-light: #f0fdf4;
  --red: #ef4444;
  --red-light: #fef2f2;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ===== Shared: Buttons ===== */
button {
  border: 0;
  border-radius: var(--radius-sm);
  background: #edf0f5;
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 14px;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover { background: #dfe3ea; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button.primary, .auth-form button[type="submit"] {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.3);
}
button.primary:hover, .auth-form button[type="submit"]:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.4);
}

/* ===== Shared: Inputs ===== */
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  outline: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input, select { height: 40px; padding: 0 12px; }
textarea { min-height: 88px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
#codexImageModel:disabled {
  cursor: not-allowed;
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--line);
  opacity: 1;
}
label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 13px; font-weight: 500; }

/* ===== Auth Shell ===== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79, 110, 247, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(34, 197, 94, 0.08), transparent 50%),
    linear-gradient(160deg, #eef1ff 0%, #f8f9fc 40%, #f0fdf4 100%);
}
.auth-panel {
  width: min(420px, 100%);
  padding: 40px 36px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(24px);
  animation: fadeUp 0.5s ease-out;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 16px rgba(79, 110, 247, 0.35);
}
.brand-mark.small {
  width: 32px;
  height: 32px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.25);
}
.auth-panel h1 {
  margin: 20px 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.auth-panel p { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  gap: 4px;
  border-radius: var(--radius);
  background: #edf0f5;
  margin-bottom: 24px;
}
.auth-tab {
  border-radius: var(--radius-sm);
  background: transparent;
  min-height: 38px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.auth-tab.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: grid; gap: 16px; }
.auth-message {
  min-height: 22px;
  margin-top: 16px;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
}

/* ===== Admin Shell ===== */
.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

/* ===== Sidebar ===== */
.sidebar {
  background: var(--sidebar-bg);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: var(--sidebar-text);
  padding: 24px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 28px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}
.menu-list { display: grid; gap: 4px; }
.menu-group {
  display: grid;
  gap: 4px;
}
.menu-group-toggle,
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  height: 42px;
  color: var(--sidebar-text);
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  padding: 0 12px;
  position: relative;
  overflow: hidden;
}
.menu-group-toggle {
  height: 44px;
}
.menu-group-toggle::before,
.menu-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
  transition: height var(--transition);
}
.menu-group-toggle:hover,
.menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}
.menu-group-toggle.is-active,
.menu-item.is-active {
  background: rgba(79, 110, 247, 0.15);
  color: var(--sidebar-active);
}
.menu-group-toggle.is-active::before,
.menu-item.is-active::before { height: 20px; }
.menu-group-toggle svg,
.menu-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: 0.7;
}
.menu-group-toggle.is-active svg,
.menu-group-toggle:hover svg,
.menu-item.is-active svg,
.menu-item:hover svg { opacity: 1; }
.menu-group-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.menu-caret {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  color: inherit;
}
.menu-caret svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}
.menu-sublist {
  display: grid;
  gap: 4px;
  padding-left: 14px;
}
.menu-item.is-submenu {
  height: 38px;
  font-size: 13px;
  padding-left: 14px;
}

/* ===== Workspace ===== */
.workspace { min-width: 0; padding: 28px 32px; }
.listing-shell { display: grid; gap: 20px; }
.ecommerce-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(0, 1.32fr);
  gap: 20px;
  align-items: start;
}
.ecommerce-side-panel {
  min-width: 0;
}
.ecommerce-detail-stack {
  min-width: 0;
  display: grid;
  gap: 20px;
}
.pipeline-layout {
  display: grid;
  gap: 20px;
}
.pipeline-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border-bottom: 1px solid #e8ecf2;
}
.pipeline-top-bar input { max-width: 220px; flex: 0 1 220px; height: 36px; }
.pipeline-top-bar select { max-width: 140px; flex: 0 0 140px; height: 36px; }
.pipeline-product-select { flex: 1 1 240px; max-width: 400px; min-width: 180px; }
.pipeline-top-actions { display: flex; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.pipeline-top-actions button { height: 36px; min-height: 36px; }
.pipeline-top-bar .pagination { flex: 0 0 auto; margin: 0; margin-left: auto; }
.pipeline-top-bar .pagination-info { font-size: 12px; }
.library-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.library-asset-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e2e7ee;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  text-align: left;
}
.library-asset-card:hover {
  border-color: rgba(79, 110, 247, 0.25);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.library-asset-card.is-selected {
  border-color: rgba(79, 110, 247, 0.4);
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: 0 4px 16px rgba(79, 110, 247, 0.12);
}
.library-asset-card .thumb {
  display: block;
  width: 100%;
  height: 180px;
  min-height: 180px;
  flex: none;
  padding: 0;
  border-radius: var(--radius-sm);
}
.library-asset-card .thumb-image {
  border-radius: var(--radius-sm);
}
.library-card-title {
  display: block;
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  position: relative;
  z-index: 1;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.library-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.library-card-actions button {
  flex: 1 1 calc(50% - 4px);
  min-width: 88px;
}
.library-picker-tip {
  font-size: 12px;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed #d8e0ec;
  background: #f8fafc;
}
.library-asset-grid-picker {
  min-height: 320px;
}
.library-asset-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.library-asset-select input {
  width: 16px;
  height: 16px;
}
.ecommerce-selection-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 320px);
  overflow: auto;
  padding-right: 4px;
}
.ecommerce-selection-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.ecommerce-selection-item:hover {
  border-color: rgba(79, 110, 247, 0.28);
  background: #f8fbff;
  box-shadow: var(--shadow);
}
.ecommerce-selection-item.is-active {
  border-color: rgba(79, 110, 247, 0.35);
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: 0 6px 20px rgba(79, 110, 247, 0.12);
}
.ecommerce-selection-item .thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
}
.ecommerce-selection-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.ecommerce-selection-copy strong {
  line-height: 1.45;
}
.ecommerce-selection-copy small {
  color: var(--muted);
  line-height: 1.4;
}
.ecommerce-product-table {
  min-width: 1360px;
}
.listing-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
}
.listing-hero h3 {
  margin: 6px 0 8px;
  font-size: 24px;
}
.listing-hero p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 760px;
  line-height: 1.6;
}
.listing-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.listing-studio-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.25fr);
  gap: 20px;
  align-items: start;
}
.listing-workbench {
  min-width: 0;
}
.listing-product-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #d4dae4;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
  font-size: 14px;
  line-height: 1.6;
}
.listing-product-detail {
  display: grid;
  gap: 18px;
}
.listing-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid #e8ecf2;
}
.listing-detail-head h3 {
  margin: 6px 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.listing-detail-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.listing-detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.listing-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.listing-detail-card {
  padding: 18px 20px;
  border: 1px solid #e8ecf2;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fcfdff 0%, #f8fafc 100%);
}
.listing-detail-card h5 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.2px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef1f6;
}
.listing-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.listing-kv-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #eef1f6;
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.listing-kv-item:hover {
  border-color: #dde3ec;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.listing-kv-item span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.listing-kv-item strong {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.listing-assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.listing-inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid #eef1f6;
}
.listing-inline-form .wide {
  grid-column: 1 / -1;
}
.listing-history-list {
  display: grid;
  gap: 14px;
}
.listing-history-card {
  padding: 16px 18px;
  border: 1px solid #e8ecf2;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff 0%, #fafbfd 100%);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.listing-history-card:hover {
  border-color: rgba(79, 110, 247, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.listing-history-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eef1f6;
}
.listing-history-head strong {
  display: block;
  font-size: 14px;
}
.listing-history-head span {
  color: var(--muted);
  font-size: 12px;
}
.listing-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}
.listing-history-actions {
  margin-bottom: 12px;
}
.listing-output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.listing-output-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e8ecf2;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fafbfd 0%, #f5f7fa 100%);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.listing-output-card:hover {
  border-color: rgba(79, 110, 247, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.listing-results-single {
  grid-template-columns: 1fr;
}
.is-selected-row {
  background: #f5f8ff;
}
.listing-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid #eef1f6;
}
.listing-form-note {
  margin: 0;
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
}
.required-star {
  color: #dc2626;
  margin-left: 2px;
  font-weight: 700;
}
.listing-form-grid .wide { grid-column: 1 / -1; }
.listing-advanced {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fafafa;
}
.listing-advanced summary {
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}
.listing-advanced summary::-webkit-details-marker { display: none; }
.listing-advanced summary::after {
  content: "展开";
  float: right;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.listing-advanced[open] summary::after { content: "收起"; }
.listing-advanced-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.listing-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}
.listing-results-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}
.listing-task-summary {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.listing-task-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.9fr);
  gap: 20px;
}
.listing-task-detail-grid {
  display: grid;
  gap: 20px;
}
.listing-task-table td {
  vertical-align: top;
}
.listing-task-table .empty-hint {
  text-align: center;
}
.listing-task-active {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: #eef2ff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}
.task-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.task-status-pill.draft {
  background: #eff6ff;
  color: #1d4ed8;
}
.task-status-pill.planned,
.task-status-pill.rendered {
  background: #ecfdf5;
  color: #047857;
}
.task-status-pill.reviewed,
.task-status-pill.exported {
  background: #f5f3ff;
  color: #7c3aed;
}
.task-status-pill.failed {
  background: #fef2f2;
  color: #dc2626;
}
.json-view {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  min-height: 200px;
  max-height: 420px;
  overflow: auto;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #0c1222 0%, #131c33 100%);
  color: #c8d9f0;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid #1e2940;
}
.listing-render-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.render-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #e8ecf2;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff 0%, #fafbfd 100%);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.render-card:hover {
  border-color: rgba(79, 110, 247, 0.18);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.render-meta {
  display: grid;
  gap: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}
.render-prompt {
  color: var(--muted);
  line-height: 1.5;
}
.empty-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.topbar-title-wrap {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.topbar-title-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.page-back-btn {
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  color: var(--primary);
  background: var(--primary-light);
  justify-self: start;
}
.page-back-btn:hover {
  background: #dfe7ff;
}
.topbar h2 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 14px;
  background: var(--panel);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  font-weight: 500;
}
.user-chip button {
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--muted);
}
.user-chip button:hover { color: var(--red); background: var(--red-light); }

/* ===== Dashboard Welcome ===== */
.dashboard-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(79, 110, 247, 0.3);
}
.welcome-text h3 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.welcome-text p {
  margin: 0;
  font-size: 14px;
  opacity: 0.85;
}
.welcome-time {
  font-size: 14px;
  opacity: 0.8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ===== Metric Grid (Dashboard) ===== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.metric-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.metric-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.metric-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}
.metric-icon svg {
  width: 22px;
  height: 22px;
}
.accent-a .metric-icon { background: var(--primary-light); color: var(--primary); }
.accent-b .metric-icon { background: var(--amber-light); color: var(--amber); }
.accent-c .metric-icon { background: var(--green-light); color: var(--green); }
.metric-body { flex: 1; min-width: 0; }
.metric-body span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.metric-body strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}
.accent-a::after { background: linear-gradient(90deg, var(--primary), #7c3aed); }
.accent-b::after { background: linear-gradient(90deg, var(--amber), #f97316); }
.accent-c::after { background: linear-gradient(90deg, var(--green), #06b6d4); }

/* ===== Dashboard Panels ===== */
.dashboard-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.panel-card {
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  position: relative;
  transition: box-shadow var(--transition);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef1f6;
}
.panel-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}

/* ===== Quick Actions ===== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 10px;
  border-radius: var(--radius);
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.quick-btn svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
  transition: all var(--transition);
}
.quick-btn:hover {
  background: var(--primary-light);
  border-color: rgba(79, 110, 247, 0.2);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ===== Status List ===== */
.status-list { display: grid; gap: 12px; }
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  font-size: 14px;
}
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.status-label {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.status-label.online { background: var(--green-light); color: #16a34a; }
.status-label.offline { background: var(--red-light); color: var(--red); }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.pagination-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
#productPagination {
  justify-content: flex-start;
  align-items: center;
}
.page-btn {
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--panel);
  border: 1px solid #e2e7ee;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled):not(.is-active) {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(79, 110, 247, 0.3);
}
.page-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(79, 110, 247, 0.3);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  border: 1px solid #eef1f6;
}
.toolbar input { max-width: 280px; }
.toolbar select { max-width: 160px; }

/* 商品页在小屏下按整块横向滚动，避免筛选栏、表格、分页宽度各自收缩后错位。 */
.wide-scroll-shell {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}
.wide-content {
  width: 100%;
  min-width: 0;
}
.wide-content-products { min-width: 1720px; }
.toolbar-wide {
  flex-wrap: nowrap;
  align-items: center;
}
.toolbar-wide > * { flex: 0 0 auto; }
.toolbar-wide input {
  width: 320px;
  max-width: none;
}
.toolbar-wide select {
  width: 160px;
  max-width: none;
}
.library-picker-toolbar {
  flex-wrap: nowrap;
}
.library-picker-toolbar #libraryAssetPickerKeyword {
  flex: 1 1 320px;
  width: auto;
  min-width: 0;
}
.library-picker-toolbar #applyLibraryAssetPickerBtn {
  margin-left: auto;
}

/* ===== Table ===== */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; min-width: 1180px; }
th, td { padding: 12px 16px; text-align: left; vertical-align: middle; }
#productsView th { text-align: center; }
th {
  color: #6b7a8d;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: linear-gradient(180deg, #f8fafc 0%, #f3f5f9 100%);
  border-bottom: 2px solid #e2e7ee;
  position: sticky;
  top: 0;
}
td {
  font-size: 14px;
  border-bottom: 1px solid #f1f5f9;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: linear-gradient(90deg, #f8fafc 0%, #f0f4ff 100%); }
tbody tr:last-child td { border-bottom: 0; }

/* ===== Product Cell ===== */
.product-cell { display: flex; gap: 12px; align-items: center; }
.comic-cell { display: flex; gap: 12px; align-items: center; }
.product-image-col {
  width: 86px;
  min-width: 86px;
  text-align: center;
}
.product-title-col {
  width: 360px;
  min-width: 360px;
}
.category-col {
  width: 240px;
  min-width: 240px;
}
.price-col {
  width: 143px;
  min-width: 143px;
  white-space: nowrap;
}
.product-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.product-copy strong {
  display: block;
  line-height: 1.4;
}
.product-meta {
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}
.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.product-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid var(--tag-border);
  border-radius: var(--radius-full);
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: #f1f5f9 center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  padding: 0;
  transition: all var(--transition);
  display: grid;
  place-items: center;
}
.thumb-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

@media (max-width: 1200px) {
  .ecommerce-layout,
  .listing-studio-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .pipeline-top-bar {
    flex-wrap: wrap;
  }
  .pipeline-top-bar input,
  .pipeline-top-bar select {
    flex: 1 1 100%;
    max-width: none;
  }
  .pipeline-product-select { flex: 1 1 100%; max-width: none; }
  .pipeline-top-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .pipeline-top-bar .pagination { width: 100%; justify-content: center; margin-left: 0; }
}

@media (max-width: 768px) {
  .listing-hero,
  .listing-detail-head,
  .listing-detail-grid,
  .listing-kv-grid,
  .listing-inline-form {
    grid-template-columns: 1fr;
    display: grid;
  }
  .listing-hero,
  .listing-detail-head {
    align-items: stretch;
  }
}
.thumb svg { width: 20px; height: 20px; }
.thumb.has-image { cursor: zoom-in; }
.thumb.has-image:hover {
  box-shadow: inset 0 0 0 2px var(--primary), var(--shadow);
  transform: scale(1.05);
}
.reason-cell {
  min-width: 220px;
  max-width: 320px;
  line-height: 1.6;
  color: var(--text-secondary);
  word-break: break-word;
}
.reason-col {
  min-width: 240px;
}
.source-link-col {
  width: 128px;
  min-width: 128px;
  white-space: nowrap;
}
.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(79, 110, 247, 0.18);
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}
.source-link:hover {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.22);
}
.status-col {
  width: 108px;
  min-width: 108px;
  white-space: nowrap;
}
.updated-col {
  width: 176px;
  min-width: 176px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.action-col {
  width: 212px;
  min-width: 212px;
  white-space: nowrap;
}

/* ===== Status Badges ===== */
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.status.draft { background: #f1f5f9; color: #64748b; }
.status.new { background: var(--primary-light); color: var(--primary); }
.status.reviewing { background: #f5f3ff; color: #7c3aed; }
.status.approved { background: var(--green-light); color: #16a34a; }
.status.archived { background: #f1f5f9; color: #64748b; }
.status.published { background: var(--green-light); color: #16a34a; }
.status.offline { background: var(--amber-light); color: #d97706; }
.status.rejected { background: var(--red-light); color: var(--red); }
.status.pending { background: var(--amber-light); color: #d97706; }
.status.disabled { background: #f1f5f9; color: #64748b; }

/* ===== Row Actions ===== */
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* ===== Empty View ===== */
.empty-view { display: grid; place-items: center; min-height: 420px; }
.empty-card {
  width: min(420px, 100%);
  padding: 48px 36px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  animation: fadeUp 0.4s ease-out;
}
.empty-card span { font-size: 48px; color: var(--primary); }
.empty-card h3 { margin: 16px 0 8px; font-size: 20px; color: var(--text); }
.empty-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr min(560px, 100%);
  z-index: 20;
  animation: fadeIn 0.2s ease-out;
}
.drawer-wide {
  grid-template-columns: 1fr min(860px, 100%);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-mask {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.drawer-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  overflow-y: auto;
  padding: 28px;
  background: var(--panel);
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chapter-panel {
  grid-template-rows: auto 1fr auto;
}
.drawer-head, .drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.drawer-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.drawer-actions { padding-top: 8px; }
.drawer-actions-end { justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

@media (max-width: 768px) {
  .library-picker-toolbar {
    flex-wrap: wrap;
  }
  .library-picker-toolbar #libraryAssetPickerKeyword {
    flex-basis: 100%;
    width: 100%;
  }
  .library-picker-toolbar #applyLibraryAssetPickerBtn {
    margin-left: auto;
  }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--sidebar-bg);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  z-index: 50;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== Image Preview ===== */
.image-preview {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  animation: fadeIn 0.2s ease-out;
}
.image-preview-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
}
.image-preview-panel {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  gap: 14px;
  justify-items: center;
  animation: fadeUp 0.3s ease-out;
}
.image-preview-panel img {
  max-width: 100%;
  max-height: calc(100vh - 112px);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-xl);
  object-fit: contain;
}
.image-preview-actions {
  width: min(980px, 100%);
  display: flex;
  justify-content: flex-end;
}
.image-preview-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}
.image-preview-download:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-xl);
}
.image-preview-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--text);
  font-size: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 2;
  transition: all var(--transition);
}
.image-preview-close:hover { transform: scale(1.1) rotate(90deg); }

/* ===== Codex Image Workbench ===== */
.codex-image-panel {
  max-width: none;
}

.codex-panel-head {
  align-items: flex-start;
  justify-content: flex-start;
  gap: 24px;
}

.codex-panel-head .primary {
  flex: 0 0 auto;
  margin-top: 18px;
}

.panel-tag {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.codex-image-grid {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.codex-image-controls {
  display: grid;
  gap: 12px;
  align-content: start;
}
.control-block {
  display: grid;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.codex-image-controls textarea {
  min-height: 156px;
}
.prompt-block textarea {
  min-height: 188px;
}
.codex-reference-box {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #eef1f6;
  border-radius: var(--radius);
  background: #f8fafc;
}
.codex-reference-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.codex-reference-head strong {
  font-size: 13px;
  color: var(--text);
}
.codex-reference-head span {
  font-size: 12px;
  color: var(--muted);
}
.codex-reference-file-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.codex-reference-file-btn:hover {
  background: #f1f5f9;
}
.codex-reference-file-btn input {
  display: none;
}
.codex-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}
.codex-reference-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #e8ecf2;
  border-radius: var(--radius-sm);
  background: #fff;
}
.codex-reference-card .thumb {
  width: 100%;
  height: 96px;
  flex: none;
}
.codex-reference-card button[data-remove-codex-reference] {
  min-height: 30px;
  font-size: 12px;
}
.codex-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.codex-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 13px;
}
.codex-checkbox-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.codex-progress-text {
  min-height: 20px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}
.codex-result-summary {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px 14px;
  justify-content: flex-start;
}
.codex-result-summary .codex-meta {
  flex: 1 1 280px;
  min-width: 0;
}
.codex-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.codex-status-badge.idle {
  background: #f1f5f9;
  color: #64748b;
}
.codex-status-badge.running {
  background: #e0f2fe;
  color: #0c4a6e;
}
.codex-status-badge.success {
  background: #dcfce7;
  color: #166534;
}
.codex-status-badge.error {
  background: #fee2e2;
  color: #991b1b;
}
.codex-image-result {
  display: grid;
  min-width: 0;
  gap: 10px;
  margin-top: -76px;
}
.codex-result-actions {
  display: flex;
  justify-content: flex-start;
}
.preview-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.preview-toolbar > :first-child {
  justify-self: start;
}
.preview-toolbar .codex-status-badge {
  justify-self: end;
}
.preview-toolbar strong {
  font-size: 18px;
}
.codex-preview-stage {
  position: relative;
  min-height: 440px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(34, 197, 94, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(79, 110, 247, 0.08) 25%, transparent 25%),
    #f6f8fa;
  background-position:
    0 0,
    0 12px;
  background-size: 24px 24px;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: zoom-in;
}
.codex-preview-stage::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(26, 26, 46, 0.08);
  border-radius: 6px;
  pointer-events: none;
}
.codex-preview-stage img {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 440px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.9);
}
.codex-meta {
  color: var(--text-secondary);
  font-size: 12px;
}
.codex-json-view {
  min-height: 130px;
  max-height: 220px;
}
.codex-log-stream {
  min-width: 0;
  max-width: 100%;
  min-height: 120px;
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #0f172a;
}
.codex-log-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.codex-log-line + .codex-log-line {
  margin-top: 4px;
}
.codex-log-line.info {
  color: #cbd5e1;
}
.codex-log-line.success {
  color: #86efac;
}
.codex-log-line.error {
  color: #fca5a5;
}
.codex-history-panel {
  margin-top: 16px;
}
.codex-history-list {
  display: grid;
  gap: 12px;
}
.codex-history-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.codex-history-card .thumb {
  width: 112px;
  height: 112px;
  flex: none;
}
.codex-history-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.codex-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.codex-history-prompt {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.render-card-actions {
  margin-top: 8px;
}

.role-permission-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
}
.role-list {
  display: grid;
  gap: 12px;
}
.role-card {
  min-height: 88px;
  display: grid;
  justify-content: flex-start;
  gap: 4px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
}
.role-card strong {
  font-size: 15px;
  color: var(--text);
}
.role-card span,
.role-card small {
  color: var(--text-secondary);
}
.role-card.is-active {
  border-color: rgba(79, 110, 247, 0.35);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.08);
}
.role-menu-panel,
.settings-panel {
  min-height: 420px;
}
.role-menu-tree {
  display: grid;
  gap: 18px;
}
.role-menu-section {
  display: grid;
  gap: 12px;
}
.role-menu-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.role-menu-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.role-menu-group-section {
  gap: 14px;
}
.role-menu-children {
  padding-left: 18px;
  border-left: 2px solid #e8ecf2;
}
.role-menu-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.role-menu-option.is-parent {
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7ff 100%);
  border-color: rgba(79, 110, 247, 0.22);
}
.role-menu-option.is-parent.is-virtual {
  border-style: dashed;
}
.role-menu-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
.role-menu-copy {
  display: grid;
  gap: 4px;
}
.role-menu-copy strong {
  color: var(--text);
  font-size: 14px;
}
.role-menu-copy small {
  color: var(--muted);
  font-size: 12px;
}
.settings-form {
  width: min(480px, 100%);
  display: grid;
  gap: 16px;
}
.settings-actions {
  justify-content: flex-start;
  padding-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    padding: 12px;
  }
  .sidebar-brand { padding-bottom: 12px; }
  .menu-list { grid-template-columns: 1fr; }
  .menu-group-toggle,
  .menu-item { justify-content: flex-start; font-size: 13px; }
  .menu-group-toggle::before,
  .menu-item::before { display: none; }
  .menu-sublist { padding-left: 10px; }
  .workspace { padding: 16px; }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .topbar-title-wrap {
    width: 100%;
    gap: 10px;
  }
  .metric-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar input, .toolbar select { max-width: 100%; }
  #productsView .toolbar {
    flex-direction: row;
    flex-wrap: nowrap;
  }
  #productsView .toolbar input,
  #productsView .toolbar select { max-width: none; }
  .drawer { grid-template-columns: 0 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-welcome {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }
  .dashboard-panels { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .role-permission-layout,
  .codex-image-grid,
  .codex-control-grid,
  .listing-results-grid,
  .listing-task-layout {
    grid-template-columns: 1fr;
  }
  .codex-image-result {
    margin-top: 0;
  }
  .codex-reference-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .codex-panel-head {
    gap: 12px;
  }
  .codex-panel-head .primary {
    width: 100%;
  }
  .preview-toolbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .preview-toolbar > :first-child,
  .preview-toolbar .codex-status-badge {
    justify-self: stretch;
  }
  .codex-preview-stage,
  .codex-preview-stage img {
    height: 220px;
    min-height: 220px;
  }
  .codex-history-card {
    grid-template-columns: 1fr;
  }
  .codex-history-card .thumb {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .role-menu-group-grid {
    grid-template-columns: 1fr;
  }
}
