/* Surf admin. Systemfont, lys/mørk etter systeminnstilling, ingen rammeverk. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --field: #ffffff;
  --text: #171a1f;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #2f5bea;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
  --ok: #1d7a3e;
  --ok-bg: #e7f4ec;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --radius: 10px;
  --side: 14rem;
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --field: #0f1115;
    --text: #e8eaef;
    --muted: #98a2b3;
    --line: #2a2f3a;
    --accent: #7c9cff;
    --accent-soft: #1c2541;
    --accent-text: #0b1020;
    --shadow: none;
    --ok: #7fd49c;
    --ok-bg: #15301f;
    --err: #ff9b8f;
    --err-bg: #3a1714;
    --warn: #f3c66b;
    --warn-bg: #352812;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.app {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  height: 100vh;
  padding: 1.25rem 0.75rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.side a {
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.side a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side a[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.side .brand {
  margin-bottom: 1.25rem;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.side .brand:hover {
  background: none;
}

.side .logout {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.side .logout .btn {
  width: 100%;
}

main {
  min-width: 0;
  max-width: 80rem;
  padding: 2rem 2.5rem 4rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.crumbs {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.card {
  margin: 0 0 1.25rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  margin-bottom: -1px;
  padding: 0.6rem 0.9rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current='page'] {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

/* Tabeller */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.table th {
  padding-top: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

.table a {
  font-weight: 500;
  text-decoration: none;
}

.table a:hover {
  text-decoration: underline;
}

.table tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.actions-cell {
  width: 1%;
  white-space: nowrap;
}

.table.log tr.test td {
  color: var(--muted);
}

/* Skjema */

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 500;
}

/* Rutenett, så lang tekst brytes ved siden av boksen og ikke under den. */
label.inline {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0.2rem 0.55rem;
  font-weight: 400;
}

label small,
.label small {
  display: block;
  color: var(--muted);
  font-weight: 400;
}

label.inline small {
  grid-column: 2;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  box-shadow: var(--shadow);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--muted);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type='checkbox'],
input[type='radio'] {
  width: auto;
  accent-color: var(--accent);
}

input[type='color'] {
  width: 3rem;
  height: 2.25rem;
  padding: 0.15rem;
}

input[readonly] {
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
  color: var(--muted);
}

textarea {
  resize: vertical;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 0.3rem;
  padding: 0;
  font-weight: 500;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem 1.5rem;
}

.grid-form .actions {
  grid-column: 1 / -1;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.grow {
  flex: 1;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 0;
  background: linear-gradient(transparent, var(--bg) 40%);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--muted);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.danger {
  border-color: var(--err);
  color: var(--err);
}

.btn.small {
  min-height: 1.85rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.icon:hover {
  background: var(--surface-2);
}

/* Meldinger og merker */

.flash {
  margin: 0 0 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 6px;
}

.flash.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.flash.err {
  background: var(--err-bg);
  color: var(--err);
}

.flash.warn {
  margin: 0;
  background: var(--warn-bg);
  color: var(--warn);
}

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.badge.active {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.inactive {
  background: var(--err-bg);
  color: var(--err);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Dialog */

dialog {
  width: min(42rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.dialog-head h2 {
  margin: 0;
}

dialog > form.actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  justify-content: flex-start;
}

/* Tekster: etikett + nb + en */

.texts {
  display: grid;
  grid-template-columns: minmax(10rem, 14rem) 1fr 1fr;
  gap: 0.6rem 1rem;
  align-items: start;
}

.texts .lang-head {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.texts .label {
  padding-top: 0.5rem;
  font-weight: 500;
}

/* Utseende */

.split {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) 2fr;
  gap: 1rem;
  align-items: start;
}

.colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}

.colors label {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.preview iframe {
  display: block;
  width: 100%;
  height: 34rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.preview header {
  margin-bottom: 0.75rem;
}

.preview header h2 {
  margin: 0;
}

/* Publisering */

.changes {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.changes li {
  margin: 0.2rem 0;
}

/* Installasjon */

.steps {
  margin: 0;
  padding-left: 1.2rem;
}

.steps li {
  margin: 0.5rem 0;
}

.copy {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.copy.block {
  align-items: flex-start;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy pre {
  flex: 1;
}

.snippet-options {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.snippet-options label:not(.inline) {
  min-width: 10rem;
}

.snippet-options label.inline {
  padding-bottom: 0.5rem;
}

/* Logg */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.filters label:not(.inline) {
  min-width: 10rem;
}

.filters label.inline {
  padding-bottom: 0.5rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats > div {
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats .n {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats .l {
  color: var(--muted);
  font-size: 0.85rem;
}

.choices {
  display: inline-flex;
  gap: 0.2rem;
}

.choices span {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.choices .on {
  background: var(--ok-bg);
  color: var(--ok);
}

.choices .off {
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: line-through;
}

.pager {
  margin: 1rem 0 0;
  text-align: right;
}

/* Forhåndsvisningssiden (inne i iframen) */

.preview-page {
  margin: 0;
  background: #f1f1ef;
  color-scheme: light;
}

.fake-page {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem;
}

.fake-page > div {
  margin-bottom: 1rem;
  border-radius: 6px;
  background: #deded9;
}

.fake-bar {
  height: 2.5rem;
}

.fake-hero {
  height: 12rem;
}

.fake-line {
  height: 1rem;
}

.fake-line.short {
  width: 60%;
}

.preview-error {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
}

@media (max-width: 60rem) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    flex-direction: row;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side .brand {
    margin: 0 1rem 0 0;
  }

  .side .logout {
    margin: 0 0 0 auto;
  }

  main {
    padding: 1rem;
  }

  .split,
  .texts,
  .cols {
    grid-template-columns: 1fr;
  }
}

/* Velger for tjenestebiblioteket */

.picker {
  gap: 0.35rem;
}

.picker legend {
  margin-bottom: 0.4rem;
}

.picker label.inline {
  align-items: start;
}

.picker input[type='checkbox'] {
  margin-top: 0.25rem;
}

.danger-zone {
  border-color: var(--err);
}

.danger-zone h2 {
  color: var(--err);
}

/* Innlogging */

.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  max-width: none;
  min-height: 100vh;
  padding: 1rem;
}

.login-brand {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login form {
  width: min(100%, 24rem);
  padding: 2rem;
  gap: 1.1rem;
}

.login h1 {
  font-size: 1.25rem;
}

.login-submit {
  width: 100%;
  min-height: 2.5rem;
  margin-top: 0.25rem;
}
