:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f5f7fa;
  --panel: #ffffff;
  --blue: #2563eb;
  --green: #16835b;
  --amber: #b76e00;
  --red: #c2413d;
  --violet: #6d5bd0;
  --shadow: 0 8px 24px rgba(29, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef2f7;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.boot,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1,
.view-head h1,
.project-title h1 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 28px;
}

.login-panel p,
.muted {
  color: var(--muted);
}

.login-panel form,
.form-grid,
.brand-form,
.user-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.field label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

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

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 12px;
  background: var(--blue);
  color: white;
  font-weight: 800;
}

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

.button.success {
  background: var(--green);
}

.button.warn {
  background: var(--amber);
}

.button.danger {
  background: var(--red);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #101828;
  color: #fff;
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 22px;
}

.brand {
  display: grid;
  gap: 4px;
}

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

.brand span {
  color: #b6c2d2;
  font-size: 13px;
}

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

.nav button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: transparent;
  color: #e6edf7;
  text-align: left;
  padding: 9px 10px;
}

.nav button.active,
.nav button:hover {
  background: #243449;
}

.user-box {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  color: #d9e2ee;
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.view-head,
.project-title,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.view-head h1,
.project-title h1 {
  font-size: 24px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(280px, 420px) 1fr;
  align-items: start;
}

.panel,
.project-row,
.format-card,
.brand-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.project-row,
.brand-row {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.project-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.project-row:hover {
  border-color: #9db6f4;
}

.project-row h3,
.brand-row h3,
.format-card h3 {
  margin: 0;
  font-size: 16px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #e8eef8;
  color: #344054;
}

.chip.ready,
.chip.approved {
  background: #dff6ec;
  color: #075f3f;
}

.chip.queued,
.chip.generating {
  background: #fff0cf;
  color: #8a5200;
}

.chip.failed,
.chip.needs_revision {
  background: #fde2df;
  color: #9b2c2c;
}

.chip.ready_with_warnings {
  background: #fff4df;
  color: #8a5200;
}

.empty {
  padding: 28px;
  border: 1px dashed #bdc7d6;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.error {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #f3b1ad;
  border-radius: 6px;
  background: #fff1f0;
  color: #9b2c2c;
}

.success-note {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #aee0c8;
  border-radius: 6px;
  background: #edfdf5;
  color: #075f3f;
}

.preset-groups {
  display: grid;
  gap: 14px;
  max-height: 420px;
  overflow: auto;
  padding-right: 6px;
}

.preset-group {
  display: grid;
  gap: 8px;
}

.preset-group h3 {
  margin: 0;
  font-size: 14px;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.check input {
  width: 16px;
  min-height: 16px;
}

.preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: #dfe6f0;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.format-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.variant-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f3f8;
}

.variant-preview-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  overflow: hidden;
}

.variant-preview-trigger:hover .variant-preview-label,
.variant-preview-trigger:focus-visible .variant-preview-label {
  opacity: 1;
}

.variant-preview-trigger:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.variant-preview-label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  opacity: 0;
  transition: opacity 120ms ease;
}

.variant-placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed #bdc7d6;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
  padding: 16px;
}

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

.history {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.correction-form {
  display: grid;
  gap: 8px;
}

/* ── Project assets ── */

.project-assets-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
  margin-bottom: 0;
}

.asset-upload-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.asset-kind-select {
  width: auto;
  min-width: 160px;
  flex-shrink: 0;
}

.asset-upload-row input[type="file"] {
  flex: 1;
  min-width: 100px !important;
  width: auto !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  opacity: 1 !important;
  display: block !important;
  height: 40px !important;
  padding: 8px 10px !important;
  border: 1px solid var(--line) !important;
  border-radius: 6px !important;
  background: #fff !important;
  color: var(--ink) !important;
}

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

.asset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.asset-thumb {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  flex-shrink: 0;
}

.asset-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.asset-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.asset-delete {
  flex-shrink: 0;
  min-height: 30px;
  padding: 4px 10px;
  font-size: 16px;
  line-height: 1;
}

.variant-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 15, 26, 0.72);
  backdrop-filter: blur(8px);
}

.variant-modal-panel {
  width: min(96vw, 1280px);
  max-height: 92vh;
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(3, 7, 18, 0.35);
}

.variant-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.variant-modal-image {
  width: 100%;
  max-height: calc(92vh - 220px);
  object-fit: contain;
  background: #0f172a;
  border-radius: 12px;
}

.variant-modal-notes {
  display: grid;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.variant-modal-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.variant-warning-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  color: var(--ink);
}

.empty.compact {
  padding: 12px 14px;
  min-height: 0;
}

.correction-form textarea {
  min-height: 74px;
}

.analysis-json {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border-radius: 6px;
  background: #101828;
  color: #d6e4ff;
  font-size: 12px;
}

.brand-list,
.user-list {
  display: grid;
  gap: 12px;
}

.brand-row.inactive,
.user-row.inactive {
  opacity: 0.65;
}

.user-filter-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px 140px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.user-row .toolbar {
  margin-bottom: 0;
}

.asset-form {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 8px;
  align-items: end;
}

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

  .sidebar {
    position: static;
  }

  .grid.two,
  .project-row,
  .asset-form,
  .user-filter-form {
    grid-template-columns: 1fr;
  }

  .view-head,
  .project-title,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
