:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f5f4;
  --ink: #17201c;
  --muted: #66736f;
  --line: #d9e0dd;
  --accent: #1f7a68;
  --accent-strong: #155848;
  --accent-soft: #e1f2ed;
  --warn: #a15c12;
  --danger: #a43d3d;
  --shadow: 0 12px 32px rgba(23, 32, 28, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #102722;
  color: #f4fbf8;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #d8b56d;
  color: #102722;
  display: grid;
  place-items: center;
  font-weight: 800;
}

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

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

.brand-lockup p,
.topbar p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.brand-lockup p {
  color: #b8c9c3;
}

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

.nav-stack a {
  color: #e9f4ef;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 14px;
}

.nav-stack a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.side-panel {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.side-panel h2 {
  font-size: 14px;
  margin-bottom: 12px;
}

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

.sequence-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #d9e7e2;
  font-size: 13px;
}

.sequence-item code {
  color: #fff7df;
}

.workspace {
  padding: 22px;
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

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

.topbar-actions,
.button-row,
.control-row,
.batch-tools,
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-header h3 {
  font-size: 17px;
}

.section-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.primary-btn,
.ghost-btn,
.copy-mini,
.segment {
  border: 1px solid var(--line);
  min-height: 36px;
  border-radius: 8px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--ink);
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

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

.ghost-btn:hover,
.copy-mini:hover,
.segment:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 8px;
}

.segment {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
}

.segment.active {
  background: white;
  border-color: var(--line);
  color: var(--accent-strong);
  font-weight: 700;
}

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

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

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

.checkbox-label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox-label input {
  width: auto;
}

.compact-check {
  min-height: 36px;
  padding: 0 4px;
  white-space: nowrap;
}

.search-input {
  min-width: 220px;
}

.inline-input {
  min-width: 220px;
  padding: 7px 9px;
}

.compact-inline {
  min-width: 132px;
  max-width: 170px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 74px;
}

.span-2 {
  grid-column: span 2;
}

.small-input {
  width: 88px;
}

.batch-box {
  display: grid;
  gap: 10px;
}

.batch-tools {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.input-hint {
  color: var(--muted);
  font-size: 13px;
}

.upload-strip {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.writer-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.panel-header.compact {
  margin-bottom: 0;
}

.upload-status {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 10px;
}

.issue-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #f0d2a4;
  border-radius: 8px;
  background: #fff8eb;
  color: var(--warn);
  font-size: 13px;
}

.hidden {
  display: none;
}

.dev-login-backdrop {
  z-index: 80;
  align-items: center;
  background: rgba(28, 36, 33, 0.38);
}

.dev-login-card {
  width: min(520px, calc(100vw - 28px));
}

.login-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #efb7ad;
  border-radius: 8px;
  background: #fff3f0;
  color: #a33a2d;
  font-size: 13px;
  font-weight: 700;
}

.table-shell {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.table-shell.wide {
  max-height: 520px;
}

.table-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.compact-table {
  max-height: 235px;
  margin-bottom: 14px;
}

.compact-table.is-expanded {
  max-height: 620px;
}

.candidate-review-layout {
  display: grid;
  grid-template-columns: minmax(440px, 0.95fr) minmax(520px, 1.25fr);
  gap: 14px;
  align-items: start;
}

.candidate-list-shell {
  max-height: 680px;
}

.candidate-summary-table {
  min-width: 720px;
}

.candidate-summary-table td {
  max-width: 220px;
}

.candidate-summary-table td:nth-child(5) {
  max-width: 250px;
}

.candidate-detail-panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.candidate-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5eeea;
  border-radius: 8px;
  background: #f7fbf9;
}

.candidate-detail-head h4 {
  margin: 4px 0 8px;
  font-size: 17px;
  line-height: 1.3;
}

.empty-detail {
  padding: 18px;
  border: 1px dashed #bfd6ce;
  border-radius: 8px;
  background: #f6fbf8;
  color: var(--muted);
}

.quality-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  background: #eef4f2;
  color: var(--muted);
  white-space: nowrap;
}

.mini-tag.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mini-tag.bad {
  background: #fbe7e7;
  color: var(--danger);
}

.mini-tag.applied {
  background: #eef0ff;
  color: #4353a5;
}

.candidate-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

tr.is-active-row {
  background: #eef8f4;
  box-shadow: inset 3px 0 0 var(--accent);
}

tr.is-applied-row {
  background: #f6f7ff;
}

tr.is-active-row.is-applied-row {
  background: #eef5ff;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf1ee;
  color: #20342e;
  font-weight: 750;
  white-space: nowrap;
}

td {
  color: #27352f;
  max-width: 360px;
}

tbody tr:hover {
  background: #fbfdfc;
}

.copy-mini {
  min-height: 30px;
  padding: 0 10px;
}

.danger-mini {
  border-color: #e4c8c8;
  color: var(--danger);
}

.danger-mini:hover {
  border-color: var(--danger);
  background: #fbe7e7;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
}

.pill-ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

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

.pill-button {
  border: 0;
  cursor: pointer;
}

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

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  background: #eef4f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.is-hidden-col {
  display: none;
}

.tree-parent {
  background: #edf8f3;
  font-weight: 700;
}

.tree-child {
  background: #fbfdfc;
}

.tree-child td:first-child,
.tree-child td:nth-child(3) {
  box-shadow: inset 3px 0 0 #9fd0bd;
}

.is-double-variation-row {
  background: #f6f7ff;
}

.is-disabled-row {
  opacity: 0.58;
  background: #f7f7f5;
}

.is-disabled-row input,
.is-disabled-row button {
  cursor: not-allowed;
}

.is-refurbished-row {
  background: #fffaf1;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tree-child td:nth-child(6) {
  padding-left: 28px;
}

.tree-toggle {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(11, 22, 19, 0.45);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
}

.modal-wide {
  width: min(980px, 100%);
}

.modal-header {
  position: sticky;
  top: -18px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 14px;
  padding: 18px 52px 12px 18px;
  border-bottom: 1px solid rgba(220, 230, 225, 0.9);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.modal-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

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

.brand-preference {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.brand-preference label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-weight: 700;
}

body[data-brand="CL"] .sidebar {
  border-right-color: #9cc7b8;
}

body[data-brand="LA"] .sidebar {
  border-right-color: #c5acd6;
}

body[data-brand="CL"] .mark,
.brand-cl .mark {
  background: #256b57;
}

body[data-brand="LA"] .mark {
  background: #6f4aa2;
}

.sequence-brand {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #b8cbc4;
  border-radius: 8px;
  background: #f7fbf9;
  color: #10241d;
}

.sequence-brand.is-preferred {
  border-color: #8ab9a9;
  box-shadow: 0 0 0 2px rgba(79, 140, 118, 0.1);
}

.sequence-brand.brand-la.is-preferred {
  border-color: #b39ad0;
  box-shadow: 0 0 0 2px rgba(111, 74, 162, 0.1);
}

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

.sequence-brand-head strong {
  color: #10241d;
  font-weight: 900;
}

.sequence-stats,
.sequence-empty {
  color: #43564f;
  font-size: 12px;
  font-weight: 700;
}

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

.sequence-brand.brand-cl {
  background: #eef8f4;
}

.sequence-brand.brand-la {
  background: #f5f0fb;
}

.sequence-brand .sequence-item {
  background: rgba(255, 255, 255, 0.88);
}

.sequence-brand .sequence-item code,
.sequence-brand .sequence-item span {
  color: #162a23;
  font-weight: 800;
}

.brand-row.brand-cl td:first-child {
  border-left: 4px solid #4f8c76;
}

.brand-row.brand-la td:first-child {
  border-left: 4px solid #7c5aa8;
}

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

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

.compare-card.brand-cl {
  border-top: 4px solid #4f8c76;
}

.compare-card.brand-la {
  border-top: 4px solid #7c5aa8;
}

.compare-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

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

.compare-card-head h5 {
  margin: 3px 0 0;
  font-size: 16px;
}

.compact-select {
  display: inline-grid;
  grid-template-columns: auto minmax(132px, 160px);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

#parentTable th:nth-child(4),
#parentTable td:nth-child(4) {
  width: 150px;
  max-width: 150px;
  white-space: normal;
}

.variation-pill-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.variation-pill-stack .pill {
  white-space: normal;
  line-height: 1.2;
}

#parentTable th:nth-child(6),
#parentTable td:nth-child(6) {
  min-width: 220px;
}

#parentTable th:nth-child(7),
#parentTable td:nth-child(7) {
  min-width: 260px;
}

.is-uncertain-row {
  background: #fff3f1;
}

.is-uncertain-row td {
  border-bottom-color: #f3c5be;
}

.parent-compare-table table {
  min-width: 880px;
}

.import-label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.import-label input {
  display: none;
}

.detail-box {
  min-height: 180px;
  max-height: 540px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  color: #22342e;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.45;
}

.product-detail-card {
  width: min(1120px, 100%);
}

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

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f5fbf8, #ffffff);
}

.detail-kicker {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-hero h4 {
  margin: 5px 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

.detail-badges,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

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

.detail-panel h4 {
  margin: 0;
  font-size: 15px;
}

.detail-line {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #eef3f1;
}

.detail-line:last-child {
  border-bottom: 0;
}

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

.detail-line strong {
  min-width: 0;
  word-break: break-word;
  font-size: 13px;
}

.copy-block {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid #edf2f0;
  border-radius: 8px;
  background: #fbfdfc;
}

.copy-block-head,
.detail-child-row,
.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.sibling-compare table {
  min-width: 760px;
}

.copy-block p {
  margin: 0;
  color: #27352f;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.detail-child-row,
.history-row {
  justify-content: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #eef3f1;
}

.history-row span {
  min-width: 140px;
  color: var(--muted);
  font-size: 12px;
}

.history-row code {
  color: var(--accent-strong);
}

.attribute-placeholder {
  padding: 12px;
  border: 1px dashed #bfd6ce;
  border-radius: 8px;
  background: #f6fbf8;
}

.attribute-placeholder p {
  margin: 6px 0 0;
  color: var(--muted);
}

.attribute-template-list {
  margin-top: 14px;
}

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

.backup-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6faf8;
}

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

.backup-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

@media (max-width: 980px) {
  .split-grid {
    grid-template-columns: 1fr;
  }

  .detail-hero,
  .detail-grid,
  .compare-grid,
  .candidate-review-layout {
    grid-template-columns: 1fr;
  }

  .candidate-detail-panel {
    position: static;
  }

  .backup-item {
    grid-template-columns: 1fr;
  }
}

.status-high {
  color: var(--danger);
  font-weight: 700;
}

.status-mid {
  color: var(--warn);
  font-weight: 700;
}

.status-low {
  color: var(--accent-strong);
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 320px;
  min-height: 38px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #102722;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-stack a {
    text-align: center;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 12px;
  }

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

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

  .span-2 {
    grid-column: auto;
  }

  .detail-line {
    grid-template-columns: 1fr;
  }

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