* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f4f4f5;
  color: #18181b;
  height: 100vh;
  overflow: hidden;
}

/* ── Layout ──────────────────────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #18181b;
  color: #a1a1aa;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #27272a;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.nav-section {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #52525b;
}

.nav-item {
  display: block;
  padding: 0.45rem 1.25rem;
  font-size: 0.875rem;
  color: #a1a1aa;
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}

.nav-item:hover:not(.disabled) {
  background: #27272a;
  color: #fff;
}

.nav-item.active {
  background: #3f3f46;
  color: #fff;
}

.nav-item.disabled {
  opacity: 0.35;
  cursor: default;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #27272a;
}

/* ── Content ─────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.page-desc {
  font-size: 0.875rem;
  color: #71717a;
  margin-top: 0.2rem;
}

/* ── Table ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  background: #fafafa;
  border-bottom: 1px solid #e4e4e7;
}

.data-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid #f4f4f5;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }

.empty { color: #a1a1aa; font-style: italic; }
.muted { color: #71717a; }
.actions { display: flex; gap: 0.5rem; }

/* ── Badge ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge--green  { background: #dcfce7; border-color: #86efac; color: #16a34a; }
.badge--muted  { background: #f4f4f5; border-color: #e4e4e7; color: #a1a1aa; }
.badge--type-audit    { background: #eff6ff; border-color: #bfdbfe; color: #2563eb; }
.badge--type-training { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge--type-augment  { background: #fdf4ff; border-color: #e9d5ff; color: #7c3aed; }

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  padding: 0.5rem 1rem;
  background: #18181b;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary:hover { background: #27272a; }

.btn-secondary {
  padding: 0.5rem 1rem;
  background: #fff;
  color: #18181b;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}
.btn-secondary:hover { background: #f4f4f5; }

.tab-bar {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #e4e4e7;
  padding-bottom: 0;
}

.tab-btn {
  padding: 0.5rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #71717a;
  cursor: pointer;
}

.tab-btn:hover { color: #18181b; }
.tab-btn.active { color: #18181b; border-bottom-color: #18181b; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.btn-back {
  background: none;
  border: none;
  color: #71717a;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0 0.25rem 0;
  display: block;
}
.btn-back:hover { color: #18181b; }

.btn-materials {
  padding: 0.25rem 0.75rem;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
}
.btn-materials:hover { background: #dbeafe; }

.btn-icon {
  padding: 0.3rem 0.65rem;
  background: #f4f4f5;
  color: #3f3f46;
  border: 1px solid #e4e4e7;
  border-radius: 5px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-icon:hover { background: #e4e4e7; }
.btn-icon.danger { color: #dc2626; }
.btn-icon.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-icon.accent { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
.btn-icon.accent:hover { background: #dbeafe; }

/* ── Status badge ────────────────────────────────────── */
.status {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #3f3f46;
  color: #a1a1aa;
}
.status.ok { background: #16a34a; color: #fff; }
.status.error { background: #dc2626; color: #fff; }

/* ── Modal ───────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.modal-box {
  position: relative;
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.modal-box h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #3f3f46;
}

.form-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: #18181b; }

.form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  outline: none;
  cursor: pointer;
}

.form-group textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
}

.field-error {
  font-size: 0.78rem;
  color: #dc2626;
}
.field-error.hidden { display: none; }

/* ── Inorganic Training ──────────────────────────────── */
.training-setup { display: flex; flex-direction: column; gap: 1.5rem; }

.setup-section {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
.setup-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  margin-bottom: 1rem;
}

.source-buttons { display: flex; gap: 0.75rem; }
.source-btn {
  padding: 0.6rem 1.25rem;
  border: 2px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
  cursor: pointer;
}
.source-btn.active { border-color: #18181b; background: #18181b; color: #fff; }
.source-btn.disabled { opacity: 0.4; cursor: not-allowed; }

.event-display { margin-top: 1rem; }
.event-display label {
  font-size: 0.8rem; font-weight: 500; color: #3f3f46;
  display: block; margin-bottom: 0.35rem;
}

.io-preview {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}
.more-card {
  display: flex; align-items: center; justify-content: center;
  font-size: 0.875rem; color: #71717a; background: #f4f4f5;
  border-radius: 6px; aspect-ratio: 1;
}

.btn-large { padding: 0.75rem 2rem; font-size: 1rem; }

.io-file-list {
  margin-top: 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
}
.file-list-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-bottom: 1px solid #f4f4f5;
}
.file-list-row:last-child { border-bottom: none; }
.file-list-num { color: #a1a1aa; min-width: 2rem; text-align: right; }
.file-list-name { flex: 1; color: #18181b; }
.file-list-size { color: #a1a1aa; }

.io-progress-area {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
.progress-header {
  display: flex; justify-content: space-between;
  font-size: 0.875rem; margin-bottom: 0.75rem;
}
.progress-bar-track {
  height: 8px; background: #f4f4f5; border-radius: 999px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: #16a34a; border-radius: 999px;
  transition: width 0.2s ease; width: 0%;
}

/* ── Gallery ─────────────────────────────────────────── */
.gallery {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gallery-card {
  background: #fff;
  border: 2px solid #e4e4e7;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s;
}

.gallery-card.selected { border-color: #2563eb; }

.card-material {
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #3f3f46;
  background: #fafafa;
  border-bottom: 1px solid #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f4f4f5;
  display: block;
}

.card-select-btn {
  width: 100%;
  padding: 0.35rem;
  border: none;
  border-top: 1px solid #e4e4e7;
  background: #fafafa;
  font-size: 0.75rem;
  cursor: pointer;
  color: #71717a;
}
.card-select-btn:hover { background: #f4f4f5; }
.card-select-btn.active { background: #eff6ff; color: #2563eb; font-weight: 600; }

/* ── Bulk bar ─────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: #18181b;
  color: #fff;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.bulk-bar.hidden { display: none; }
.bulk-bar #bulk-count { font-size: 0.875rem; font-weight: 600; flex: 1; }

/* ── Filters ──────────────────────────────────────────── */
.filters { display: flex; gap: 0.75rem; align-items: center; }
.filters select {
  padding: 0.4rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  outline: none;
  cursor: pointer;
}

/* ── Paging ───────────────────────────────────────────── */
.paging {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
}
.paging-info { font-size: 0.875rem; color: #71717a; }

/* ── Checkbox list ───────────────────────────────────── */
.checkbox-list {
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.checkbox-list--lg {
  max-height: 340px;
}

.modal-box--lg {
  width: 520px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.checkbox-item:hover { background: #f4f4f5; }
.checkbox-item input { cursor: pointer; }

.form-row {
  display: flex;
  gap: 0.75rem;
}
.form-row .form-group { flex: 1; }

.material-picker-btn {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  background: #fff;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  color: #18181b;
}
.material-picker-btn:hover:not(:disabled) { border-color: #18181b; }
.material-picker-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pick-list {
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}
.pick-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.pick-item:hover { background: #f4f4f5; }
.pick-item.selected { background: #eff6ff; color: #2563eb; font-weight: 500; }
.pick-check { color: #2563eb; font-weight: 700; }

.inline-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.inline-add input, .inline-add select {
  flex: 1;
  padding: 0.4rem 0.75rem;
  border: 1px solid #e4e4e7;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  background: #fff;
  font-family: inherit;
}
.inline-add input:focus, .inline-add select:focus { border-color: #18181b; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
