:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #66736c;
  --line: #dbe2dd;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --soft: #edf5f2;
  --shadow: 0 18px 44px rgba(23, 32, 27, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

.app-shell.login-screen .sidebar {
  width: min(100%, 1040px);
  min-height: calc(100vh - 56px);
  margin: 0 auto;
  padding: 36px;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  background: transparent;
  color: var(--ink);
}

.app-shell.login-screen .brand {
  color: var(--ink);
}

.app-shell.login-screen .brand p {
  color: var(--muted);
}

.app-shell.login-screen .auth-panel {
  align-self: center;
  justify-self: center;
  width: min(100%, 380px);
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.app-shell.login-screen .status-panel {
  display: none;
}

.app-shell.login-screen .login-form strong {
  color: var(--ink);
  font-size: 18px;
}

.app-shell.login-screen .login-form label {
  color: var(--muted);
  font-size: 14px;
}

.app-shell.login-screen .login-form input {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.app-shell.login-screen .auth-panel .form-note {
  color: var(--muted);
  font-size: 14px;
}

.sidebar {
  background: #17201b;
  color: #ffffff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f2c94c;
  color: #17201b;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #aebbb3;
  font-size: 13px;
}

.brand-switcher {
  display: grid;
  gap: 7px;
  color: #aebbb3;
  font-size: 13px;
}

.brand-switcher select {
  background: #26332d;
  border-color: #3d5047;
  color: #ffffff;
}

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

.nav-item {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d7e1db;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #26332d;
  border-color: #3d5047;
  color: #ffffff;
}

.status-panel {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #26332d;
  border: 1px solid #3d5047;
  border-radius: 8px;
  padding: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2dd4bf;
  margin-top: 5px;
}

.status-panel strong {
  display: block;
  font-size: 14px;
}

.status-panel p {
  color: #aebbb3;
  margin: 2px 0 0;
  font-size: 12px;
}

.auth-panel {
  display: grid;
  gap: 10px;
  background: #202b26;
  border: 1px solid #3d5047;
  border-radius: 8px;
  padding: 14px;
}

.login-form,
.session-panel {
  display: grid;
  gap: 10px;
}

.login-form strong,
.session-panel strong {
  font-size: 14px;
}

.login-form label {
  display: grid;
  gap: 5px;
  color: #aebbb3;
  font-size: 12px;
}

.login-form input {
  background: #101713;
  border-color: #3d5047;
  color: #ffffff;
}

.auth-panel .form-note,
.session-panel span {
  color: #aebbb3;
  margin: 0;
  font-size: 12px;
}

.mock-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff7ed;
  color: var(--warn);
  border: 1px solid #fed7aa;
  font-weight: 700;
  font-size: 12px;
}

.main {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.topbar,
.section-head,
.top-actions,
.filters,
.form-actions,
.search-test {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.topbar h2 {
  font-size: 30px;
}

.top-actions,
.filters {
  gap: 10px;
}

.search-box {
  width: min(360px, 42vw);
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

input[readonly] {
  background: #f8fafc;
  color: #475569;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn {
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 9px 14px;
  white-space: nowrap;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.ghost-btn,
.small-btn {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.danger-btn {
  background: #fff5f4;
  color: var(--danger);
  border-color: #ffd4cf;
}

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

.metrics article,
.view {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span,
.muted {
  color: var(--muted);
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.view {
  display: none;
  padding: 20px;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.section-head {
  margin-bottom: 16px;
}

.section-head h3 {
  font-size: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.bulk-bar,
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.bulk-bar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.roi-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.roi-strip span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px 12px;
  color: var(--muted);
}

.roi-strip strong {
  color: var(--ink);
  margin-left: 4px;
}

.pagination-bar {
  margin: 14px 0 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.35;
}

th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

th:nth-child(1),
td:nth-child(1) {
  width: 42px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 96px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 210px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 96px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 150px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 230px;
}

th:nth-child(7),
td:nth-child(7),
th:nth-child(8),
td:nth-child(8) {
  width: 130px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 190px;
}

.thumb {
  width: 76px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.product-name {
  font-size: 15px;
  line-height: 1.28;
  font-weight: 700;
  max-width: 190px;
  overflow-wrap: normal;
}

.product-meta {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
}

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

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 230px;
}

.tag {
  background: var(--soft);
  border: 1px solid #d4e8e0;
  border-radius: 999px;
  color: #245347;
  padding: 4px 9px;
  font-size: 12px;
  line-height: 1.2;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 96px;
}

.pill.done {
  background: #e8f7ed;
  color: var(--ok);
}

.pill.pending {
  background: #fff7e6;
  color: var(--warn);
}

.pill.skipped {
  background: #eef2f1;
  color: var(--muted);
}

.pill.embedding,
.pill.review {
  background: #eef7ff;
  color: #2563eb;
}

.pill.review {
  background: #fff7e6;
  color: var(--warn);
}

.pill.failed {
  background: #fff0ef;
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  min-width: 178px;
}

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

.editor-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

.editor-preview {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.editor-preview img {
  width: min(420px, 100%);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.system-info-panel {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  color: var(--muted);
}

.system-info-panel strong {
  color: var(--ink);
}

.system-info-panel b {
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.status-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.form-note {
  margin: 0;
  color: var(--warn);
  font-size: 13px;
}

.form-actions {
  justify-content: space-between;
  gap: 12px;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.toggle {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink) !important;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.queue-list,
.result-grid {
  display: grid;
  gap: 12px;
}

.queue-item,
.result-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.queue-item img,
.result-item img {
  width: 86px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
}

.queue-item h4,
.result-item h4 {
  margin: 0 0 4px;
}

.queue-item p,
.result-item p {
  margin: 0;
  color: var(--muted);
}

.search-test {
  gap: 10px;
  margin-bottom: 16px;
}

.score {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.batch-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.auto-index-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  margin: 10px 0 18px;
}

.auto-index-summary div {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px 14px;
}

.auto-index-summary strong {
  color: var(--ink);
}

.auto-index-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auto-index-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}

.auto-index-flow span {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  min-height: 44px;
  padding: 9px 10px;
}

.batch-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.batch-panel h4 {
  margin: 0 0 14px;
}

.batch-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.batch-monitor {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.progress-bar {
  height: 14px;
  border-radius: 999px;
  background: #e7ece9;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.batch-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.batch-stats span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
}

.batch-stats strong {
  color: var(--ink);
  margin-left: 4px;
}

.ssot-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.ssot-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.ssot-form .action-group {
  grid-column: 1 / -1;
  justify-self: end;
  width: auto;
  flex-direction: row;
  align-items: center;
}

.ssot-form .action-group button {
  width: auto;
  min-width: 132px;
}

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

.ssot-row {
  display: grid;
  grid-template-columns: 150px 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.ssot-row strong {
  display: block;
}

.ssot-row span {
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  min-width: 0;
}

.settings-panel h4 {
  margin: 0 0 14px;
}

.settings-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
  min-width: 0;
}

.settings-panel .toggle {
  display: flex !important;
  align-items: center;
  color: var(--ink) !important;
  min-width: 0;
  white-space: normal;
}

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

.settings-note {
  margin: 14px 0 0;
  color: var(--muted);
}

.setting-current {
  display: block;
  color: var(--muted);
  margin-top: -4px;
  overflow-wrap: anywhere;
}

.settings-confirm {
  margin-top: 16px;
  border: 1px solid #f2d3a8;
  border-radius: 8px;
  background: #fffaf0;
  padding: 14px;
}

.settings-confirm label {
  display: grid;
  gap: 7px;
  color: var(--warn);
  font-size: 13px;
}

.settings-panel summary {
  cursor: pointer;
  font-weight: 800;
  font-size: 18px;
}

.advanced-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.advanced-settings input,
.advanced-settings textarea {
  min-width: 0;
}

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

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

.compact-head h4 {
  margin: 0;
}

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

.admin-form label {
  margin-bottom: 0;
}

.field-title {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.brand-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brand-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #f8fafc;
}

.brand-checks input {
  width: auto;
}

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

.permission-matrix {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.compact-table {
  overflow-x: auto;
}

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

.compact-table th,
.compact-table td {
  padding: 9px 10px;
  font-size: 13px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) minmax(96px, 0.6fr) minmax(104px, 0.6fr) minmax(210px, max-content);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-width: 100%;
  overflow: hidden;
}

.admin-row strong {
  display: block;
}

.admin-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-row .action-group {
  justify-self: end;
  max-width: 100%;
}

.admin-row .action-group button {
  min-width: 64px;
  padding-inline: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 700;
  font-size: 12px;
  background: #e7f6ed;
  color: var(--ok);
}

.status-badge.suspended {
  background: #fff7ed;
  color: var(--warn);
}

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

  .sidebar {
    position: static;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .status-panel {
    display: none;
  }

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

  .auto-index-summary {
    grid-template-columns: 1fr;
  }

  .auto-index-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .ssot-form {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .ssot-form .action-group {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .advanced-settings {
    grid-template-columns: 1fr;
  }

  .admin-form,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .wide-panel {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .app-shell.login-screen {
    padding: 0;
  }

  .app-shell.login-screen .sidebar {
    min-height: 100vh;
    padding: 24px;
  }

  .app-shell.login-screen .auth-panel {
    align-self: start;
    margin-top: 48px;
  }

  .main,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-head,
  .top-actions,
  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }

  .metrics,
  .editor-grid,
  .status-grid,
  .ssot-form,
  .batch-stats,
  .auto-index-flow {
    grid-template-columns: 1fr;
  }

  .ssot-row {
    grid-template-columns: 1fr;
  }

  .ssot-form {
    grid-template-columns: 1fr;
  }

  .ssot-form .action-group {
    justify-self: stretch;
    width: 100%;
  }

  .ssot-form .action-group button {
    width: 100%;
  }

  .queue-item,
  .result-item {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .queue-item .small-btn,
  .result-item .score {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
