* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --warn-bg: #fef2f2;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 200px; flex-shrink: 0;
  background: #0f172a; color: #e2e8f0;
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}
#sidebar h1 { font-size: 19px; margin-bottom: 22px; padding: 0 8px; color: #fff; }
#sidebar a {
  color: #cbd5e1; text-decoration: none; padding: 9px 10px;
  border-radius: 8px; margin-bottom: 4px; font-weight: 500;
}
#sidebar a:hover { background: #1e293b; color: #fff; }
#sidebar a.active { background: var(--accent); color: #fff; }
.nav-footer { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.nav-footer .hint { font-size: 11.5px; color: #64748b; padding: 4px 6px; line-height: 1.4; }
.nav-footer .btn-ghost { color: #94a3b8; border-color: #334155; }
.nav-footer .btn-ghost:hover { background: #1e293b; color: #e2e8f0; }

#main { flex: 1; padding: 24px 28px; min-width: 0; }

/* ---------- Common ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; margin-right: auto; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }

.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--warn-bg); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-ghost { background: transparent; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

input[type=text], input[type=number], select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; outline-offset: -1px; }
label { font-size: 13.5px; font-weight: 600; color: #334155; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
}
.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-state p { margin-bottom: 14px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
table.list th, table.list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; }
table.list th { background: #f8fafc; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.list tr:last-child td { border-bottom: none; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list a { color: var(--accent); font-weight: 600; text-decoration: none; }
table.list a:hover { text-decoration: underline; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: toastIn .2s ease; max-width: 500px; }
.toast.warn { background: #b45309; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin-bottom: 14px; font-size: 18px; }
.modal .modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal .modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal .field { display: flex; flex-direction: column; gap: 5px; }
.modal .checkline { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; }
.modal textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Class editor ---------- */
.class-table-wrap { overflow-x: auto; }
table.class-table { border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
table.class-table th, table.class-table td { border: 1px solid #e2e8f0; padding: 0; }
table.class-table th { background: #f8fafc; padding: 6px 8px; min-width: 130px; }
table.class-table th .col-head { display: flex; flex-direction: column; gap: 4px; }
table.class-table th input { border: none; background: transparent; font-weight: 600; font-size: 14px; width: 100%; padding: 2px 4px; }
table.class-table th select { font-size: 12px; padding: 2px 4px; color: var(--muted); }
table.class-table td input { border: none; width: 100%; padding: 7px 9px; font-size: 14px; background: transparent; }
table.class-table td input:focus { background: #eff6ff; outline: none; }
table.class-table td.rownum { padding: 4px 8px; color: var(--muted); font-size: 12.5px; text-align: right; background: #f8fafc; min-width: 34px; }
table.class-table td.rowdel { padding: 0 4px; }
.del-x { border: none; background: none; color: #cbd5e1; cursor: pointer; font-size: 15px; padding: 4px; }
.del-x:hover { color: var(--danger); }

/* ---------- Room canvas ---------- */
.room-outer { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.room-inner { position: absolute; top: 0; left: 0; transform-origin: top left; }
.board-bar {
  position: absolute; left: 15%; width: 70%; height: 34px;
  background: #334155; color: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; letter-spacing: .25em; font-weight: 600;
}
.desk {
  position: absolute; border: 2px solid #94a3b8; border-radius: 8px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 14px; line-height: 1.15; font-weight: 600;
  user-select: none; touch-action: none; overflow: hidden; padding: 2px;
}
.desk .desk-num { position: absolute; top: 1px; left: 5px; font-size: 10px; color: #94a3b8; font-weight: 400; }
.desk.empty { border-style: dashed; color: #cbd5e1; font-weight: 400; }
.desk.occupied { cursor: grab; }
.desk.drop-hover { outline: 3px solid var(--accent); outline-offset: 1px; }
.desk.warn { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(220,38,38,.35); }
.desk .warn-badge { position: absolute; top: -1px; right: 2px; font-size: 12px; }
.desk .stu-dot { position: absolute; bottom: 3px; right: 4px; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.desk.paint-target { cursor: crosshair; }
.desk .desk-name { display: block; max-width: 100%; overflow: hidden; }
/* markør for siden eleven sitter på (roterer med pulten) */
.desk::after { content: ''; position: absolute; bottom: 2px; left: 30%; width: 40%; height: 3px; background: #cbd5e1; border-radius: 2px; }
.desk.warn::after { background: #fca5a5; }
.room-editor .desk { cursor: grab; }
.room-editor .desk.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.4); }

/* ---------- Sekskantbord ---------- */
.hexdesk { position: absolute; user-select: none; touch-action: none; }
.hexdesk svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hexdesk .hex-num { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 11px; color: #94a3b8; }
.room-editor .hexdesk { cursor: grab; }
.seat-chip {
  position: absolute; width: 72px; height: 26px; line-height: 23px; text-align: center;
  border: 1.5px solid var(--border); border-radius: 6px; background: #fff;
  font-size: 10.5px; font-weight: 600; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; user-select: none; touch-action: none; padding: 0 3px;
}
.seat-chip.empty { border-style: dashed; background: transparent; }
.seat-chip.occupied { cursor: grab; }
.seat-chip.warn { border-color: var(--danger); background: var(--warn-bg); box-shadow: 0 0 0 2px rgba(220,38,38,.3); }
.seat-chip.drop-hover { outline: 3px solid var(--accent); outline-offset: 1px; }
.seat-chip.paint-target { cursor: crosshair; }
.room-editor .seat-chip { pointer-events: none; }
.room-editor .room-inner { cursor: crosshair; }
.selection-rect {
  position: absolute; border: 1.5px dashed var(--accent);
  background: rgba(37, 99, 235, .08); pointer-events: none; z-index: 5;
}

/* ---------- Plan editor ---------- */
.plan-layout { display: flex; gap: 16px; align-items: flex-start; }
.plan-main { flex: 1; min-width: 0; }
.plan-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.plan-toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.warn-summary { margin: 10px 0 0; font-size: 13.5px; color: var(--danger); background: var(--warn-bg); border: 1px solid #fecaca; padding: 8px 12px; border-radius: 8px; }
.warn-summary ul { margin: 4px 0 0 18px; }

#waitingPanel {
  width: 230px; flex-shrink: 0; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
}
#waitingPanel h3 { font-size: 15px; margin-bottom: 4px; }
#waitingPanel .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
#waitingArea { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 60px; border-radius: 8px; }
#waitingArea.drop-hover { outline: 3px dashed var(--accent); outline-offset: 3px; }
.stu-chip {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
  background: #f8fafc; font-size: 13.5px; font-weight: 600; cursor: grab;
  user-select: none; touch-action: none; display: flex; align-items: center; gap: 7px;
}
.stu-chip .stu-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(0,0,0,.25); }
.stu-chip .chip-sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: auto; }

.palette { display: flex; gap: 4px; align-items: center; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 2px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.swatch.active { outline: 3px solid var(--text); outline-offset: 1px; }
.swatch.none { background: repeating-linear-gradient(45deg, #fff, #fff 4px, #e2e8f0 4px, #e2e8f0 8px); }

.drag-ghost { position: fixed; z-index: 400; pointer-events: none; opacity: .85; transform: translate(-50%, -50%); box-shadow: 0 8px 24px rgba(0,0,0,.3); }

.perspective-label { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }

/* ---------- Print ---------- */
#printArea { display: none; }
@media print {
  body > #app, #toasts { display: none !important; }
  #printArea { display: block; }
  #printArea img { width: 100%; }
  @page { size: A4 landscape; margin: 8mm; }
}
