:root {
  --bg: #0f172a;
  --panel: #111827;
  --accent: #f97316;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --good: #22c55e;
  --warn: #facc15;
  --danger: #ef4444;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 20% 20%, rgba(249, 115, 22, 0.15), transparent 25%),
              radial-gradient(circle at 80% 0%, rgba(79, 70, 229, 0.18), transparent 25%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a.card-link { display: block; }

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img {
  height: 48px;
  width: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.header h1 {
  font-size: 32px;
  letter-spacing: -0.04em;
  margin: 0;
}
.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 120ms ease, border-color 120ms ease;
}
.card:hover { transform: translateY(-2px); border-color: rgba(249, 115, 22, 0.35); }
.card h3 { margin: 0; letter-spacing: -0.02em; }
.card .meta { color: var(--muted); font-size: 14px; }
.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.id-big {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
}
.id-big small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }

.thumb {
  width: 100%;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #0b0f19;
}
.status-ready_to_format { background: #facc15; }
.status-ready { background: var(--good); }
.status-needs_backup { background: var(--danger); }
.holder-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #a855f7;
  color: #0b0f19;
  font-weight: 700;
  font-size: 13px;
}
.holder-pill.holder-office {
  background: var(--accent);
}
.badge-issue {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.14);
  color: #fecdd3;
  font-weight: 700;
  font-size: 12px;
}

.quick-popover {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  padding: 10px;
  border-radius: 12px;
  max-width: 280px;
}
.pill-option {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.pill-option:hover {
  background: rgba(255, 255, 255, 0.16);
}
.pill-option.holder-default { background: #a855f7; color: #0b0f19; }
.pill-option.status-needs_backup { background: var(--danger); color: #0b0f19; }
.pill-option.status-ready_to_format { background: var(--warn); color: #0b0f19; }
.pill-option.status-ready { background: var(--good); color: #0b0f19; }
.pill-option.holder-office { background: var(--accent); color: #0b0f19; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.toolbar input, .toolbar select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  min-width: 180px;
}
.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.toolbar .spacer { flex: 1 1 auto; }
.filter-group {
  display: grid;
  gap: 8px;
}
.filter-label {
  font-size: 13px;
  color: var(--muted);
}
.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }
.toggle {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.toggle.active {
  border-color: rgba(249, 115, 22, 0.8);
  background: rgba(249, 115, 22, 0.12);
  color: var(--text);
}

button.primary {
  background: linear-gradient(135deg, #f97316, #fbbf24);
  color: #0b0f19;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease;
}
button.primary:hover { transform: translateY(-1px); }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  margin: 12px 0 8px;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-size: 13px;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(249, 115, 22, 0.08);
  color: var(--text);
  font-size: 14px;
}

.item-page {
  max-width: 720px;
  margin: 0 auto;
}
.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.item-header h2 { margin: 0; }
.item-id-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.item-id {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.75);
}
.item-id-label { font-size: 12px; color: var(--muted); }
.item-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.item-thumb {
  width: 180px;
  aspect-ratio: 5 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stack { display: grid; gap: 14px; }
.stack input, .stack select, .stack textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
}
.stack textarea { min-height: 80px; resize: vertical; }

.two-col {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.list {
  display: grid;
  gap: 10px;
}
.list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  align-items: center;
  transition: transform 120ms ease, border-color 120ms ease;
}
.list-row:hover { transform: translateY(-2px); border-color: rgba(249, 115, 22, 0.35); }
.list-thumb {
  width: 96px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}
.list-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.list-title { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.02em; }
.list-meta { color: var(--muted); font-size: 14px; }
.id-inline {
  font-weight: 800;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.8);
}
.list-actions { display: flex; gap: 8px; align-items: center; }
.holder-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.holder-big {
  font-size: 20px;
  font-weight: 800;
  color: #e5e7eb;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.history-list {
  display: grid;
  gap: 10px;
}
.history-entry {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}
.history-date {
  font-size: 12px;
  color: var(--muted);
}
.history-body {
  margin-top: 4px;
  font-weight: 600;
}

.qr-panel {
  display: grid;
  gap: 12px;
}
.qr-box {
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}
.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.version-foot {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

@media (max-width: 640px) {
  .header { flex-direction: column; align-items: flex-start; }
  .item-header { flex-direction: column; align-items: flex-start; }
  .item-id-stack { align-items: flex-start; }
  .list-row { grid-template-columns: 1fr; }
  .list-actions { justify-content: flex-start; }
}
