* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f6f8;
  color: #111;
}

header {
  background: #1f2937;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; }
header .subtitle { color: #cbd5e1; font-size: .85rem; }

main { padding: 1.5rem 2rem; max-width: 1280px; margin: 0 auto; }

#pre-upload-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .75rem;
}

#dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 10px;
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  background: white;
  transition: background .15s, border-color .15s;
}
#dropzone.over { border-color: #2563eb; background: #eff6ff; }
#dropzone.loading { opacity: .6; pointer-events: none; }
.dz-headline { margin: 0 0 .25rem; font-size: 1.05rem; font-weight: 600; color: #1f2937; }
.dz-sub { margin: 0; color: #64748b; font-size: .9rem; }
.dz-sub code { background: #f1f5f9; padding: 0 .25rem; border-radius: 3px; }

#results-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}
.muted { color: #64748b; font-size: .85rem; }

button {
  padding: .45rem .9rem;
  border: 1px solid #cbd5e1;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
button:disabled { color: #94a3b8; cursor: not-allowed; background: #f1f5f9; }
button.primary,
#isrc-reserve-btn { background: #2563eb; color: white; border-color: #1d4ed8; }
button.primary:disabled,
#isrc-reserve-btn:disabled { background: #cbd5e1; color: #64748b; border-color: #cbd5e1; }
#isrc-reserve-btn { margin-left: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
th, td {
  padding: .55rem .8rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  font-size: .88rem;
}
th { background: #f1f5f9; font-weight: 600; }
tr:last-child td { border-bottom: none; }

.clickable {
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
}

.badges { display: flex; flex-wrap: wrap; gap: .25rem; }
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 500;
  color: white;
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}
.badge.warning { background: #d97706; }
.badge.error   { background: #dc2626; }
.badge.ok      { background: #16a34a; cursor: default; }

#modal-backdrop,
#reservation-backdrop,
#staging-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#modal-backdrop[hidden],
#reservation-backdrop[hidden],
#staging-backdrop[hidden] { display: none; }

#modal,
.modal {
  background: white;
  border-radius: 10px;
  padding: 1.25rem 1.5rem 1.5rem;
  width: min(720px, 92vw);
  max-height: 85vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .2);
}
#modal-close,
.modal-close {
  position: absolute; top: .35rem; right: .55rem;
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  padding: .25rem .5rem; cursor: pointer; color: #64748b;
}
#modal-title,
.modal h2 { margin: 0 0 .75rem; font-size: 1.1rem; }

.issue-item { padding: .55rem 0; border-bottom: 1px solid #e2e8f0; }
.issue-item:last-child { border-bottom: none; }
.issue-item .row { margin: .2rem 0; font-size: .88rem; }
.issue-item code { background: #f1f5f9; padding: 0 .3rem; border-radius: 3px; }

.section-title {
  margin: 1rem 0 .35rem;
  font-size: .92rem;
  font-weight: 600;
  color: #1f2937;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: .25rem;
}
.kv-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: .5rem;
  padding: .2rem 0;
  font-size: .85rem;
}
.kv-row strong { color: #475569; font-weight: 500; }
.kv-row span { white-space: pre-wrap; word-break: break-word; }
.group-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
  background: #fafafa;
}
.group-card .group-head {
  font-size: .8rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: .04em;
  margin-bottom: .25rem;
}

.payload-table {
  margin: .5rem 0 1rem;
}
.payload-table code { background: #f1f5f9; padding: 0 .3rem; border-radius: 3px; font-size: .82rem; }

.token-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: .5rem;
  margin: .5rem 0 1rem;
}
.token-row input {
  padding: .4rem .55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font: inherit;
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .25rem;
}

.note { margin: .5rem 0 0; font-size: .85rem; }
.note.muted   { color: #64748b; }
.note.success { color: #16a34a; }
.note.error   { color: #dc2626; }
.staging-row-status.success { color: #16a34a; }
.staging-row-status.error   { color: #dc2626; }
