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

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

:root {
  --green:   #16a34a;
  --green-bg: #f0fdf4;
  --yellow:  #ca8a04;
  --yellow-bg: #fefce8;
  --gray:    #6b7280;
  --gray-bg: #f9fafb;
  --border:  #e5e7eb;
  --text:    #111827;
  --text-muted: #6b7280;
  --radius:  8px;
  --shadow:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: #f3f4f6;
  min-height: 100vh;
}

/* ── Layout ── */
.page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.page-header h1 { font-size: 1.25rem; font-weight: 700; }
.page-header .meta { font-size: .875rem; color: var(--text-muted); margin-top: 2px; }

main { max-width: 800px; margin: 0 auto; padding: 24px 16px 60px; }

section { margin-bottom: 32px; }
section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: .01em;
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card .number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .label  { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.green   { border-top: 3px solid var(--green); }
.stat-card.yellow  { border-top: 3px solid var(--yellow); }
.stat-card.gray    { border-top: 3px solid var(--gray); }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray); }

.tag {
  display: inline-block;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--text-muted);
  margin-right: 4px;
}

/* ── Besøk card ── */
.besok-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.besok-dato { font-weight: 600; font-size: .95rem; }
.besok-av   { font-size: .8rem; color: var(--text-muted); }
.besok-tags { margin: 8px 0; }
.besok-desc { font-size: .9rem; color: #374151; }

.thumbnails { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumbnails img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity .15s;
}
.thumbnails img:hover { opacity: .85; }

/* ── Avvik card ── */
.avvik-card {
  border-left: 4px solid var(--yellow);
}
.avvik-card.lukket {
  border-left-color: var(--green);
  opacity: .7;
}
.avvik-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.avvik-tittel { font-weight: 600; font-size: .95rem; }
.avvik-meta   { font-size: .8rem; color: var(--text-muted); margin-bottom: 6px; }
.avvik-desc   { font-size: .9rem; color: #374151; }

/* ── Lightbox ── */
#lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img  { max-width: 95vw; max-height: 90vh; border-radius: 4px; }

/* ── Footer ── */
footer {
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* ── Admin ── */
.admin-header {
  background: #111827;
  color: #fff;
  padding: 20px 24px;
}
.admin-header h1 { font-size: 1.25rem; font-weight: 700; }
.admin-header .meta { font-size: .875rem; color: #9ca3af; margin-top: 2px; }

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: #fff;
  overflow-x: auto;
}
.tab-btn {
  padding: 12px 20px;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  font-size: .9rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s;
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: #111827;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 6px;
}
input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: #374151;
}
textarea { resize: vertical; min-height: 100px; }

.checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.checkbox-item  { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-item input[type="checkbox"] {
  width: 20px; height: 20px; cursor: pointer; flex-shrink: 0;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-align: center;
}
.btn-primary   { background: #111827; color: #fff; width: 100%; }
.btn-primary:hover   { background: #1f2937; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover   { opacity: .9; }
.btn-sm { padding: 6px 12px; font-size: .85rem; font-weight: 500; }

.confirm-msg {
  display: none;
  background: var(--green-bg);
  border: 1px solid #bbf7d0;
  color: var(--green);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  margin-top: 16px;
  text-align: center;
}
.confirm-msg.show { display: block; }

/* ── Avvik list in admin ── */
.avvik-admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--yellow);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.avvik-admin-item.lukket { border-left-color: var(--green); opacity: .65; }
.avvik-admin-info { flex: 1; }
.avvik-admin-tittel { font-weight: 600; font-size: .9rem; }
.avvik-admin-meta   { font-size: .8rem; color: var(--text-muted); }

/* ── Mobile tweaks ── */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .number { font-size: 1.6rem; }
  main { padding: 16px 12px 60px; }
}
