:root {
  --pride: #673c94;
  --deep: #4a2a6b;
  --powder: #e8d9fa;
  --mist: #f6f1fc;
  --karton: #fbf3dc;
  --white: #fff;
  --dark: #252525;
  --line: #673c94;
  --grey: #5c5c5c;
  --err: #a12a2a;
  --ok: #1d6b2e;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--dark);
  background: var(--karton);
}

a { color: var(--pride); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  background: var(--deep);
  color: var(--white);
}

.bar a, .bar .link, .bar .who { color: var(--white); }
.bar .brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.bar nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.bar nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.bar .who { color: var(--powder); }

main { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

h1 { color: var(--pride); margin: 0 0 1rem; line-height: 1.2; }
h2 { color: var(--pride); margin: 0 0 0.75rem; font-size: 1.25rem; }

.card {
  background: var(--white);
  border: 2px solid var(--pride);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.narrow { max-width: 26rem; margin: 3rem auto; }

label { display: block; margin: 0 0 0.9rem; font-weight: 600; }
label.check { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0 1rem 0.3rem 0; font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  border: 1px solid #8a7a9c;
  border-radius: 8px;
  background: var(--white);
}

:focus-visible { outline: 3px solid var(--pride); outline-offset: 2px; }

button, .btn {
  font: inherit;
  padding: 0.55rem 1rem;
  border: 2px solid var(--pride);
  border-radius: 999px;
  background: var(--white);
  color: var(--pride);
  cursor: pointer;
  font-weight: 600;
}

button.primary { background: var(--pride); color: var(--white); }
button.danger { border-color: var(--err); color: var(--err); }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; font-weight: 400; }
form.inline { display: inline; }

.error { color: var(--err); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.hint { color: var(--grey); font-size: 0.9rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.tile {
  display: grid;
  gap: 0.4rem;
  padding: 1.25rem 1.4rem;
  background: var(--powder);
  border: 2px solid rgba(103, 60, 148, 0.25);
  border-radius: 14px;
  text-decoration: none;
  color: var(--dark);
}
.tile:hover { border-color: var(--pride); }
.tile strong { color: var(--pride); font-size: 1.15rem; }

.row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.row label { flex: 1 1 14rem; margin: 0; }
.linkbox { font-family: monospace; }

/* ---- økonomi ---- */
.fincards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 28rem), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.fincard .finrow { flex-wrap: nowrap; }
@media (max-width: 520px) { .fincard .finrow { flex-wrap: wrap; } }
.fincard { background: var(--white); border: 2px solid var(--pride); border-radius: 14px; padding: 1rem 1.25rem 1.1rem; }
.fincard h2 { font-size: 1.1rem; margin-bottom: 0.6rem; }
.fincard h2 a { color: var(--pride); }
.finbar { display: flex; height: 1.6rem; border-radius: 999px; overflow: hidden; background: #e4ded9; margin: 0 0 0.35rem; }
.finbar span { display: grid; place-items: center; color: var(--white); font-size: 0.8rem; font-weight: 700; min-width: 0; }
.finbar .used { background: #b83a3a; }
.finbar .unused { background: #2a7d5a; }
.barkey { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; font-size: 0.85rem; color: var(--grey); margin: 0 0 0.9rem; }
.barkey .k { width: 0.8rem; height: 0.8rem; border-radius: 3px; display: inline-block; }
.barkey .k.used { background: #b83a3a; }
.barkey .k.unused { background: #2a7d5a; margin-left: 0.6rem; }
.finrow { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.pie { flex: 0 0 auto; }
.big { display: grid; gap: 0.1rem; min-width: 8rem; }
.big .cap { font-size: 0.85rem; color: var(--grey); }
.big .num { font-size: 1.8rem; font-weight: 700; color: var(--pride); line-height: 1.15; }
.big .num.neg, .neg { color: var(--err); }
.big .sub { font-size: 0.85rem; color: var(--grey); }
.legend { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.25rem; font-size: 0.9rem; }
.legend li { display: grid; grid-template-columns: 0.9rem 1fr auto; gap: 0.5rem; align-items: center; }
.legend .sw { width: 0.9rem; height: 0.9rem; border-radius: 3px; display: inline-block; }
.legend .val { font-variant-numeric: tabular-nums; }
.small { font-size: 0.9rem; margin: 0.5rem 0 0; }
.yearpick { margin: 0; }
.yearpick label { margin: 0; display: inline-flex; align-items: center; gap: 0.5rem; }
.yearpick select { width: auto; margin: 0; }
.fintable { width: 100%; border-collapse: collapse; margin: 0 0 1rem; }
.fintable th, .fintable td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--powder); text-align: left; vertical-align: middle; }
.fintable .r { text-align: right; font-variant-numeric: tabular-nums; }
.fintable .acts { white-space: nowrap; }
.fintable input { margin: 0; }
.fintable input.amt { text-align: right; max-width: 9rem; margin-left: auto; }
.user { display: grid; grid-template-columns: 1fr 2fr auto; gap: 1rem; align-items: center; padding: 0.9rem 0; border-top: 1px solid var(--powder); }
.user .who { display: grid; }
.user .acts { display: grid; gap: 0.4rem; }
@media (max-width: 760px) { .user { grid-template-columns: 1fr; } }

/* ---- org chart ---- */
.tool-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.sync { font-size: 0.9rem; font-weight: 600; }
.sync.ok { color: var(--ok); }
.sync.bad { color: var(--err); }

.levels { background: var(--white); border: 2px solid var(--pride); border-radius: 14px; padding: 1.5rem 1rem 2rem; margin-bottom: 2rem; overflow-x: auto; }
.resth { margin: 0 0 1rem; }
.results { list-style: none; margin: 0.25rem 0 0.5rem; padding: 0; border: 1px solid #8a7a9c; border-radius: 8px; max-height: 13rem; overflow: auto; background: var(--white); }
.results li { margin: 0; }
.results .res { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; font-weight: 400; color: var(--dark); background: transparent; padding: 0.45rem 0.7rem; }
.results .res:hover, .results .res:focus-visible { background: var(--mist); }
.results .more { padding: 0.35rem 0.7rem; }
.chosen { margin: 0 0 0.75rem; }
.orgtabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.orgtab { border-radius: 999px; padding: 0.45rem 1.1rem; }
.orgtab.on { background: var(--pride); color: var(--white); }
.lvl { list-style: none; margin: 0; padding: 0; display: flex; justify-content: safe center; position: relative; }
.levels { display: grid; }
.levels > .lvl:not(.l4) { width: max-content; min-width: 100%; }
.lvl:not(.l1) { padding-top: 24px; }
.lvl:not(.l1)::before { content: ""; position: absolute; top: 0; left: 50%; height: 24px; border-left: 2px solid var(--line); }
.lvl > li { position: relative; margin: 0; padding: 24px 6px 0; list-style: none; text-align: center; }
.lvl.l1 > li { padding-top: 0; }
.lvl:not(.l1):not(.l4) > li::before, .lvl:not(.l1):not(.l4) > li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 24px; border-top: 2px solid var(--line); }
.lvl:not(.l1):not(.l4) > li::after { right: auto; left: 50%; border-left: 2px solid var(--line); }
.lvl:not(.l1):not(.l4) > li:first-child::before, .lvl:not(.l1):not(.l4) > li:last-child::after { border: 0 none; }
.lvl:not(.l1):not(.l4) > li:last-child::before { border-right: 2px solid var(--line); }
.lvl:not(.l1):not(.l4) > li:only-child::before, .lvl:not(.l1):not(.l4) > li:only-child::after { display: none; }
.lvl.l4 { display: block; max-width: 84rem; margin: 0 auto; }
.lvl.l4 .box { border: 2px solid var(--powder); background: var(--mist); border-radius: 14px; padding: 0.6rem 0.75rem 1.25rem; }
.lvl.l4 .boxlabel { margin: 0; font-weight: 700; color: var(--pride); }
.lvl.l4 .cells { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 10px; }
.lvl.l4 .cell { flex: 0 0 auto; }
.node {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  width: 10.5rem;
  min-height: 6rem;
  margin: 30px auto 0;
  padding: 36px 0.5rem 0.7rem;
  background: var(--white);
  border: 2px solid var(--pride);
  border-radius: 12px;
  color: var(--dark);
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
}
.node:hover { background: var(--mist); }
.node .av {
  position: absolute;
  top: -28px;
  left: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--powder);
  color: var(--deep);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
  box-shadow: 0 0 0 2px var(--pride);
}
.node .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.node .title { font-size: 0.8rem; color: var(--grey); hyphens: auto; }
.node .name { font-weight: 700; color: var(--pride); font-size: 0.95rem; }
.node .contact { font-size: 0.8rem; overflow-wrap: anywhere; }
.node.vacant { border-style: dashed; }
.node.vacant .name { color: var(--grey); font-style: italic; font-weight: 400; }
.node.hidden-web .name::after { content: " (skjult)"; color: var(--grey); font-size: 0.7rem; font-weight: 400; }
.node.auto { background: var(--powder); }
.node.entity { margin-top: 2px; min-height: 3.5rem; padding-top: 0.7rem; align-content: center; background: var(--mist); }
.node.entity .name { font-size: 0.9rem; hyphens: auto; }
.lvl.l5 > li { padding-top: 0; }
.node.add { min-height: 3rem; border-style: dashed; color: var(--pride); font-weight: 600; background: transparent; padding-top: 0.7rem; align-content: center; }
.unit { margin-bottom: 1.75rem; }
.unit h3 { margin: 0 0 0.6rem; color: var(--pride); font-size: 1.15rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.75rem; }

.pcard {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 5rem;
  padding: 0.75rem 0.9rem;
  background: var(--white);
  border: 2px solid var(--pride);
  border-radius: 12px;
  color: var(--dark);
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
}
.pcard:hover { background: var(--mist); }
.pcard .av {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--powder);
  color: var(--deep);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}
.pcard .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .info { display: grid; min-width: 0; }
.pcard .title { font-size: 0.85rem; color: var(--grey); }
.pcard .name { font-weight: 700; color: var(--pride); }
.pcard .contact { font-size: 0.875rem; overflow-wrap: anywhere; }
.pcard.vacant { border-style: dashed; }
.pcard.vacant .name { color: var(--grey); font-style: italic; font-weight: 400; }
.pcard.hidden-web .name::after { content: " (skjult)"; color: var(--grey); font-size: 0.75rem; font-weight: 400; }
.pcard.add { justify-content: center; border-style: dashed; color: var(--pride); font-weight: 600; background: transparent; }

dialog {
  width: min(44rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 2px solid var(--pride);
  border-radius: 14px;
}
dialog::backdrop { background: rgba(37, 37, 37, 0.5); }
dialog form { padding: 1.25rem 1.5rem; }
dialog fieldset { border: 1px solid var(--powder); border-radius: 10px; margin: 0 0 1rem; padding: 0.75rem 1rem 0.25rem; }
dialog legend { color: var(--pride); font-weight: 700; padding: 0 0.4rem; }
dialog .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { dialog .two { grid-template-columns: 1fr; } }
dialog .btns { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: space-between; }
dialog .btns > div { display: flex; gap: 0.6rem; flex-wrap: wrap; }
dialog .msg { min-height: 1.4rem; }
.avprev { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--powder); display: block; margin-bottom: 0.4rem; }
