:root {
  color-scheme: dark;
  --page: #080b12;
  --surface: rgba(15, 21, 32, .92);
  --surface-strong: rgba(20, 28, 42, .97);
  --surface-soft: rgba(27, 36, 53, .84);
  --line: rgba(142, 162, 194, .20);
  --text: #f5f7fb;
  --muted: #98a4b7;
  --cyan: #40d9ff;
  --blue: #638cff;
  --violet: #aa78ff;
  --pink: #ff72b8;
  --green: #35e296;
  --red: #ff5e6d;
  --amber: #ffc65c;
  --rail-width: 318px;
  --composer-width: 68%;
  --bg-overlay: .68;
  --bg-blur: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.mobile-only { display: none; }

.background-layer {
  position: fixed;
  inset: -30px;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(var(--bg-blur));
}
.background-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 70% 15%, rgba(69, 102, 188, .16), transparent 34%),
    rgba(5, 8, 14, var(--bg-overlay));
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-width) 5px minmax(0, 1fr);
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: .17em;
  font-weight: 900;
  letter-spacing: -.055em;
  white-space: nowrap;
}
.wordmark .areal {
  background: linear-gradient(90deg, #39ddff, #6aa0ff);
  -webkit-background-clip: text;
  color: transparent;
}
.wordmark .lyn {
  background: linear-gradient(90deg, #7d91ff, #bf72ff);
  -webkit-background-clip: text;
  color: transparent;
}
.wordmark .ai {
  background: linear-gradient(90deg, #ce72ff, #ff79af);
  -webkit-background-clip: text;
  color: transparent;
}
.small-wordmark { font-size: 19px; }
.compact-wordmark { font-size: 18px; }
.hero-wordmark {
  font-size: clamp(33px, 6vw, 72px);
  filter: drop-shadow(0 12px 35px rgba(100, 140, 255, .16));
}

.admin-rail {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--surface-strong);
  backdrop-filter: blur(22px);
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.rail-header {
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
}
.rail-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 9px;
  border-bottom: 1px solid var(--line);
}
.rail-link {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 7px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
}
.rail-link span { font-size: 15px; }
.rail-link:hover, .rail-link.active {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}
.rail-panel { overflow: auto; padding: 9px; }
.rail-footer {
  padding: 9px;
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
}
.profile-mini {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.profile-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #07101c;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}
.profile-mini div:last-child { min-width: 0; display: flex; flex-direction: column; }
.profile-mini strong, .profile-mini span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-mini strong { font-size: 11px; }
.profile-mini span { color: var(--muted); font-size: 9px; }

.rail-splitter {
  cursor: col-resize;
  position: relative;
  touch-action: none;
}
.rail-splitter::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 2px;
  width: 1px;
  background: var(--line);
}

.chat-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(5, 8, 13, .26);
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: rgba(11, 16, 25, .88);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.top-brand { min-width: 121px; }
.connection-indicators { display: flex; align-items: center; gap: 5px; }
.status-indicator {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 20, 31, .74);
  color: var(--muted);
  padding: 0 9px;
  cursor: pointer;
}
.status-indicator i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px rgba(255, 94, 109, .55);
}
.status-indicator.online i {
  background: var(--green);
  box-shadow: 0 0 12px rgba(53, 226, 150, .8);
}
.status-indicator.partial i {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 198, 92, .65);
}
.model-select {
  min-width: 150px;
  max-width: 270px;
  height: 32px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 8px;
}
.layout-actions { display: flex; align-items: center; gap: 1px; }

.icon-button, .composer-button, .send-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
}
.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  font-size: 17px;
}
.icon-button:hover, .composer-button:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

.chat-viewport {
  min-height: 0;
  overflow-y: auto;
  padding: clamp(14px, 3vw, 38px) 12px 24px;
  scroll-behavior: smooth;
}
.welcome {
  min-height: 100%;
  max-width: 850px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.welcome p {
  margin: 6px 0 17px;
  color: var(--muted);
  font-size: clamp(12px, 1.5vw, 16px);
}
.quick-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px 13px;
  max-width: 760px;
}
.quick-actions button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}
.quick-actions button:hover { color: var(--text); }
.quick-actions i {
  width: 7px;
  height: 7px;
  border: 1px solid var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(99, 140, 255, .5);
}

.message-list {
  max-width: 980px;
  margin: 0 auto;
}
.message-row { display: flex; margin: 0 0 13px; }
.message-row.user { justify-content: flex-end; }
.message-bubble {
  max-width: min(82%, 780px);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 10px 12px;
  background: rgba(15, 21, 32, .86);
  backdrop-filter: blur(14px);
  overflow-wrap: anywhere;
}
.message-row.user .message-bubble {
  background: rgba(36, 53, 81, .92);
  border-bottom-right-radius: 4px;
}
.message-row.assistant .message-bubble { border-bottom-left-radius: 4px; }
.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 5px;
}
.copy-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.message-content p { margin: 0 0 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content pre {
  overflow-x: auto;
  background: #070a10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
}
.message-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.message-content :not(pre) > code {
  background: #252f42;
  padding: 2px 5px;
  border-radius: 5px;
}
.message-content a { color: var(--cyan); }
.typing::after {
  content: "▋";
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.composer-zone {
  padding: 5px 8px 4px;
  background: rgba(9, 13, 21, .88);
  backdrop-filter: blur(20px);
}
.composer {
  width: var(--composer-width);
  max-width: 850px;
  min-width: 280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border: 1px solid rgba(109, 147, 220, .34);
  border-radius: 15px;
  background: rgba(17, 23, 34, .95);
  padding: 5px 6px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .18);
}
.composer:focus-within {
  border-color: rgba(78, 154, 255, .7);
  box-shadow: 0 0 0 2px rgba(74, 145, 255, .10);
}
.composer-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}
#promptInput {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  max-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 5px 4px 4px;
  line-height: 1.35;
}
.send-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: #07101b;
  font-weight: 900;
}
.attachment-strip {
  width: var(--composer-width);
  max-width: 850px;
  min-width: 280px;
  margin: 0 auto 4px;
  display: flex;
  gap: 5px;
  overflow-x: auto;
}
.attachment-chip {
  max-width: 220px;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 4px 7px;
  font-size: 10px;
  white-space: nowrap;
}
.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.micro-footer {
  height: 17px;
  max-width: 980px;
  margin: 1px auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(171, 182, 201, .62);
  font-size: 8px;
}

.floating-bubble {
  position: fixed;
  z-index: 80;
  right: calc(18px + var(--safe-right));
  bottom: calc(20px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 19px;
  display: grid;
  place-items: center;
  color: #07101b;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 48%, var(--violet));
  box-shadow: 0 15px 45px rgba(0, 0, 0, .5);
  cursor: grab;
  touch-action: none;
}
.bubble-a { font-size: 24px; font-weight: 900; }
.floating-bubble i {
  position: absolute;
  width: 10px;
  height: 10px;
  right: 5px;
  bottom: 5px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #111827;
}
.floating-bubble.online i { background: var(--green); }
.app.minimized .admin-rail,
.app.minimized .rail-splitter,
.app.minimized .chat-shell { visibility: hidden; }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
}
.panel-heading h2 { margin: 0; font-size: 14px; }
.panel-heading p { margin: 1px 0 0; color: var(--muted); font-size: 9px; }
.panel-tools { display: flex; gap: 4px; }

.primary-button, .subtle-button {
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 11px;
  font-weight: 750;
}
.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: #07101b;
}
.subtle-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
}
.small-button { padding: 6px 8px; font-size: 10px; }
.wide { width: 100%; }

.list-stack { display: grid; gap: 5px; }
.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 7px 8px;
}
.list-item:hover, .list-item.selected {
  background: var(--surface-soft);
  border-color: var(--line);
}
.list-main { min-width: 0; cursor: pointer; }
.list-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: 700;
}
.list-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 8px;
}
.list-actions { display: flex; gap: 1px; }
.tiny-button {
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tiny-button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.tiny-button.danger:hover { color: var(--red); }

.empty-state {
  color: var(--muted);
  font-size: 10px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  padding: 12px;
  text-align: center;
}
.search-field, .form-field, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 12, 19, .8);
  color: var(--text);
  outline: none;
  padding: 8px 9px;
}
.search-field { margin-bottom: 7px; }
.form-label { display: grid; gap: 5px; font-size: 10px; font-weight: 700; }
.form-label small { color: var(--muted); font-weight: 400; }
.form-textarea { resize: vertical; min-height: 70px; }

.status-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}
.status-dot.online { background: var(--green); box-shadow: 0 0 8px rgba(53,226,150,.65); }
.status-dot.partial { background: var(--amber); }

.settings-stack { display: grid; gap: 11px; }
.settings-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(11, 16, 25, .55);
}
.settings-group h3 { margin: 0 0 7px; font-size: 12px; }
.range-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
}
.range-row output { color: var(--muted); font-size: 9px; }
.background-preview {
  height: 105px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 9px;
  margin-top: 7px;
}
.background-preview img { width: 100%; height: 100%; object-fit: cover; }

.modal {
  width: min(640px, calc(100% - 20px));
  max-height: calc(100dvh - 20px);
  padding: 0;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--text);
}
.modal::backdrop { background: rgba(0,0,0,.64); backdrop-filter: blur(5px); }
.modal-card {
  max-height: calc(100dvh - 20px);
  overflow: auto;
  background: #121a28;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 15px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-header p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-fields .full { grid-column: 1 / -1; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 13px;
}
.diagnostic-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px;
}
.diagnostic-card code { color: var(--cyan); overflow-wrap: anywhere; }
.diagnostic-card span { color: var(--muted); font-size: 10px; }
.diagnostic-details {
  min-height: 100px;
  max-height: 250px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #080c13;
  padding: 10px;
  color: var(--muted);
  font-size: 10px;
}
.scrim { display: none; }

.app.layout-popup {
  width: min(470px, 100%);
  height: min(760px, 100%);
  margin: auto;
  grid-template-columns: 0 0 1fr;
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0,0,0,.55);
}
.app.layout-popup .admin-rail,
.app.layout-popup .rail-splitter { display: none; }
.app.layout-popup .desktop-only { display: none; }
.app.layout-popup .mobile-only { display: inline-grid; }
.app.layout-popup .top-brand { display: none; }
.app.layout-popup .composer { width: 88%; min-width: 0; }
.app.layout-popup .attachment-strip { width: 88%; min-width: 0; }

.app.layout-sidebar { --rail-width: 285px; }

@media (max-width: 900px) {
  :root { --composer-width: 72%; }
  .status-indicator span { display: none; }
  .status-indicator { width: 30px; padding: 0; justify-content: center; }
  .top-brand { min-width: 100px; }
}

@media (max-width: 720px) {
  :root { --composer-width: 70%; }
  .desktop-only { display: none; }
  .mobile-only { display: inline-grid; }

  .app { display: block; padding: 0; }
  .admin-rail {
    position: fixed;
    z-index: 60;
    inset: 0 auto 0 0;
    width: min(86vw, 345px);
    transform: translateX(-103%);
    transition: transform .2s ease;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .admin-rail.open { transform: translateX(0); }
  .rail-header { justify-content: space-between; }
  .rail-splitter { display: none; }
  .scrim {
    position: fixed;
    z-index: 55;
    inset: 0;
    background: rgba(0,0,0,.54);
  }
  .scrim.open { display: block; }

  .chat-shell {
    height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  .topbar {
    height: 44px;
    gap: 4px;
    padding: 0 6px;
  }
  .top-brand { min-width: 83px; }
  .compact-wordmark { font-size: 15px; }
  .model-select {
    min-width: 0;
    max-width: 36vw;
    height: 29px;
    padding-inline: 5px;
    font-size: 10px;
  }
  .icon-button { width: 31px; height: 31px; font-size: 15px; }
  .connection-indicators { gap: 3px; }
  .status-indicator { width: 25px; height: 25px; }
  .status-indicator i { width: 7px; height: 7px; }

  .chat-viewport { padding: 11px 7px 16px; }
  .welcome { justify-content: flex-start; padding-top: min(10vh, 60px); }
  .hero-wordmark { font-size: clamp(31px, 11vw, 48px); }
  .welcome p {
    max-width: 88%;
    margin: 3px 0 9px;
    font-size: 10px;
  }
  .quick-actions {
    gap: 1px 10px;
    max-width: 92%;
  }
  .quick-actions button { font-size: 9px; padding: 3px 0; }
  .quick-actions i { width: 5px; height: 5px; }

  .message-list { padding: 0 2px; }
  .message-bubble { max-width: 91%; padding: 8px 9px; }

  .composer-zone {
    padding: 3px 5px calc(2px + var(--safe-bottom));
  }
  .composer {
    width: var(--composer-width);
    min-width: 0;
    max-width: none;
    padding: 3px 4px;
    border-radius: 12px;
  }
  #promptInput {
    min-height: 27px;
    max-height: 105px;
    padding: 4px 2px 3px;
    font-size: 12px;
  }
  .composer-button { width: 27px; height: 27px; font-size: 12px; }
  .send-button { width: 29px; height: 29px; }
  .attachment-strip { width: var(--composer-width); min-width: 0; }
  .micro-footer {
    height: 13px;
    font-size: 7px;
    padding: 0 3px;
  }
}

@media (max-width: 390px) {
  :root { --composer-width: 78%; }
  .top-brand { display: none; }
  .model-select { max-width: 43vw; }
  .welcome { padding-top: min(7vh, 38px); }
}

@media (min-width: 721px) and (max-width: 1180px) {
  :root { --rail-width: 280px; --composer-width: 66%; }
}

/* Fold-enheter med to fysiske visningssegmenter. */
@media (horizontal-viewport-segments: 2) {
  .app {
    grid-template-columns:
      env(viewport-segment-width 0 0)
      env(viewport-segment-left 1 0)
      env(viewport-segment-width 1 0);
  }
  .admin-rail { grid-column: 1; position: static; transform: none; width: auto; }
  .rail-splitter { grid-column: 2; display: block; cursor: default; }
  .chat-shell { grid-column: 3; height: 100dvh; }
  .mobile-only { display: none; }
}


/* V3.2.0 — full administrasjonsarbeidsflate */
.rail-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workspace { width: min(1500px, 100%); min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; }
.workspace-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 4px 4px 16px; border-bottom: 1px solid var(--line); }
.workspace-header h1 { margin: 0; font-size: clamp(22px, 3vw, 34px); }
.workspace-header p { margin: 4px 0 0; color: var(--muted); }
.workspace-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.workspace-content { flex: 1; min-height: 0; padding: 16px 4px 24px; display: grid; gap: 14px; }
.chat-viewport.workspace-mode { padding: 12px clamp(10px, 2vw, 24px) 20px; }
.metrics-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.metric-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.metric-card span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.metric-card strong { display: block; margin: 6px 0 2px; font-size: clamp(20px, 3vw, 30px); }
.metric-card small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-card.ok { border-color: rgba(53,226,150,.35); }
.metric-card.error { border-color: rgba(255,94,109,.35); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.workspace-card { min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 14px; overflow: hidden; }
.workspace-card.wide-card { grid-column: 1 / -1; }
.workspace-card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.workspace-card h2 { margin: 0; font-size: 15px; }
.workspace-card p { color: var(--muted); }
.workspace-card > header button { border: 0; background: transparent; color: var(--cyan); cursor: pointer; }
.compact-rows { display: grid; gap: 5px; }
.compact-row { display: grid; grid-template-columns: auto minmax(0,1fr) minmax(0,1.2fr); gap: 8px; align-items: center; padding: 7px; border-radius: 9px; background: rgba(255,255,255,.025); }
.compact-row i, .stream-card header i, .sql-connections button i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px rgba(255,94,109,.4); }
.compact-row i.online, .stream-card.active header i, .sql-connections button i.online { background: var(--green); box-shadow: 0 0 10px rgba(53,226,150,.65); }
.compact-row span, .compact-row small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact-row small { color: var(--muted); text-align: right; }
.project-summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.project-summary { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); color: var(--text); padding: 11px; cursor: pointer; }
.project-summary span, .project-summary small { color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-list { display: grid; gap: 4px; }
.activity-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) auto; gap: 10px; padding: 7px 3px; border-bottom: 1px solid rgba(255,255,255,.04); }
.activity-row span, .activity-row time { color: var(--muted); font-size: 10px; }
.workspace-empty { min-height: 52vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--muted); }
.project-studio { min-height: 690px; display: grid; grid-template-columns: 230px minmax(0,1fr); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; background: var(--surface); }
.project-sidebar { min-width: 0; padding: 11px; display: flex; flex-direction: column; gap: 8px; border-right: 1px solid var(--line); background: rgba(9,14,23,.72); }
.project-name { font-weight: 800; }
.project-mini-list { flex: 1; min-height: 180px; overflow: auto; display: grid; align-content: start; gap: 4px; margin-top: 5px; }
.project-mini-list button { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); padding: 8px; cursor: pointer; }
.project-mini-list button.active, .project-mini-list button:hover { background: var(--surface-soft); border-color: var(--line); }
.project-mini-list strong, .project-mini-list small { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-mini-list small { color: var(--muted); }
.project-editor-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr); }
.studio-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line); }
.code-tabs, .studio-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.code-tabs button { border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); padding: 6px 10px; cursor: pointer; }
.code-tabs button.active { background: var(--surface-soft); color: var(--text); border-color: var(--blue); }
.studio-actions .primary-button, .studio-actions .subtle-button { padding: 6px 9px; font-size: 10px; }
.studio-split { min-height: 0; display: grid; grid-template-columns: minmax(0,1fr) minmax(320px, .95fr); }
.code-editor { width: 100%; height: 100%; min-height: 610px; resize: none; border: 0; border-right: 1px solid var(--line); outline: 0; padding: 15px; background: #070b12; color: #dbe6ff; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; }
.preview-wrap { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 1fr; background: #fff; }
.preview-label { padding: 7px 9px; background: #111827; color: #aeb9cc; font-size: 10px; }
.project-preview { width: 100%; height: 100%; min-height: 580px; border: 0; background: white; }
.admin-table { display: grid; gap: 4px; overflow: auto; }
.admin-row { display: grid; grid-template-columns: minmax(150px,.8fr) minmax(90px,.45fr) minmax(240px,1.5fr) minmax(160px,1fr) minmax(300px,1.2fr); gap: 8px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.admin-row.admin-head { position: sticky; top: 0; z-index: 2; background: #111827; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.admin-row code { overflow-wrap: anywhere; color: var(--cyan); font-size: 10px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.table-actions .subtle-button, .table-actions .primary-button { padding: 5px 7px; font-size: 9px; }
.stream-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.stream-card { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); padding: 12px; }
.stream-card.active { border-color: rgba(53,226,150,.35); }
.stream-card header { display: flex; justify-content: space-between; gap: 8px; }
.stream-card h2 { margin: 0; font-size: 14px; }
.stream-card p, .stream-card small { color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.stream-card pre { min-height: 110px; max-height: 220px; overflow: auto; white-space: pre-wrap; border: 1px solid var(--line); border-radius: 9px; background: #070b12; padding: 9px; color: #b9c5d8; font-size: 10px; }
.stream-card footer { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.stream-card footer button { padding: 6px 8px; font-size: 9px; }
.sql-layout { min-height: 650px; display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 10px; }
.sql-connections { display: grid; align-content: start; gap: 5px; overflow: auto; }
.sql-connections button { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr); gap: 4px 7px; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: 10px; text-align: left; cursor: pointer; }
.sql-connections button.active { border-color: var(--blue); background: var(--surface-soft); }
.sql-connections button strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sql-connections button span, .sql-connections button code { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9px; }
.sql-console { min-width: 0; display: flex; flex-direction: column; gap: 9px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); padding: 12px; }
.sql-console > header { display: flex; align-items: center; gap: 7px; }
.sql-console > header > div { flex: 1; min-width: 0; }
.sql-console h2 { margin: 0; }
.sql-console p { color: var(--muted); margin: 2px 0 0; }
.sql-editor { width: 100%; min-height: 190px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #070b12; color: #dbe6ff; padding: 12px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sql-mode { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; }
.sql-result { flex: 1; min-height: 230px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #080c13; padding: 10px; color: var(--muted); }
.sql-result table { border-collapse: collapse; min-width: 100%; color: var(--text); font-size: 10px; }
.sql-result th, .sql-result td { border: 1px solid var(--line); padding: 6px; text-align: left; white-space: nowrap; }
.settings-workspace-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.settings-workspace-grid .workspace-card { min-height: 170px; }
.toggle-row { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.large-preview { height: 150px; margin: 9px 0; }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .stream-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .studio-split { grid-template-columns: 1fr; }
  .code-editor { min-height: 400px; border-right: 0; border-bottom: 1px solid var(--line); }
  .project-preview { min-height: 480px; }
}

@media (max-width: 720px) {
  .rail-nav { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .workspace-header { flex-direction: column; padding-bottom: 10px; }
  .workspace-actions { justify-content: flex-start; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid, .settings-workspace-grid { grid-template-columns: 1fr; }
  .project-summary-grid { grid-template-columns: 1fr; }
  .activity-row { grid-template-columns: 1fr; gap: 2px; }
  .project-studio { grid-template-columns: 1fr; min-height: auto; }
  .project-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .project-mini-list { display: flex; min-height: 0; overflow-x: auto; }
  .project-mini-list button { min-width: 150px; }
  .studio-toolbar { align-items: flex-start; flex-direction: column; }
  .studio-actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .code-editor { min-height: 350px; }
  .project-preview { min-height: 430px; }
  .admin-row, .admin-row.admin-head { display: flex; flex-direction: column; align-items: stretch; }
  .admin-row.admin-head { display: none; }
  .admin-row > span::before { content: attr(data-label); display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; }
  .stream-grid { grid-template-columns: 1fr; }
  .sql-layout { grid-template-columns: 1fr; min-height: auto; }
  .sql-connections { display: flex; overflow-x: auto; }
  .sql-connections button { min-width: 235px; }
  .sql-editor { min-height: 170px; }
}


/* V4.0.0 — innlogging, flow og trafikkdashboard */


.flow-workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, .38fr) minmax(0, .62fr);
  gap: 10px;
}
.flow-map-card { min-height: 410px; }
.flow-map-svg {
  width: 100%;
  height: 350px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(6, 10, 17, .64);
}
.flow-traffic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px;
  margin-top: 10px;
}
.flow-traffic-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0,1fr) 150px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  padding: 9px;
}
.flow-traffic-card h3 { margin: 0; font-size: 11px; }
.flow-traffic-card p { margin: 2px 0 0; color: var(--muted); font-size: 9px; }
.flow-sparkline { width: 150px; height: 48px; display: block; }
.flow-list { display: grid; gap: 6px; }
.flow-list-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 7px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px;
  background: var(--surface);
}
.flow-list-row strong, .flow-list-row small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-list-row small { color: var(--muted); font-size: 9px; }
.flow-actions { display: flex; gap: 2px; }
.flow-status-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.flow-summary-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 10px;
}
.flow-summary-card span { color: var(--muted); font-size: 9px; }
.flow-summary-card strong { display: block; margin-top: 3px; font-size: 20px; }

@media (max-width: 980px) {
  .flow-workspace-grid { grid-template-columns: 1fr; }
  .flow-traffic-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .flow-status-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .flow-traffic-card { grid-template-columns: minmax(0,1fr) 105px; }
  .flow-sparkline { width: 105px; }
  .flow-map-svg { height: 290px; }
}


/* V4.2.0 — nettsideaktivitet og permanente domener */
.analytics-host-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
}
.analytics-host-card {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(13,19,29,.70);
  padding: 10px;
}
.analytics-host-card strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.analytics-host-card span, .analytics-host-card small { color: var(--muted); }
.workspace-note {
  border: 1px solid rgba(255,198,94,.30);
  border-radius: 10px;
  background: rgba(255,198,94,.08);
  color: #ffd98d;
  padding: 9px;
  margin-bottom: 8px;
  font-size: 10px;
}
.permanent-domain-list { display: grid; gap: 7px; }
.permanent-domain-list > div {
  display: grid;
  grid-template-columns: 90px minmax(0,1fr);
  gap: 2px 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.permanent-domain-list code {
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.permanent-domain-list span {
  grid-column: 2;
  color: var(--muted);
  font-size: 9px;
}
.checkbox-line {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  margin-top: 8px;
}
@media (max-width: 980px) {
  .analytics-host-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 520px) {
  .analytics-host-grid { grid-template-columns: 1fr; }
}
