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

:root {
  --bg:       #0d0d0d;
  --surface:  #161616;
  --surface2: #1e1e1e;
  --border:   #2a2a2a;
  --text:     #d4d4d4;
  --muted:    #666;

  --accent:  #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;

  --p-high:   #ef4444;
  --p-medium: #f59e0b;
  --p-low:    #3b82f6;

  --s-queued:  #22c55e;
  --s-printed: #f59e0b;
  --s-done:    #555;

  --font: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', ui-monospace, monospace;
  --r: 4px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 10px; }

.logo {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--accent);
  user-select: none;
}

.health-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .3s;
}
.health-dot.ok  { background: var(--accent); }
.health-dot.err { background: var(--danger); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; }

.tab {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--r);
  font: inherit;
  font-size: 12px;
  letter-spacing: .05em;
  transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); background: rgba(34,197,94,.08); }

/* ── Layout ── */
.main { max-width: 1200px; margin: 0 auto; padding: 24px; }

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

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Filters ── */
.filter-group { display: flex; gap: 4px; }

.filter {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--r);
  font: inherit;
  font-size: 12px;
  transition: all .15s;
}
.filter:hover { border-color: var(--text); color: var(--text); }
.filter.active { border-color: var(--accent); color: var(--accent); background: rgba(34,197,94,.08); }

/* ── Buttons ── */
.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  padding: 5px 14px;
  border-radius: var(--r);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  transition: all .15s;
}
.btn:hover   { border-color: var(--text); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-sm { padding: 2px 8px; font-size: 11px; }

.btn-primary { border-color: var(--accent);  color: var(--accent); }
.btn-primary:hover  { background: rgba(34,197,94,.1); }

.btn-danger  { border-color: var(--danger);  color: var(--danger); }
.btn-danger:hover   { background: rgba(239,68,68,.1); }

.btn-warning { border-color: var(--warning); color: var(--warning); }
.btn-warning:hover  { background: rgba(245,158,11,.1); }

.btn-group { display: flex; gap: 8px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.col-id      { color: var(--muted); font-size: 12px; white-space: nowrap; }
.col-name    { font-weight: 500; }
.col-desc    { color: var(--muted); font-size: 12px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-date    { color: var(--muted); font-size: 11px; white-space: nowrap; }
.col-actions { white-space: nowrap; text-align: right; }
.col-actions .btn { margin-left: 4px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 2px;
  font-size: 11px;
  border: 1px solid;
  white-space: nowrap;
}
.badge-queued  { color: var(--s-queued);  border-color: rgba(34,197,94,.3);  background: rgba(34,197,94,.08); }
.badge-printed { color: var(--s-printed); border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.08); }
.badge-done    { color: var(--s-done);    border-color: rgba(85,85,85,.3);   background: rgba(85,85,85,.08); }
.badge-high    { color: var(--p-high);    border-color: rgba(239,68,68,.3);  background: rgba(239,68,68,.08); }
.badge-medium  { color: var(--p-medium);  border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.08); }
.badge-low     { color: var(--p-low);     border-color: rgba(59,130,246,.3); background: rgba(59,130,246,.08); }

/* ── States ── */
.empty       { text-align: center; padding: 64px 24px; color: var(--muted); }
.loading     { text-align: center; padding: 32px;      color: var(--muted); font-size: 12px; }
.error-state { padding: 16px; color: var(--danger); font-size: 12px; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.stat-label { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* ── Users ── */
.user-code { font-size: 12px; font-weight: 700; color: var(--accent); }

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

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

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  z-index: 1;
}

.modal-box h2 { font-size: 14px; font-weight: 600; margin-bottom: 20px; }

.confirm-msg { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: var(--r);
  outline: none;
  transition: border-color .15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; }
.field select option { background: var(--surface); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Checkbox ── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 13px;
  z-index: 200;
  transition: opacity .3s;
  max-width: 320px;
}
.toast.hidden { display: none; }
.toast.ok  { border-color: var(--accent);  color: var(--accent); }
.toast.err { border-color: var(--danger);  color: var(--danger); }

/* ── Priority Zones ── */
.zones { display: flex; flex-direction: column; gap: 16px; }

.zone-section {}

.zone-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.zone-count {
  color: var(--muted);
  font-size: 11px;
}

.zone-drop {
  min-height: 60px;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.zone-drop.sortable-over {
  border-color: var(--accent);
  background: rgba(34,197,94,.04);
}

.zone-empty {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

/* Hide zone-empty when the zone has todo cards (modern CSS) */
.zone-drop:has(.todo-card) .zone-empty { display: none; }

/* ── Todo Card ── */
.todo-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  user-select: none;
  cursor: grab;
  transition: border-color .15s;
}
.todo-card:hover  { border-color: #444; }
.todo-card:active { cursor: grabbing; }
.todo-card .btn   { cursor: pointer; }

.drag-handle {
  color: var(--border);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  padding: 2px 4px;
  transition: color .15s;
}
.todo-card:hover .drag-handle { color: var(--muted); }

.card-body { flex: 1; min-width: 0; }

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.card-name { font-weight: 500; font-size: 13px; }

.card-desc {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
}

.card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Sortable states */
.sortable-ghost { opacity: .3; }
.sortable-drag  { opacity: 1;  box-shadow: 0 4px 20px rgba(0,0,0,.5); }

/* ── Stats Page ── */
.stats-section { margin-bottom: 32px; }

.stats-section h3 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 16px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 0;
}

.chart-box h4 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 16px;
}

.chart-wrap      { position: relative; height: 200px; }
.chart-wrap-tall { position: relative; height: 280px; }

/* ── Leaderboard ── */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.lb-rank {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.lb-rank.gold   { color: #fbbf24; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #b45309; }

.lb-name  { flex: 1; font-weight: 500; }
.lb-code  { color: var(--accent); font-size: 12px; font-weight: 700; margin-right: 6px; }
.lb-count { font-size: 22px; font-weight: 700; color: var(--accent); min-width: 32px; text-align: right; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 16px; }
  .header { padding: 0 16px; }
  .col-desc { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .card-desc { display: none; }
}
