:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1a2332;
  --text-secondary: #4a5568;
  --muted: #718096;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.04);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.layout { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0.25rem 0 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.inline-form {
  display: inline;
  margin: 0;
}

.lead {
  margin: 0.35rem 0 0;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.25rem;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.95rem;
}

.back-link:hover { text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.card-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.125rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 0.4rem 0.75rem;
}

.btn-ghost:hover { background: var(--bg); }

.btn-block { width: 100%; }

.inline { display: inline; margin: 0; }

.form-stack label { display: block; margin-bottom: 1.125rem; }

.label-text {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.label-text em { color: var(--error); font-style: normal; }

.hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea { resize: vertical; min-height: 100px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-top: 1.75rem;
}

.checkbox-field input { width: auto; margin: 0; }

.form-actions { margin-top: 0.5rem; }

.detail-grid {
  display: grid;
  gap: 1.25rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }

.table-card { padding: 0; overflow: hidden; }
.table-card .data-table { margin: 0; }
.table-card th:first-child,
.table-card td:first-child { padding-left: 1.25rem; }
.table-card th:last-child,
.table-card td:last-child { padding-right: 1.25rem; }

.mono { font-family: var(--mono); font-size: 0.92em; }

.tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}

.tag-new { background: #dbeafe; color: #1e40af; }
.tag-generating { background: #fef3c7; color: #92400e; }
.tag-rendered { background: #d1fae5; color: #065f46; }
.tag-needs_review, .tag-error { background: #fee2e2; color: #991b1b; }
.tag-approved { background: #ecfdf5; color: #047857; }

.link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.link:hover { text-decoration: underline; }

.ok { color: var(--success); font-weight: 600; }
.warn { color: var(--warning); font-weight: 600; }
.muted { color: var(--muted); }

.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.empty-state h2 { margin-top: 0; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.photo-item figcaption {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.photo-thumb {
  position: relative;
  width: 100%;
}

.photo-delete-form {
  position: absolute;
  top: 6px;
  right: 6px;
  margin: 0;
}

.photo-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #dc2626;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 1px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.photo-delete-btn:hover {
  background: #b91c1c;
}

.preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.slide-hint {
  margin: 0 0 1rem;
}

.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 1rem 0;
}

.slide-item {
  margin: 0;
}

.slide-preview-link {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f1f5f9;
  transition: box-shadow 0.15s ease;
}

.slide-preview-link:hover {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.slide-preview {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  cursor: zoom-in;
}

.slide-item figcaption {
  margin-top: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.qa-issues {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.spec-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.spec-list dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.spec-list dd { margin: 0; }

.pre, .code-block {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.85rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
  max-height: 320px;
}

.upload-form {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card-title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-link:hover { color: var(--primary); }

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.btn-danger {
  color: var(--error);
}

.btn-danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

label.checkbox input { width: auto; margin: 0; }

.section-hint {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.tag-admin {
  background: #ede9fe;
  color: #5b21b6;
}
