/* mtx.netikka.dk - eget design i netikka.dk's palette. Light + dark via tokens. */
:root {
  --groen: #bed73b;
  --groen-dyb: #8fa62a;
  --moerk: #23281a;
  --moerk2: #2e3422;
  --lys: #f4f6ec;
  --graa: #9aa18a;
  --blaa: #5aa9e6;
  --gul: #e8c547;
  --roed: #e0533f;

  /* light (default) */
  --bg: #f4f6ec;
  --bg-2: #ffffff;
  --bg-3: #e9ecdf;
  --fg: #23281a;
  --fg-2: #4b5240;
  --muted: #7d846f;
  --line: #d9ddcc;
  --accent: #8fa62a;
  --accent-fg: #ffffff;
  --shadow: 0 8px 30px rgba(35, 40, 26, .10);
  --sidebar-bg: #23281a;
  --sidebar-fg: #f4f6ec;
  --radius: 14px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #23281a;
  --bg-2: #2e3422;
  --bg-3: #384029;
  --fg: #f4f6ec;
  --fg-2: #d6dbc7;
  --muted: #9aa18a;
  --line: #3f4732;
  --accent: #bed73b;
  --accent-fg: #1a1a1a;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --sidebar-bg: #1b1f14;
  --sidebar-fg: #f4f6ec;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg: #23281a; --bg-2: #2e3422; --bg-3: #384029; --fg: #f4f6ec; --fg-2: #d6dbc7; --muted: #9aa18a;
    --line: #3f4732; --accent: #bed73b; --accent-fg: #1a1a1a; --shadow: 0 12px 40px rgba(0,0,0,.45);
    --sidebar-bg: #1b1f14; --sidebar-fg: #f4f6ec; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
h4 { margin: .8rem 0 .3rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.muted { color: var(--muted); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
button, input, select {
  font: inherit; color: inherit;
}
button {
  background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 10px;
  padding: .55rem 1rem; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.06); }
button.danger { background: var(--roed); color: #fff; }
button.ghost { background: transparent; color: var(--fg-2); border: 1px solid var(--line); }
input, select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .75rem;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: .3rem; font-size: .9rem; color: var(--fg-2); }

/* layout */
#app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
#sidebar {
  grid-row: 1 / 3; background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column; padding: 18px 12px; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--sidebar-fg); padding: 4px 8px; }
.brand img { width: 64px; height: auto; filter: drop-shadow(0 6px 16px rgba(0,0,0,.35)); }
.brand span { font-weight: 300; letter-spacing: .35em; text-transform: uppercase; }
#menu { display: flex; flex-direction: column; gap: 4px; }
#menu a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--sidebar-fg); opacity: .8;
}
#menu a i { font-style: normal; width: 20px; text-align: center; color: var(--groen); }
#menu a:hover { background: rgba(255,255,255,.06); opacity: 1; }
#menu a.active { background: rgba(190, 215, 59, .16); opacity: 1; }
.side-foot { margin-top: auto; display: flex; gap: 8px; }
.side-foot button { background: rgba(255,255,255,.08); color: var(--sidebar-fg); flex: 1; }
#topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
#burger { display: none; background: transparent; color: var(--fg); font-size: 1.3rem; padding: .2rem .5rem; }
#topstats { display: flex; gap: 18px; flex: 1; overflow: auto; white-space: nowrap; font-size: .9rem; }
#topstats b { color: var(--fg); font-weight: 600; }
#topstats span { color: var(--muted); }
#live-dot span { display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--roed); box-shadow: 0 0 0 4px rgba(224,83,63,.2); }
#live-dot.on span { background: var(--groen); box-shadow: 0 0 0 4px rgba(190,215,59,.25); }
#content { padding: 24px; padding-inline: max(16px, 24px); }
.page-head { margin-bottom: 18px; }
.page-head p { margin: .2rem 0 0; }
section { margin-top: 28px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.card header { display: flex; align-items: center; gap: 10px; }
.card header .kind, .card header .codec { margin-left: auto; font-size: .8rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--graa); flex: none; }
.dot.ok { background: var(--groen); box-shadow: 0 0 0 3px rgba(190,215,59,.25); }
.dot.warn { background: var(--gul); box-shadow: 0 0 0 3px rgba(232,197,71,.25); }
.dot.bad { background: var(--roed); box-shadow: 0 0 0 3px rgba(224,83,63,.25); }
.kv { display: grid; grid-template-columns: minmax(84px, max-content) 1fr; gap: 3px 8px; margin: 0; font-size: .9rem; }
.kv dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 3px; white-space: nowrap; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.endpoints { display: grid; gap: 6px; }
.ep-group { display: grid; grid-template-columns: minmax(84px, max-content) 1fr; gap: 5px 8px; align-items: start; }
.ep-group .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ep-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 5px; white-space: nowrap; }
.chip {
  font-size: .75rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-2);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.video { border-color: color-mix(in srgb, var(--groen) 60%, var(--line)); }
.chip.audio { border-color: color-mix(in srgb, var(--blaa) 60%, var(--line)); }
.chip .dot { width: 7px; height: 7px; box-shadow: none; }
canvas.spark { width: 100%; height: 48px; display: block; }
.card footer { display: flex; gap: 8px; justify-content: flex-end; }
.preview { position: relative; background: #000; border-radius: 10px; aspect-ratio: 16/9; overflow: hidden; display: grid; place-items: center; }
.preview video { width: 100%; height: 100%; object-fit: contain; }
.preview button { position: absolute; }
.preview .btn-stop { right: 10px; bottom: 10px; padding: .35rem .7rem; font-size: .85rem; opacity: .85; }
ul.readers { list-style: none; padding: 0; margin: 0; font-size: .9rem; display: grid; gap: 4px; }
ul.readers li { display: flex; gap: 10px; }
ul.readers li b { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: var(--muted); width: 56px; }

/* tables */
table.list { width: 100%; border-collapse: collapse; background: var(--bg-2); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: .9rem; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.list-wrap, .matrix-wrap { overflow-x: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.stack { display: grid; gap: 8px; max-width: 380px; }
.msg { min-height: 1.2em; margin: 0; font-size: .9rem; color: var(--muted); }
.msg.err { color: var(--roed); } .msg.ok { color: var(--groen-dyb); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; color: var(--fg-2); border-radius: 0; }
.seg button.active { background: var(--accent); color: var(--accent-fg); }

/* routing matrix */
#matrix { border-collapse: separate; border-spacing: 0; font-size: .85rem; background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); }
#matrix th, #matrix td { border: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
#matrix th.src { writing-mode: vertical-rl; transform: rotate(180deg); height: 26px; text-align: start; font-weight: 500; font-size: .7rem; padding: 4px 2px; }
#matrix th.dst { text-align: right; position: sticky; left: 0; background: var(--bg-2); font-weight: 400; }
#matrix th.dst.foldable, #matrix th.group { cursor: pointer; }
#matrix th.dst { vertical-align: top; }
#matrix th.ch { text-align: right; font-weight: 500; font-size: .75rem; min-width: 28px; background: var(--bg-2); }
#matrix th.dst b { font-weight: 600; color: var(--fg); }
#matrix th.ep { writing-mode: vertical-rl; transform: rotate(180deg); height: 110px; text-align: start; vertical-align: top; cursor: pointer; font-weight: 500; background: var(--bg-2); font-size: .8rem; padding: 6px 4px; white-space: nowrap; }
#matrix th.ep .fold { writing-mode: horizontal-tb; transform: rotate(180deg); display: inline-block; margin: 4px 0 0; }
#matrix th.corner { position: sticky; left: 0; background: var(--bg-2); z-index: 2; }
#matrix .fold { display: inline-block; width: 16px; color: var(--accent); cursor: pointer; font-weight: 700; }
#matrix .fold.none { cursor: default; }
#matrix th.group { background: var(--bg-3); color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; text-align: left; }
#matrix th.group .fold { letter-spacing: 0; }
#matrix th.sub { background: color-mix(in srgb, var(--bg-3) 55%, var(--bg-2)); color: var(--fg-2); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; text-align: left; cursor: pointer; }
#matrix th.bg-video { background: color-mix(in srgb, var(--groen) 28%, var(--bg-2)); }
#matrix th.bg-audio { background: color-mix(in srgb, var(--blaa) 26%, var(--bg-2)); }
#matrix th.dst.bg-video, #matrix th.dst.bg-audio { color: var(--fg); }
#matrix td.x { width: 26px; min-width: 26px; height: 26px; padding: 0; text-align: center; cursor: pointer; }
#matrix td.x:hover { background: var(--bg-3); }
#matrix td.x.hl { background: color-mix(in srgb, var(--accent) 14%, var(--bg-2)); }
#matrix td.x.na.hl { background: color-mix(in srgb, var(--accent) 10%, var(--bg-3)); }
#matrix th.hl { outline: 2px solid var(--accent); outline-offset: -2px; }
#matrix td.x.na { cursor: default; background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 5px); }
#matrix td.x .pt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
#matrix td.x .pt.ok { background: var(--groen); } #matrix td.x .pt.warn { background: var(--gul); } #matrix td.x .pt.bad { background: var(--roed); }
.media-video { color: var(--groen-dyb); } [data-theme="dark"] .media-video { color: var(--groen); }
.media-audio { color: var(--blaa); }

/* auth */
#auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% -20%, var(--moerk2) 0%, var(--moerk) 65%); color: var(--lys); }
.auth-card { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; }
.auth-logo { width: min(260px, 70%); margin: 0 auto 10px; filter: drop-shadow(0 12px 40px rgba(0,0,0,.45)); }
.auth-card form { display: grid; gap: 12px; text-align: left; }
.auth-card input { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.15); color: var(--lys); }
.auth-card button { background: var(--groen); color: #1a1a1a; }
.auth-card label { color: var(--graa); }
.auth-msg { min-height: 1.2em; color: var(--gul); margin: 0; text-align: center; }

/* responsive */
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; transform: translateX(-100%); transition: transform .2s; z-index: 20; }
  #app.menu-open #sidebar { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  #burger { display: block; }
  #content { padding: 16px; }
  .cards { grid-template-columns: 1fr; }
}

/* modal */
dialog#modal { border: 0; border-radius: var(--radius); padding: 0; background: var(--bg-2); color: var(--fg); box-shadow: var(--shadow); width: min(440px, calc(100vw - 32px)); }
dialog#modal::backdrop { background: rgba(35, 40, 26, .55); backdrop-filter: blur(2px); }
.modal-card { padding: 22px 22px 18px; display: grid; gap: 10px; margin: 0; }
.modal-card h3 { font-size: 1.1rem; }
.modal-card p { margin: 0; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal-actions button.ghost { margin-right: auto; }

/* encoder-styring paa enhedskort */
.encoders { display: grid; gap: 8px; }
form.enc { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); font-size: .85rem; }
form.enc .enc-head { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
form.enc label { display: flex; align-items: center; gap: 6px; font-size: .8rem; }
form.enc label.row { grid-column: 1; }
form.enc input[type=number] { width: 84px; padding: .3rem .5rem; }
form.enc button { grid-column: 2; justify-self: end; padding: .35rem .8rem; }

/* intercom: brugere x linjer */
#ic-table th.line { text-align: center; }
#ic-table th.ic-name { display: flex; align-items: center; gap: 10px; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--fg); min-width: 170px; }
#ic-table th.ic-name b { font-weight: 600; display: block; }
#ic-table .ic-sub { display: block; font-size: .72rem; white-space: nowrap; }
#ic-table td.ic { text-align: center; min-width: 78px; padding: 6px 4px; vertical-align: middle; }
#ic-table td.ic .acc { width: 100%; padding: .28rem .3rem; font-size: .75rem; border-radius: 8px; }
#ic-table td.ic .acc.talk { background: var(--accent); color: var(--accent-fg); }
#ic-table td.ic .acc.listen { background: color-mix(in srgb, var(--blaa) 22%, var(--bg-2)); color: var(--fg); border: 1px solid color-mix(in srgb, var(--blaa) 60%, var(--line)); }
#ic-table td.ic .acc.none { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
#ic-table td.ic .acc:disabled { opacity: .7; cursor: default; }
#ic-table td.ic .live { display: block; min-height: 1.1em; margin-top: 4px; font-size: .7rem; color: var(--muted); white-space: nowrap; }
#ic-table td.ic .live.talk { color: var(--groen-dyb); font-weight: 600; }
[data-theme="dark"] #ic-table td.ic .live.talk { color: var(--groen); }
#ic-table td.ic .live.listen { color: var(--blaa); font-weight: 600; }
#ic-table td.ic .live.can { cursor: pointer; opacity: .55; }
#ic-table td.ic .live.can:hover { opacity: 1; text-decoration: underline; }
#ic-table td.ic-act { white-space: nowrap; }
#ic-table td.ic-act input { width: 130px; padding: .3rem .5rem; font-size: .8rem; margin-right: 4px; }
#ic-table td.ic-act button { padding: .3rem .6rem; font-size: .8rem; }
#ic-table button.danger.ghost { color: var(--roed); border-color: color-mix(in srgb, var(--roed) 50%, var(--line)); background: transparent; }
#ic-table tr.group th { background: var(--bg-3); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; cursor: pointer; }
#ic-table tr.group .fold { color: var(--accent); font-weight: 700; margin-right: 4px; }
#ic-table tr.bridge th.ic-name b { font-weight: 500; color: var(--fg-2); }
#ic-table tr.guests th { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.small { font-size: .8rem; }
