:root {
  --ink: #2e2926;
  --ink-soft: #5f5650;
  --paper: #f6f1ea;
  --surface: #ffffff;
  --surface-soft: #fbf8f4;
  --line: #e5dbd2;
  --line-strong: #cbbdb2;
  --rose: #d8b5a4;
  --rose-soft: #f1ddd3;
  --sage: #dce7d8;
  --sage-strong: #4d6a48;
  --amber: #f4e7bc;
  --danger: #8a3f35;
  --danger-soft: #f2d7d2;
  --shadow: 0 20px 60px rgba(70, 53, 43, 0.12);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(216, 181, 164, 0.24), transparent 34rem),
    var(--paper);
}

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

[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { font-size: clamp(2.25rem, 4vw, 4rem); margin-bottom: 0.7rem; }
h2 { font-size: clamp(1.7rem, 2.5vw, 2.5rem); margin-bottom: 0.55rem; }
h3 { font-size: 1.45rem; margin-bottom: 0; }

.eyebrow {
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.muted { color: var(--ink-soft); }

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(100%, 560px);
  padding: clamp(2rem, 5vw, 4rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.intro {
  margin-bottom: 2rem;
  color: var(--ink-soft);
  line-height: 1.65;
  font-size: 1.05rem;
}

.form-stack { display: grid; gap: 1rem; }
.form-stack label, .upload-field { display: grid; gap: 0.5rem; font-weight: 700; }
.form-stack input, .upload-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: white;
  color: var(--ink);
}
.form-stack input:focus, .upload-field input:focus, button:focus-visible {
  outline: 3px solid rgba(216, 181, 164, 0.45);
  outline-offset: 2px;
}

.form-message {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-weight: 700;
}

.safety-note {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 12px;
  background: var(--sage);
  color: var(--sage-strong);
  line-height: 1.45;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  background: white;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }
.button--primary { background: var(--ink); color: white; box-shadow: 0 8px 24px rgba(46, 41, 38, 0.18); }
.button--quiet { border-color: var(--line); background: var(--surface); }
.button--danger { border-color: var(--danger-soft); background: var(--danger-soft); color: var(--danger); }
.button--small { padding: 0.6rem 0.85rem; font-size: 0.88rem; }

.app-shell { min-height: 100vh; }
.app-header {
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 3vw, 2.6rem);
  border-bottom: 1px solid rgba(229, 219, 210, 0.85);
  background: rgba(246, 241, 234, 0.9);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-header h1 { margin: 0; font-size: 2rem; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.65rem; flex-wrap: wrap; }
.session-user { font-size: 0.88rem; color: var(--ink-soft); }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 102px);
}

.batch-sidebar {
  border-right: 1px solid var(--line);
  padding: 1.5rem;
  background: rgba(251, 248, 244, 0.74);
}
.sidebar-heading, .panel-heading, .detail-header, .dialog-heading, .dialog-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.sidebar-heading h2 { font-size: 1.7rem; }
.batch-list { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.batch-list__empty { color: var(--ink-soft); padding: 1rem 0; }
.batch-card {
  width: 100%;
  display: grid;
  gap: 0.5rem;
  text-align: left;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  cursor: pointer;
}
.batch-card:hover, .batch-card[aria-current="true"] { border-color: var(--rose); box-shadow: 0 10px 28px rgba(79, 58, 47, 0.09); }
.batch-card strong { font-size: 0.96rem; }
.batch-card small { color: var(--ink-soft); }
.batch-card__row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

.content-area { padding: clamp(1rem, 3vw, 2.5rem); min-width: 0; }
.empty-state {
  min-height: 65vh;
  display: grid;
  place-content: center;
  justify-items: start;
  max-width: 680px;
  margin: auto;
}
.empty-state p:not(.eyebrow) { line-height: 1.65; color: var(--ink-soft); font-size: 1.05rem; }

.detail-header { margin-bottom: 1.5rem; }
.detail-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.52rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 800;
  background: var(--amber);
}
.status-pill[data-status="review_required"],
.status-pill[data-status="review_in_progress"] { background: var(--rose-soft); }
.status-pill[data-status="ready_for_final_approval"],
.status-pill[data-status="approved_for_shopify_draft"] { background: var(--sage); color: var(--sage-strong); }
.status-pill[data-status="validation_failed"],
.status-pill[data-status="archived"] { background: var(--danger-soft); color: var(--danger); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.summary-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface);
}
.summary-card strong { display: block; font-size: 1.5rem; margin-bottom: 0.25rem; }
.summary-card span { color: var(--ink-soft); font-size: 0.83rem; }

.panel {
  margin-bottom: 1rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 10px 35px rgba(70, 53, 43, 0.06);
}
.panel-heading { margin-bottom: 1rem; }
.panel-heading h3 { font-size: 1.45rem; }

.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.75rem; }
.source-card {
  min-height: 130px;
  display: grid;
  align-content: space-between;
  gap: 0.7rem;
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: var(--surface-soft);
}
.source-card[data-complete="true"] { border-style: solid; border-color: #b8ccb2; background: #f2f7ef; }
.source-card strong { overflow-wrap: anywhere; }
.source-card small { color: var(--ink-soft); line-height: 1.45; }

.validation-list { display: grid; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }
.validation-item { padding: 0.8rem 0.9rem; border-radius: 10px; background: var(--amber); line-height: 1.45; }
.validation-item--error { background: var(--danger-soft); color: var(--danger); }

.product-list { display: grid; gap: 0.75rem; }
.product-card {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.4fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}
.product-card p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; }
.product-card__meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.meta-chip { border-radius: 999px; padding: 0.35rem 0.55rem; background: white; border: 1px solid var(--line); font-size: 0.75rem; }

.audit-list { display: grid; gap: 0.75rem; padding-left: 1.25rem; }
.audit-list li { padding-left: 0.4rem; }
.audit-list strong { display: block; }
.audit-list small { color: var(--ink-soft); }

.create-dialog {
  width: min(92vw, 680px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: var(--shadow);
  background: transparent;
}
.create-dialog::backdrop { background: rgba(37, 31, 28, 0.55); backdrop-filter: blur(6px); }
.dialog-card { padding: clamp(1.4rem, 4vw, 2.4rem); background: var(--surface); }
.dialog-heading h2 { font-size: 2rem; }
.icon-button { border: 0; background: transparent; font-size: 2rem; line-height: 1; cursor: pointer; }
.upload-field { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.upload-field small { color: var(--ink-soft); font-weight: 500; }
.dialog-actions { justify-content: flex-end; margin-top: 1.25rem; }

.progress-box { margin-top: 1rem; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--ink); transition: width 180ms ease; }
.progress-box p { margin: 0.55rem 0 0; color: var(--ink-soft); }

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  max-width: min(90vw, 420px);
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .batch-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .batch-list { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .product-card { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .login-layout { padding: 1rem; }
  .login-card { padding: 1.5rem; border-radius: 20px; }
  .app-header, .detail-header, .panel-heading, .sidebar-heading { align-items: stretch; flex-direction: column; }
  .header-actions, .detail-actions { justify-content: flex-start; }
  .content-area, .batch-sidebar { padding: 1rem; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}
