@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg-canvas: #12151a;
  --bg-panel: #1a1e25;
  --bg-panel-raised: #232830;
  --bg-input: #1a1e25;
  --border: #2c333d;
  --border-soft: #232830;
  --text-primary: #e9e7e2;
  --text-muted: #8b93a1;
  --text-faint: #565f6d;
  --accent: #5b8cff;
  --accent-dim: #2c3a5e;
  --good: #4fae7d;
  --good-dim: #1c3327;
  --mid: #d9a441;
  --mid-dim: #3a2f18;
  --poor: #e0685f;
  --poor-dim: #3a201d;
  --danger: #e0685f;
  --radius: 6px;
  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-data: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

a { color: var(--accent); }

/* ---------- Login screen ---------- */

.login-shell {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.login-mark {
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 9px 10px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #0e1116;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); filter: none; }

.btn-danger { background: var(--poor); color: #1a0e0d; }
.btn-quiet { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

.error-banner {
  background: var(--poor-dim);
  color: var(--poor);
  border: 1px solid var(--poor);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.info-banner {
  background: var(--bg-panel-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- App shell ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.brand {
  font-family: var(--font-data);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 22px;
  padding: 0 6px;
}

.nav-group-label {
  font-size: 11px;
  color: var(--text-faint);
  padding: 0 6px;
  margin: 18px 0 6px;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--bg-panel-raised); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--text-primary); }

.nav-item .count {
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--text-faint);
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 6px 0;
  border-top: 1px solid var(--border-soft);
}

.who {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.who strong { color: var(--text-primary); }

.role-pill {
  display: inline-block;
  font-family: var(--font-data);
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
}

/* ---------- Main column ---------- */

.main {
  overflow-y: auto;
  padding: 24px 28px 60px;
}

.main-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}

.main-header h2 {
  font-size: 18px;
  margin: 0;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.sort-control select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 5px 8px;
}

.subhead {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-bottom: 18px;
}

/* ---------- Table ---------- */

.queue-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.queue-table thead th {
  text-align: left;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.queue-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

.queue-table tbody tr:hover { background: var(--bg-panel-raised); }
.queue-table tbody tr:last-child { border-bottom: none; }

.queue-table td {
  padding: 11px 14px;
  vertical-align: middle;
}

.title-cell { max-width: 420px; }
.title-cell .t { font-weight: 500; }
.title-cell .u { color: var(--text-faint); font-size: 11.5px; }

.score {
  font-family: var(--font-data);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
}

.score.good { color: var(--good); background: var(--good-dim); }
.score.mid { color: var(--mid); background: var(--mid-dim); }
.score.poor { color: var(--poor); background: var(--poor-dim); }

.badge {
  font-family: var(--font-data);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.attempts-flag { color: var(--mid); font-family: var(--font-data); font-size: 11.5px; }

.empty-state, .loading-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------- Detail panel (slide-over) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 13, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.overlay.open { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 92vw);
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.18s ease;
  z-index: 21;
  display: flex;
  flex-direction: column;
}

.panel.open { transform: translateX(0); }

.panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.35;
}

.panel-head .meta {
  font-size: 12px;
  color: var(--text-faint);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
}

.panel-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.section-label {
  font-size: 11px;
  color: var(--text-faint);
  margin: 20px 0 8px;
}
.section-label:first-child { margin-top: 0; }

.prose { font-size: 13.5px; color: var(--text-primary); white-space: pre-wrap; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

.dims {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.dim-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.dim-name { width: 92px; color: var(--text-muted); flex-shrink: 0; }

.dim-bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-panel-raised);
  border-radius: 3px;
  overflow: hidden;
}

.dim-bar-fill { height: 100%; border-radius: 3px; }

.dim-val { font-family: var(--font-data); width: 28px; text-align: right; }

.mates-list { display: flex; flex-direction: column; gap: 6px; }
.mate-item {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 6px 8px;
  background: var(--bg-panel-raised);
  border-radius: 4px;
}
.mate-item .id { font-family: var(--font-data); color: var(--text-faint); margin-right: 6px; }

.issues-block {
  font-family: var(--font-data);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.panel-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.viewer-note {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* ---------- Inline forms inside actions ---------- */

.inline-form {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
}

.inline-form .field { margin-bottom: 10px; }
.inline-form textarea {
  width: 100%;
  min-height: 64px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 8px;
  resize: vertical;
}
.inline-form select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 8px;
}
.inline-form .row-actions { display: flex; gap: 8px; margin-top: 12px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 30;
}
.toast.error { border-color: var(--poor); color: var(--poor); }
.toast.success { border-color: var(--good); color: var(--good); }

