:root {
  --bg: #0a0d12;
  --bg-elevated: #10141b;
  --surface: #141a22;
  --surface-2: #1a212b;
  --border: #242e3a;
  --border-soft: #1b232d;
  --text: #e7edf3;
  --muted: #8b98a8;
  --faint: #5c6a78;
  --accent: #35d6a3;
  --accent-strong: #23b98b;
  --accent-soft: rgba(53, 214, 163, 0.12);
  --accent-text: #06231a;
  --warn: #e8b74f;
  --warn-soft: rgba(232, 183, 79, 0.12);
  --error: #f0616b;
  --error-soft: rgba(240, 97, 107, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Bakgrunn ---------- */

.ham-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ham-bg__glow {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  max-width: 900px;
  max-height: 900px;
  background: radial-gradient(circle, rgba(53, 214, 163, 0.20) 0%, rgba(53, 214, 163, 0) 70%);
}

.ham-bg__glow::after {
  content: "";
  position: absolute;
  bottom: -40%;
  left: -30%;
  width: 50vw;
  height: 50vw;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(circle, rgba(63, 130, 214, 0.15) 0%, rgba(63, 130, 214, 0) 70%);
}

.ham-bg__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(230, 237, 243, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(230, 237, 243, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 50%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 50%, transparent 100%);
}

.ham-bg__scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 220px;
  top: -220px;
  background: linear-gradient(to bottom, transparent, rgba(53, 214, 163, 0.11), transparent);
  animation: scan-sweep 14s ease-in-out infinite;
}

@keyframes scan-sweep {
  0%   { transform: translateY(0); opacity: 0; }
  8%   { opacity: 1; }
  50%  { transform: translateY(60vh); opacity: 1; }
  92%  { opacity: 0; }
  100% { transform: translateY(100vh); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ham-bg__scan { animation: none; display: none; }
}

/* ---------- Struktur ---------- */

.topbar, main, .auth-box {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(16, 20, 27, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.topbar .brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex: none;
}

.topbar .brand-mark svg {
  width: 15px;
  height: 15px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.86rem;
  color: var(--muted);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.86rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}

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

.topbar-nav a.is-danger:hover {
  color: var(--error);
  background: var(--error-soft);
}

main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 72px;
}

.page-head {
  margin-bottom: 32px;
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Propagasjonsside ---------- */

.propagation-summary {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  font-size: 0.94rem;
  line-height: 1.55;
}

.propagation-summary svg {
  flex: none;
  color: var(--accent);
  margin-top: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-tile__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 4px;
}

.stat-tile__value {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-tile.is-good .stat-tile__value { color: var(--accent); }
.stat-tile.is-warn .stat-tile__value { color: var(--warn); }
.stat-tile.is-bad .stat-tile__value { color: var(--error); }

.band-table td.is-good { color: var(--accent); font-weight: 600; }
.band-table td.is-warn { color: var(--warn); font-weight: 600; }
.band-table td.is-bad { color: var(--error); font-weight: 600; }

.vhf-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.vhf-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.vhf-list .vhf-status {
  color: var(--muted);
}

main h1 {
  letter-spacing: -0.01em;
}

/* ---------- Tjeneste-grid ---------- */

.service-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.service-grid > li {
  display: flex;
}

.service-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 152px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.service-card:hover {
  border-color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.service-card--form:hover {
  border-color: var(--border);
  transform: none;
  box-shadow: none;
}

.service-card--form .lookup-form {
  margin-top: 4px;
  max-width: none;
}

.service-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.service-card__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.service-card__icon svg {
  width: 17px;
  height: 17px;
}

.service-card__name {
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-card__meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.status-dot.is-online {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status-dot.is-offline {
  background: var(--error);
  box-shadow: 0 0 0 3px var(--error-soft);
}

.service-card__meta .arrow {
  color: var(--faint);
  transition: transform 0.15s ease, color 0.15s ease;
}

.service-card:hover .service-card__meta .arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.service-card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Innloggingsboks ---------- */

.auth-box {
  width: 100%;
  max-width: 360px;
  margin: auto;
  padding: 36px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-box .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.auth-box .brand-mark svg {
  width: 22px;
  height: 22px;
}

.auth-box h1 {
  margin: 0 0 22px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-box form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}

.auth-box input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
}

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

.auth-box button {
  margin-top: 6px;
}

.error {
  color: var(--error);
  font-size: 0.87rem;
  margin: -6px 0 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.success {
  color: var(--accent);
  font-size: 0.87rem;
  margin: -6px 0 4px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.auth-box p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 18px 0 0;
  text-align: center;
}

.auth-box p a {
  text-decoration: none;
}

.auth-box p a:hover {
  text-decoration: underline;
}

/* ---------- Knapper ---------- */

button, .btn {
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button[type="submit"], .btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

button[type="submit"]:hover, .btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-ghost:hover {
  border-color: var(--accent-strong);
  color: var(--accent);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--error);
  font-weight: 500;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-danger:hover {
  border-color: var(--error);
  background: var(--error-soft);
}

/* ---------- Kort (profil / admin-seksjoner) ---------- */

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.profile-card h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.profile-card > p.muted:first-of-type {
  margin-top: 0;
}

.profile-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 340px;
  margin-top: 16px;
}

.profile-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}

.profile-card input,
.profile-card textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--font);
}

.profile-card textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}

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

.profile-card button {
  align-self: flex-start;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 14px;
}

.lookup-form {
  max-width: 420px;
  margin-top: 16px;
}

.lookup-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 500;
}

.lookup-form__row {
  display: flex;
  gap: 10px;
}

.lookup-form__row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--font);
  line-height: 1.5;
}

.lookup-form__row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lookup-form__row button {
  flex: none;
  padding: 9px 16px;
}

.lookup-form--card .lookup-form__row input {
  padding: 7px 9px;
  font-size: 0.85rem;
}

.lookup-form--card .lookup-form__row button {
  padding: 7px 12px;
  font-size: 0.8rem;
}

.profile-card.wide {
  max-width: none;
}

label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-elevated);
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.checkbox-row input[type="checkbox"]:hover {
  border-color: var(--accent-strong);
}

.checkbox-row input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-row span {
  font-size: 0.9rem;
  color: var(--text);
}

label.toggle-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-row span:not(.toggle-switch) {
  font-size: 0.9rem;
  color: var(--text);
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 40px;
  height: 22px;
}

.toggle-switch input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle-switch input:checked ~ .toggle-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle-switch input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--accent);
}

.toggle-switch input:focus-visible ~ .toggle-track {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Tabell ---------- */

.table-scroll {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.user-table th,
.user-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.user-table tbody tr:last-child td {
  border-bottom: none;
}

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

.user-table th {
  color: var(--faint);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-elevated);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--faint);
  border: 1px solid var(--border);
}

.user-actions {
  display: flex;
  gap: 8px;
}

.user-actions form {
  display: inline;
}

/* ---------- Diverse ---------- */

.card-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 720px) {
  .card-grid-2 {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
