:root {
  --nav: #1c1a3a;
  --nav-2: #2a2752;
  --bg: #f4f4f7;
  --panel: #ffffff;
  --ink: #1d1e24;
  --muted: #6b6d80;
  --line: #e4e4ec;
  --primary: #673de6;
  --primary-dark: #5025d1;
  --primary-soft: #efeafe;
  --ok: #00a88a;
  --ok-soft: #dcf5ef;
  --warn: #d98a00;
  --warn-soft: #fff2d9;
  --danger: #e0346b;
  --danger-soft: #fde6ee;
  --info: #3764e0;
  --info-soft: #e5ecfd;
  --spectrum: linear-gradient(90deg, #8c6bff 0%, #e04bbf 55%, #ff9a4d 100%);
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28, 26, 58, .04), 0 6px 24px rgba(28, 26, 58, .05);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.55 "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--primary); }
img { max-width: 100%; display: block; }
h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .6rem; }
code { background: var(--primary-soft); color: var(--primary-dark); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
.icon { flex-shrink: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: .25rem 0; }
.lead { color: var(--muted); margin-top: -.25rem; }
.right { text-align: right; }

/* ---------- Toppmeny ---------- */
.topbar { background: var(--nav); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; padding: 0 20px; max-width: 1180px; margin: 0 auto; }
body.admin .topbar-inner { max-width: none; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.topbar-right { display: flex; gap: 10px; }
.topbar-pill {
  display: inline-flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-size: .9rem; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25);
}
.topbar-pill:hover { border-color: #b9a4ff; background: rgba(255, 255, 255, .06); }
.spectrum { height: 3px; background: var(--spectrum); }

/* ---------- Oppsett ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px; }
.footer { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; padding-top: 0; }
.adminlink { color: var(--muted); text-decoration: none; }
.adminlink:hover { color: var(--primary); }

.shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 65px); }
.sidebar { background: #fbfbfd; border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 65px; height: calc(100vh - 65px); overflow-y: auto; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a, .sidebar-logout {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none;
  font-weight: 500; font-size: .95rem; background: none; border: 0; width: 100%; cursor: pointer; font-family: inherit;
}
.sidebar nav a:hover, .sidebar-logout:hover { background: #f0eff6; }
.sidebar-logout { justify-content: flex-start; color: var(--muted); }
.sidebar nav a.active { background: #fff; box-shadow: var(--shadow); font-weight: 700; }
.sidebar nav a.active .icon { color: var(--primary); }
.sidebar .count { margin-left: auto; }
.sidebar-heading { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 12px 6px; }
.sidebar-bottom { margin-top: auto; }
.content { padding: 32px 36px 60px; max-width: 1100px; width: 100%; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar-heading { display: none; }
  .sidebar-bottom { margin: 0; }
  .sidebar nav a span:not(.count), .sidebar-logout span { font-size: .85rem; }
  .content { padding: 20px 16px 40px; }
}

/* ---------- Kort ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; margin: 0 0 20px; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 16px; }
.card-title .icon { color: var(--primary); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.narrow-card { max-width: 760px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.login-card { max-width: 400px; margin: 40px auto; }
.list-card { padding: 22px 0 8px; }
.list-card .card-title, .list-card .empty { padding: 0 26px; }
.stack { display: grid; gap: 0; }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700;
}
.empty { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 0 0 14px; }
.empty .icon { color: var(--ok); }

.pagehead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 0 0 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }
.crumbs span { margin: 0 6px; opacity: .6; }
.greeting { font-size: 2rem; margin-bottom: 20px; }

/* ---------- Forside ---------- */
.hero { text-align: center; padding: 28px 0 34px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 600; }
.hero-text { max-width: 640px; margin: 0 auto 22px; color: var(--muted); font-size: 1.05rem; }
.hero-text p { margin: 0; }
.promptbar {
  display: flex; align-items: center; gap: 12px; max-width: 680px; margin: 0 auto; padding: 8px 8px 8px 20px;
  background: #fff; border-radius: 999px; box-shadow: 0 4px 24px rgba(28, 26, 58, .10); border: 1px solid var(--line); text-align: left;
}
.promptbar-icon { color: var(--primary); display: flex; }
.promptbar-label { color: var(--muted); flex: 1; }
.promptbar-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; font-weight: 600; font-size: .88rem; white-space: nowrap; }
.chip:hover { background: var(--primary); color: #fff; }
.round-button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; flex-shrink: 0; }
.round-button:hover { background: var(--primary-dark); }
@media (max-width: 620px) {
  .promptbar { border-radius: var(--radius); flex-wrap: wrap; padding: 14px; }
  .promptbar-label { flex-basis: calc(100% - 40px); }
  .round-button { display: none; }
}

.steplist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steplist li { display: flex; gap: 14px; background: #f8f7fc; border-radius: 14px; padding: 16px; }
.steplist p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.stepnum { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--primary); font-weight: 700; flex-shrink: 0; }
@media (max-width: 760px) { .steplist { grid-template-columns: 1fr; } }

.rows { display: grid; }
.rows-head, .row { display: grid; grid-template-columns: 2.4fr 1fr 1fr auto; gap: 16px; align-items: center; padding: 0 26px; }
.rows-head { font-size: .85rem; font-weight: 600; color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.row { padding-top: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #faf9fe; }
.row.static:hover { background: none; }
.row:hover .button.outline { background: var(--primary); color: #fff; border-color: var(--primary); }
.row-main { display: flex; align-items: center; gap: 16px; }
.row-main strong { display: block; font-size: 1.05rem; }
.row-main small, .row-price small { color: var(--muted); font-size: .85rem; font-weight: 400; }
.row-price { font-weight: 700; }
.thumb { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: #f0eff6; border: 1px solid var(--line); flex-shrink: 0; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); }
@media (max-width: 760px) {
  .rows-head { display: none; }
  .row { grid-template-columns: 1fr auto; gap: 10px; }
  .row-main { grid-column: 1 / -1; }
  .row-action { grid-column: 1 / -1; }
}

/* ---------- Anleggsside ---------- */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } }
.gallery { display: grid; gap: 10px; margin-bottom: 16px; }
.gallery a.zoom { cursor: zoom-in; display: block; border-radius: 14px; overflow: hidden; background: #f0eff6; }
.gallery img { width: 100%; max-height: 460px; object-fit: contain; transition: transform .2s; }
.gallery a.zoom:hover img { transform: scale(1.015); }
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--primary-soft); color: var(--primary-dark); border-radius: 12px; padding: 12px 14px; margin: 16px 0; }
.note .icon { margin-top: 3px; }
.note p { margin: 0; }

dialog#lightbox { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 96vh; overflow: visible; cursor: zoom-out; }
dialog#lightbox::backdrop { background: rgba(20, 18, 42, .88); }
dialog#lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 10px; display: block; }
.lightbox-close {
  position: absolute; top: -14px; right: -14px; width: 38px; height: 38px; border-radius: 50%; padding: 0; font-size: 1.4rem;
  line-height: 38px; background: #fff; color: var(--ink); box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.lightbox-close:hover { background: #fff; color: var(--primary); }

.calnav { display: flex; gap: 6px; }
.iconbutton { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 1.3rem; line-height: 1; }
.iconbutton:hover { border-color: var(--primary); color: var(--primary); }
.calendars { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .calendars { grid-template-columns: 1fr; } }
.calendar { width: 100%; border-collapse: separate; border-spacing: 3px; }
.calendar caption { font-weight: 700; padding: 0 0 6px 3px; text-align: left; }
.calendar th { font-size: .72rem; color: var(--muted); font-weight: 600; padding-bottom: 2px; }
.calendar td { text-align: center; padding: 6px 0; border-radius: 8px; font-size: .88rem; }
.calendar td.free { background: var(--ok-soft); color: #0b6e5b; cursor: pointer; font-weight: 600; }
.calendar td.free:hover { outline: 2px solid var(--ok); }
.calendar td.busy { background: var(--danger-soft); color: #a3264f; text-decoration: line-through; }
.calendar td.past { color: #bdbccb; }
.calendar td.selected { background: var(--primary); color: #fff; }
.calendar td.free.addon-busy:not(.selected) { background: var(--warn-soft); color: #8a5a00; box-shadow: inset 0 -3px 0 #f2b640; }
.dot.addon-busy { background: var(--warn-soft); border: 1px solid #f2b640; }

.addon { display: flex; gap: 14px; align-items: flex-start; background: #f8f7fc; border-radius: 14px; padding: 12px; }
.addon-img { width: 72px; height: 72px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: #fff; border: 1px solid var(--line); cursor: zoom-in; }
.addon-img img { width: 100%; height: 100%; object-fit: cover; }
.addon-img-empty { display: grid; place-items: center; color: var(--primary); cursor: default; }
.form label.addon-check { background: none; padding: 0; flex: 1; }
.addon-desc { display: block; color: var(--muted); font-size: .88rem; margin-top: 4px; }
.addon-desc p { margin: 0; }
.addon-note { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; }
.addon-warning { display: block; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: #8a5a00; font-weight: 600; font-size: .88rem; }
.addon-warning[hidden] { display: none; }
.legend { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 10px 0 0; flex-wrap: wrap; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-left: 8px; }
.dot:first-child { margin-left: 0; }
.dot.free { background: var(--ok-soft); border: 1px solid var(--ok); }
.dot.busy { background: var(--danger-soft); border: 1px solid var(--danger); }
.dot.selected { background: var(--primary); }

/* ---------- Merker ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; padding: 4px 10px 4px 8px;
  border-radius: 99px; background: #efeff4; color: var(--muted); white-space: nowrap;
}
.badge.ok, .badge.confirmed { background: var(--ok-soft); color: #0b6e5b; }
.badge.ok .icon { color: var(--ok); }
.badge.busy .icon { color: var(--warn); }
.badge.busy, .badge.pending { background: var(--warn-soft); color: #8a5a00; }
.badge.approved { background: var(--info-soft); color: #23419a; }
.badge.approved .icon { color: var(--info); }
.badge.declined, .badge.expired, .badge.cancelled { background: #efeff4; color: var(--muted); }
.badge.price { background: var(--primary-soft); color: var(--primary-dark); font-size: .95rem; padding: 6px 14px; }
.badge.pending::before, .badge.confirmed::before, .badge.declined::before, .badge.expired::before, .badge.cancelled::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8;
}

/* ---------- Oppgaver ---------- */
.todos { display: grid; gap: 10px; }
.todo { display: flex; align-items: center; gap: 14px; background: #f8f7fc; border-radius: 14px; padding: 14px 16px; }
.todo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.todo-icon { display: grid; place-items: center; width: 44px; height: 44px; background: #fff; border-radius: 12px; border: 1px solid var(--line); color: var(--primary); flex-shrink: 0; }
.todo-body { flex: 1; min-width: 0; }
.todo-body p { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
@media (max-width: 620px) { .todo { flex-wrap: wrap; } .todo-dot { display: none; } }

/* ---------- Tabeller ---------- */
.tablewrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th:first-child, table.list td:first-child { padding-left: 26px; }
table.list th:last-child, table.list td:last-child { padding-right: 26px; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #faf9fe; }
table.list th { font-size: .85rem; color: var(--muted); font-weight: 600; border-top: 1px solid var(--line); }
table.list form { margin: 0; }

/* ---------- Skjema ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
input, textarea, select {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #d6d5e0; border-radius: var(--radius-sm); background: #fff; color: var(--ink); width: 100%;
}
input:hover, textarea:hover, select:hover { border-color: #b9b7cc; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; line-height: 1.5; }
.form label.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; background: #f8f7fc; padding: 14px; border-radius: 12px; }
.form label.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); flex-shrink: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.upload { margin-top: 18px; grid-template-columns: 1fr auto; align-items: end; }
@media (max-width: 560px) { .upload { grid-template-columns: 1fr; } }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: .95rem;
  background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 10px 18px; cursor: pointer; text-decoration: none; justify-self: start; white-space: nowrap;
}
button:hover, .button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.outline, button.outline { background: #fff; color: var(--primary); border-color: #cfc3f7; }
.button.outline:hover, button.outline:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
button.danger { background: #fff; color: var(--danger); border-color: #f4bccd; }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.small { padding: 6px 12px; font-size: .85rem; }
.actions { display: flex; gap: 10px; margin: 18px 0 6px; flex-wrap: wrap; }
.actions form { margin: 0; }

.alert { padding: 12px 16px; border-radius: 12px; font-weight: 500; }
.alert.error { background: var(--danger-soft); color: #a3264f; }
.alert.ok { background: var(--ok-soft); color: #0b6e5b; }

/* ---------- Innhold ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 16px 0; padding: 16px 18px; background: #f8f7fc; border-radius: 14px; }
.facts:empty { display: none; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; gap: 2px; } .facts dd { margin-bottom: 8px; } }
.contract { border: 1px solid var(--line); border-radius: 14px; padding: 6px 22px 10px; margin: 18px 0; max-height: 460px; overflow-y: auto; background: #fff; }
.contract h2 { font-size: 1.15rem; }
.contract h3 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .15rem 0; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 8px; }
.thumbs figure { margin: 0; display: grid; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; }
.thumbs figure.is-main { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.thumbs img { border-radius: 10px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.imgactions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.imgactions form { margin: 0; }
details { margin-top: 18px; }
summary { cursor: pointer; font-weight: 600; color: var(--primary); }

.mails { display: grid; gap: 10px; margin-top: 14px; }
details.mail { margin: 0; border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; background: #fcfcfe; }
details.mail[open] { background: #fff; box-shadow: var(--shadow); padding-bottom: 16px; }
details.mail summary { display: flex; align-items: center; gap: 10px; padding: 14px 0; color: var(--ink); list-style: none; }
details.mail summary::-webkit-details-marker { display: none; }
details.mail summary::after { content: "›"; margin-left: auto; font-size: 1.3rem; color: var(--muted); transition: transform .15s; }
details.mail[open] summary::after { transform: rotate(90deg); }
.fields { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--muted); }
.field.required { color: var(--ink); font-weight: 700; }
