/* LeninShop admin — dark record-shop palette: charcoal, cream, red accent. */

:root {
  --bg: #17130f;
  --bg-raised: #221c16;
  --bg-input: #2c241c;
  --line: #3b3025;
  --line-soft: #2c241c;
  --text: #f3ece0;
  --text-dim: #a89880;
  --accent: #c8102e;
  --accent-hot: #e2263f;
  --yellow: #f5c518;   /* the painted steel columns */
  --brick: #8b4a3a;    /* the exposed back wall */
  --ok: #5aa06a;
  --warn: #d9a441;
  --radius: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .55);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* An explicit `display` in a class rule beats the default UA styling for the
   `hidden` attribute, so state it outright — the whole UI toggles on `hidden`. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--text-dim); }
.grow { flex: 1; }
.hint { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.req { color: var(--accent); }
.error { color: #e8776a; font-size: 13px; margin: 10px 0 0; }

/* ── Controls ──────────────────────────────────────────────────────── */

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

input[type="text"], input[type="password"], input[type="url"],
input[type="number"], input[type="search"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, .18);
}

textarea { resize: vertical; font-family: inherit; }
select { cursor: pointer; }

.btn {
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-input);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #43434d; background: #2a2a31; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn-primary:hover { background: var(--accent-hot); border-color: var(--accent-hot); }

.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: #5c2b26; color: #e8776a; }
.btn-danger:hover { background: #3a1c19; border-color: #7d3a33; }
.btn-block { width: 100%; }
.icon-btn { padding: 8px 11px; line-height: 1; }

/* ── Login ─────────────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #1e1e23 0%, var(--bg) 60%);
}

.login-card {
  width: min(360px, 100%);
  padding: 34px 30px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { font-size: 24px; margin-bottom: 2px; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card input { margin-bottom: 12px; text-align: center; }

.login-mark, .brand-mark {
  display: block;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--accent) 0 18%, transparent 19%),
    repeating-radial-gradient(circle, #26262b 0 2px, #191919 2px 4px);
}
.login-mark { width: 56px; height: 56px; margin: 0 auto 14px; }
.brand-mark { width: 22px; height: 22px; }

/* ── Top bar ───────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-weight: 650; letter-spacing: .01em; }
.brand-sub { color: var(--text-dim); font-size: 12px; border-left: 1px solid var(--line); padding-left: 9px; }

.scan-wrap {
  position: relative;
  flex: 1;
  max-width: 340px;
  margin-left: auto;
}
.scan-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-dim);
  pointer-events: none;
}
#scan-input { padding-left: 34px; font-family: var(--mono); font-size: 13px; }
#scan-input:focus { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(76, 154, 106, .2); }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* ── Stats ─────────────────────────────────────────────────────────── */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px 0;
}
.stat {
  flex: 1 1 120px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.stat-value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); margin-top: 2px; }
.stat.alert .stat-value { color: var(--warn); }

/* ── Toolbar ───────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.toolbar .grow { min-width: 220px; }
.toolbar select { width: auto; min-width: 130px; }

/* ── Item table ────────────────────────────────────────────────────── */

.table-wrap { padding: 0 20px; overflow-x: auto; }

table.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.items th {
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.items td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.items tbody tr:hover { background: #1a1a1e; }
table.items tbody tr.unpublished { opacity: .55; }

.col-art { width: 48px; }
.col-format, .col-year, .col-cond { width: 90px; white-space: nowrap; }
.col-qty { width: 120px; }
.col-pub { width: 56px; }
.col-actions { width: 76px; }

.cover {
  width: 40px; height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: #232329;
  display: block;
}
.cover-empty {
  width: 40px; height: 40px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #202026 0 5px, #1a1a1f 5px 10px);
  display: grid; place-items: center;
  color: #4a4a55; font-size: 15px;
}

.release-artist { font-weight: 550; }
.release-title { color: var(--text-dim); font-size: 13px; }
.release-meta { color: #6d6a64; font-size: 11px; font-family: var(--mono); margin-top: 1px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  background: #26262d;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-dim);
}
.tag.oos { background: #3a1c19; border-color: #5c2b26; color: #e8776a; }

/* Quantity stepper */
.qty { display: flex; align-items: center; gap: 4px; }
.qty button {
  width: 24px; height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  line-height: 1;
}
.qty button:hover { background: #2f2f37; }
.qty-value {
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.qty-value.zero { color: var(--accent); }

/* Publish toggle */
.switch { position: relative; display: inline-block; width: 34px; height: 19px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: #33333c;
  border-radius: 19px;
  transition: background .18s;
}
.switch span::before {
  content: "";
  position: absolute;
  height: 13px; width: 13px;
  left: 3px; top: 3px;
  background: #8d8d97;
  border-radius: 50%;
  transition: transform .18s, background .18s;
}
.switch input:checked + span { background: rgba(76, 154, 106, .4); }
.switch input:checked + span::before { transform: translateX(15px); background: var(--ok); }

.empty { padding: 60px 20px; text-align: center; color: var(--text-dim); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
}

/* ── Modal ─────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .68);
  display: grid;
  place-items: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

.modal-card {
  width: min(880px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-narrow { width: min(560px, 100%); }

.modal-head, .modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
}
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-foot { border-top: 1px solid var(--line); }

.modal-body { padding: 20px; overflow-y: auto; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
/* Block, not flex: the caption text and its inline <span class="req|hint">
   badges stay on one line, and the control drops below as a block. */
.field-grid label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-dim);
}
.field-grid label > input,
.field-grid label > select,
.field-grid label > textarea {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-weight: 400;
  font-size: 14px;
}
.field-grid label > select { width: 100%; }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }

.checkbox { display: flex !important; align-items: center; gap: 9px; cursor: pointer; }
.checkbox input { display: inline-block !important; width: 16px; height: 16px; margin-top: 0 !important; accent-color: var(--accent); }
.checkbox span { color: var(--text); font-weight: 400; font-size: 14px; }

.subsection {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.subsection h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 12px; }

/* Photos */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
}
.photo-tile.primary { border-color: var(--accent); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tools {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85));
  opacity: 0;
  transition: opacity .15s;
}
.photo-tile:hover .photo-tools { opacity: 1; }
.photo-tools button {
  flex: 1;
  padding: 3px;
  font-size: 11px;
  border: none;
  border-radius: 3px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  cursor: pointer;
}
.photo-tools button:hover { background: rgba(255, 255, 255, .3); }
.photo-badge {
  position: absolute; top: 4px; left: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.upload-drop {
  display: block;
  padding: 22px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.upload-drop:hover, .upload-drop.dragover { border-color: var(--accent); background: rgba(192, 57, 43, .07); }
.upload-drop b { color: var(--text); }
.upload-drop small { display: block; margin-top: 4px; font-size: 11px; }

.track-list { margin: 0; padding-left: 22px; font-size: 13px; color: var(--text-dim); }
.track-list li { padding: 2px 0; }
.track-list .t-title { color: var(--text); }
.track-list .t-dur { font-family: var(--mono); font-size: 12px; }

/* Requests */
.request {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.request:last-child { border-bottom: none; }
.request.handled { opacity: .45; }
.request-main { flex: 1; }
.request-who { font-weight: 550; font-size: 14px; }
.request-item { color: var(--text-dim); font-size: 13px; }
.request-msg { font-size: 13px; margin-top: 5px; }
.request-when { color: #6d6a64; font-size: 11px; font-family: var(--mono); margin-top: 4px; }

/* ── Toast ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 11px 20px;
  background: #2a2a31;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: rise .2s ease-out;
}
.toast.err { border-left-color: var(--accent); }
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .span2, .span4 { grid-column: 1 / -1; }
  .topbar { flex-wrap: wrap; }
  .scan-wrap { order: 3; max-width: none; flex-basis: 100%; margin-left: 0; }
  .col-year, .col-cond, .col-format { display: none; }
}

/* ── Lookup / review-before-save ───────────────────────────────────── */

.notice {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left-width: 3px;
  font-size: 13px;
  margin-bottom: 16px;
}
.notice-warn { border-left-color: var(--warn); background: rgba(201, 146, 47, .08); }
.notice-info { border-left-color: var(--ok); background: rgba(76, 154, 106, .08); }
.notice strong { color: var(--text); }
.notice .notice-actions { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.notice a { color: var(--text); }

.lookup-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 4px;
  color: var(--text-dim);
  font-size: 14px;
}
.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.candidate-list { display: flex; flex-direction: column; gap: 8px; }

.candidate {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.candidate:hover { border-color: var(--accent); background: #2a2a31; }

.candidate-art {
  width: 54px; height: 54px;
  border-radius: 4px;
  object-fit: cover;
  background: #1a1a1f;
  flex-shrink: 0;
}
.candidate-art.empty {
  display: grid; place-items: center;
  color: #4a4a55; font-size: 19px;
  background: repeating-linear-gradient(45deg, #202026 0 5px, #1a1a1f 5px 10px);
}

.candidate-body { flex: 1; min-width: 0; }
.candidate-artist { font-weight: 600; font-size: 14px; }
.candidate-title { font-size: 13px; color: var(--text); }
.candidate-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidate-source {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.candidate-source.discogs { border-color: #4a4a2b; color: #cbbf7a; }
.candidate-source.musicbrainz { border-color: #3a2b4a; color: #b79ad6; }

.notes {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--text-dim);
}
.notes li { margin: 3px 0; }

.lookup-empty { padding: 26px 4px; color: var(--text-dim); font-size: 14px; }

/* ── Tag editor (genres / styles) ──────────────────────────────────── */

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  padding: 6px 8px;
  min-height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.tag-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(192, 57, 43, .18); }
.tag-chips { display: contents; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 10px;
  background: #30303a;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.tag-chip button {
  width: 17px; height: 17px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.tag-chip button:hover { background: var(--accent); color: #fff; }

.tag-input {
  flex: 1;
  min-width: 110px;
  width: auto !important;
  padding: 3px 2px !important;
  background: none !important;
  border: none !important;
  outline: none;
  font-size: 14px;
  box-shadow: none !important;
}

/* ── Display racks ─────────────────────────────────────────────────── */

.rack-intro { margin: 0 0 16px; }

.rack-list { display: grid; gap: 8px; margin-bottom: 18px; }

.rack-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rack-row.off { opacity: .55; }

.rack-name {
  flex: 1 1 160px;
  min-width: 0;
  padding: 7px 10px !important;
  font-weight: 600;
  /* The sign copy, so it reads like the sign. */
  color: var(--yellow) !important;
  letter-spacing: .02em;
}
.rack-count {
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
}

.rack-add { display: flex; gap: 8px; }
.rack-add input { flex: 1; }

/* ── Rack contents picker ──────────────────────────────────────────── */

.picker-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  margin: 20px 0 10px;
}
.picker-heading:first-child { margin-top: 0; }
.picker-heading .hint { text-transform: none; letter-spacing: 0; }

#picker-search { margin-bottom: 12px; }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.picker-tile {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 0 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: border-color .15s, transform .06s;
}
.picker-tile:hover { border-color: var(--accent); }
.picker-tile:active { transform: scale(.98); }

.picker-tile img, .picker-tile .tile-ph {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  margin-bottom: 6px;
}
.picker-tile .tile-ph {
  display: grid;
  place-items: center;
  font-size: 26px;
  color: #4a3f36;
  background: repeating-linear-gradient(45deg, #2a221c 0 6px, #221b16 6px 12px);
}

.tile-artist {
  font-size: 12px;
  font-weight: 600;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-title {
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-mark {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(12, 9, 7, .8);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 15px;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.picker-tile:hover .tile-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
