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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f5f7;
  color: #111;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Innlogging ── */

#login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
}

#login-card {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

#login-card h1 {
  font-size: 28px;
  font-weight: 800;
  color: #D64545;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 32px;
}

#login-form input {
  display: block;
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

#login-form input:focus {
  outline: none;
  border-color: #D64545;
}

#login-form button {
  width: 100%;
  background: #D64545;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}

#login-form button:hover { opacity: 0.88; }

/* ── App-layout ── */

#app-wrapper {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

#sidebar-logo {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  padding: 0 24px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

#sidebar-logo span {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #D64545;
  margin-top: 2px;
}

#sidebar ul { list-style: none; flex: 1; }

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 15px;
  padding: 12px 24px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-btn.active { background: rgba(214,69,69,0.2); color: #fff; border-left: 3px solid #D64545; }

#logout-btn {
  margin: 0 16px 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

#logout-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

#content {
  margin-left: 220px;
  padding: 40px;
  flex: 1;
  max-width: 900px;
}

#content h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── Kort ── */

.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.card-header > div { flex: 1; }

.card-tittel {
  font-size: 16px;
  font-weight: 700;
}

.card-kode {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #1a1a2e;
  font-family: monospace;
  margin-bottom: 2px;
}

.card-meta {
  font-size: 13px;
  color: #888;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-aktiv { background: #e6f9ed; color: #2e7d4f; }
.badge-inaktiv { background: #fdecea; color: #c0392b; }

/* ── Meldingskort ── */

.melding-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 12px;
}

.melding-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #888;
  margin-bottom: 10px;
}

.melding-tekst {
  font-size: 15px;
  color: #222;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ── Opprett-skjema ── */

.form-card { max-width: 480px; }

.form-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  margin-top: 16px;
}

.form-card label:first-of-type { margin-top: 0; }

.form-card input[type="text"],
.form-card input[type="file"] {
  display: block;
  width: 100%;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  transition: border-color 0.15s;
}

.form-card input[type="text"]:focus {
  outline: none;
  border-color: #D64545;
}

.form-card input[type="file"] {
  padding: 10px 14px;
  background: #fafafa;
  cursor: pointer;
}

#generert-kode-boks {
  background: #f0f4ff;
  border: 1.5px solid #c5d0ff;
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 20px;
}

.kode-label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

#generert-kode, #ny-kode-verdi {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #1a1a2e;
  font-family: monospace;
}

#opprett-btn {
  display: block;
  width: 100%;
  background: #D64545;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 24px;
  transition: opacity 0.15s;
}

#opprett-btn:hover { opacity: 0.88; }
#opprett-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Knapper ── */

.knapp-rod {
  background: #D64545;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.knapp-rod:hover { opacity: 0.88; }
.knapp-rod:disabled { opacity: 0.5; cursor: not-allowed; }

.knapp-grå {
  background: none;
  color: #888;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 11px 20px;
}

.knapp-tilbakekall {
  background: none;
  border: 1.5px solid #D64545;
  color: #D64545;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.knapp-tilbakekall:hover { background: #fdecea; }

.knapp-slett-skole {
  background: #D64545;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.knapp-slett-skole:hover { opacity: 0.82; }

/* ── Modal ── */

#modal-overlay,
#slett-skole-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

#modal-card,
#slett-skole-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}

#modal-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

#modal-tekst {
  font-size: 15px;
  color: #333;
  margin-bottom: 10px;
}

.modal-advarsel {
  font-size: 13px;
  color: #D64545;
  background: #fdecea;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

#ny-kode-boks {
  background: #e6f9ed;
  border: 1.5px solid #a8dbb8;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

#modal-knapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Tekst ── */

.error-text { color: #D64545; font-size: 13px; margin-top: 10px; min-height: 18px; }
.success-text { color: #2e7d4f; font-size: 13px; margin-top: 10px; min-height: 18px; }
.tom-liste { color: #aaa; font-size: 15px; padding: 20px 0; }

.knapp-slett {
  margin-left: auto;
  background: none;
  border: none;
  color: #ccc;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.knapp-slett:hover { color: #D64545; background: #fdecea; }

/* ── Skolekort – klikk for å vise ansatte ── */

.skole-kort {
  cursor: pointer;
  user-select: none;
}

.skole-kort .card-header { user-select: none; }

.skole-info { flex: 1; }

.chevron {
  color: #bbb;
  font-size: 14px;
  transition: color 0.15s;
}

.skole-kort:hover .chevron { color: #888; }

/* ── Ansatte-panel ── */

.ansatte-panel {
  border-top: 1px solid #f0f0f0;
  margin-top: 12px;
  padding-top: 12px;
}

.ansatte-liste {
  display: flex;
  flex-direction: column;
}

.ansatt-rad {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-radius: 8px;
  transition: background 0.1s;
}

.ansatt-rad:hover { background: #f9f9f9; }

.ansatt-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8eaff;
  color: #4a5cc7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.ansatt-info { flex: 1; }

.ansatt-navn {
  font-size: 14px;
  font-weight: 600;
  color: #111;
}

.ansatt-navn-mangler {
  font-weight: 400;
  color: #aaa;
  font-style: italic;
}

.ansatt-kode {
  font-size: 12px;
  color: #888;
  font-family: monospace;
  margin-top: 1px;
}

.admin-badge {
  display: inline-block;
  background: #ede9ff;
  color: #6d28d9;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

.knapp-admin-toggle {
  background: none;
  border: 1.5px solid #d1d5db;
  color: #555;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.knapp-admin-toggle:hover {
  border-color: #6d28d9;
  color: #6d28d9;
  background: #ede9ff;
}

.knapp-admin-toggle.er-admin {
  border-color: #c4b5fd;
  color: #6d28d9;
  background: #f5f3ff;
}

.knapp-admin-toggle.er-admin:hover {
  border-color: #D64545;
  color: #D64545;
  background: #fdecea;
}

/* ── Godkjenningssystem ── */

.ansatte-seksjon-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fff;
  background: #C9980A;
  padding: 5px 10px;
  border-radius: 6px;
  margin: 8px 0 4px;
}

.ansatte-seksjon-header-godkjent {
  background: #3A7D44;
  margin-top: 12px;
}

.ansatt-avatar-ventende {
  background: #fef3c7;
  color: #92400e;
}

.ventende-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.knapp-godkjenn {
  background: #3A7D44;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.knapp-godkjenn:hover { opacity: 0.85; }
