:root {
  --bg: #0F1620;
  --surface: #1B2530;
  --surface-alt: #232F3C;
  --border: #2A3540;
  --text: #EDEFF2;
  --text-muted: #8B97A5;
  --accent: #E8A33D;
  --accent-text: #1A1200;
  --danger: #D1554A;
  --success: #4C9A6A;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

.hidden { display: none !important; }

/* Filinnputt for kamera/bilde skal IKKE bruke display:none - på iPhone kan det gjøre at
   nettleseren "mister" bildet når kameraet lukkes og skal levere det tilbake til siden.
   Mobile nettlesere respekterer heller ikke alltid width/height-krymping av <input type="file">
   (de insisterer på å vise knappen i naturlig størrelse) - derfor flyttes feltet helt utenfor
   synlig område i stedet for å prøve å gjøre det mikroskopisk på stedet. */
.visually-hidden-file {
  position: fixed;
  top: -1000px;
  left: -1000px;
}

.photo-thumb-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.photo-thumb-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.photo-thumb-preview .file-chip { align-self: flex-start; }

/* ---------- Login ---------- */
#screen-login {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px calc(32px + var(--safe-bottom));
}

.login-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 20px;
}

#screen-login h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

#screen-login p.sub-title {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 10px;
}

#screen-login p.sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 14px;
}

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

.field input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 8px;
}

.btn-primary:active { opacity: 0.85; }

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-secondary {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

#login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
}

/* ---------- App shell ---------- */
#screen-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

header.app-header {
  padding: calc(14px + var(--safe-top)) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

header.app-header h2 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.offline::before { background: var(--danger); }

/* Push permission banner */
#push-banner {
  margin: 12px 18px 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#push-banner button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

main.tab-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 24px;
}

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

.list-heading {
  padding: 18px 18px 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: none;
}

ul.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-row.sev-hoy { border-left-color: var(--danger); }
.item-row.sev-middels { border-left-color: var(--accent); }
.item-row.sev-lav { border-left-color: var(--success); }

.item-row .row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.item-row .kategori {
  font-weight: 600;
  font-size: 15px;
}

.item-row .tid {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.item-row .beskrivelse {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}

.item-row .thumb {
  margin-top: 6px;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge.status-apen { background: rgba(209,85,74,0.15); color: var(--danger); }
.badge.status-under { background: rgba(232,163,61,0.15); color: var(--accent); }
.badge.status-lukket { background: rgba(76,154,106,0.15); color: var(--success); }

.empty-state {
  padding: 60px 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Oppgaver */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
}

.task-check.done {
  background: var(--success);
  border-color: var(--success);
  color: #0B1A11;
  font-weight: 900;
  font-size: 13px;
}

.task-body { flex: 1; }
.task-title { font-size: 15px; font-weight: 600; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Floating action button */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(84px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  z-index: 6;
}

/* Bottom tab bar */
nav.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding-bottom: var(--safe-bottom);
  position: sticky;
  bottom: 0;
}

nav.tab-bar button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 0 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

nav.tab-bar button .dot {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid currentColor;
}

nav.tab-bar button.active {
  color: var(--accent);
}

/* ---------- Sheet (new hendelse) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20;
  display: flex;
  align-items: flex-end;
}

.sheet {
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 18px calc(24px + var(--safe-bottom));
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 16px;
}

.sheet h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.field select {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
}

.field textarea {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.photo-input-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.sheet-actions .btn-secondary { width: auto; flex: 1; }
.sheet-actions .btn-primary { width: auto; flex: 2; }

.toast {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(90px + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  z-index: 30;
}

/* ---------- Lagt til for reell datamodell (arrangement, kommentarer, kontakter) ---------- */
.event-name-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 14px;
}
.check-grid label { display: flex; align-items: center; gap: 6px; color: var(--text); }
.check-grid input[type="checkbox"],
.check-grid input[type="radio"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
  margin: 0;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.meta-text { font-size: 12px; color: var(--text-muted); }

.attachments-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.file-chip {
  font-size: 12px;
  color: var(--accent);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.comment-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comment-item {
  font-size: 13px;
  color: var(--text);
  margin-left: 16px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}
.comment-who { display: block; font-size: 11px; color: var(--text-muted); }

.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.inline-form .comment-input {
  flex: 1;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.btn-small {
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-close-case { margin-top: 8px; width: 100%; }

.contact-row {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}
.contact-row a { color: var(--accent); text-decoration: none; }

.divider-row {
  padding: 14px 18px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.file-preview-text {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

#screen-event-picker {
  flex: 1;
  display: none;
}
#screen-event-picker:not(.hidden) { display: flex; flex-direction: column; }

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

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn:active { opacity: 0.8; }

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--chip-color, var(--border));
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}
.color-chip input {
  accent-color: var(--chip-color, var(--accent));
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex-shrink: 0;
  margin: 0;
}

.swatch-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.color-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.color-swatch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.swatch-dot {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--chip-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  border: 2px solid transparent;
  transition: border-color 0.1s ease;
}
.color-swatch input:checked + .swatch-dot {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--chip-color);
}
.swatch-label {
  font-size: 10px;
  color: var(--text-muted);
}

.badge-color {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* ---------- Legg til som app-guide ---------- */
.install-guide {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.install-guide-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
}
.install-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.install-tab-btn {
  flex: 1;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}
.install-tab-btn.active {
  background: var(--accent);
  color: #06131f;
  border-color: var(--accent);
}
.install-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.install-steps li { margin-bottom: 4px; }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5595e;
}
.notif-item {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.notif-item.unread { border-left: 3px solid var(--accent); padding-left: 10px; }
.notif-item .notif-title { font-weight: 700; font-size: 14px; }
.notif-item .notif-body { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.notif-item .notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
