:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --purple: #6f2dad;
  --purple-dark: #4c197f;
  --purple-soft: #f2eafb;
  --green: #52cf91;
  --green-dark: #249f68;
  --green-soft: #e8f9f1;
  --ink: #1e1b2e;
  --text: #4f4b60;
  --muted: #888398;
  --canvas: #f6f5f9;
  --surface: #fff;
  --border: #e8e5ee;
  --danger: #df5267;
  --shadow: 0 12px 35px rgb(42 29 68 / 8%);
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { min-height: 100vh; margin: 0; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.eyebrow {
  margin: 0;
  color: var(--purple);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .15em;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 17px;
  background: linear-gradient(145deg, #813fc1, #5f209d);
  box-shadow: 0 10px 24px rgb(111 45 173 / 25%);
  color: #fff;
  font-size: 27px;
  font-weight: 900;
}
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 20px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 10%, rgb(82 207 145 / 22%), transparent 28%),
    radial-gradient(circle at 88% 88%, rgb(111 45 173 / 22%), transparent 32%),
    linear-gradient(145deg, #f9f7fc, #f0ebf7);
}
.login-shell::before {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgb(111 45 173 / 10%) 1px, transparent 1px);
  background-size: 24px 24px;
  content: "";
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(100%, 460px);
  display: grid;
  gap: 22px;
  padding: 42px;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 28px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 30px 80px rgb(62 31 94 / 16%);
  backdrop-filter: blur(18px);
}
.login-brand { display: flex; align-items: center; gap: 15px; }
.brand-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.login-heading { margin-top: 8px; }
.login-heading h1 { margin: 0 0 8px; font-size: clamp(30px, 6vw, 38px); letter-spacing: -.04em; }
.login-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.login-fields { display: grid; gap: 10px; }

label { display: grid; gap: 8px; color: var(--text); font-size: 13px; font-weight: 720; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfafd;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: #aaa5b4; }
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #d5cfdf; background: #fff; }
input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  background: #fff;
  box-shadow: 0 0 0 4px rgb(111 45 173 / 11%);
}

.primary-button, .save-button, .secondary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 780;
  transition: transform .16s, box-shadow .16s, opacity .16s;
}
.primary-button, .save-button {
  background: linear-gradient(135deg, var(--purple), #8c45c6);
  box-shadow: 0 9px 20px rgb(111 45 173 / 22%);
  color: #fff;
}
.primary-button:hover, .save-button:hover { transform: translateY(-1px); box-shadow: 0 12px 24px rgb(111 45 173 / 28%); }
.secondary-button { border: 1px solid #ddd5e8; background: #fff; color: var(--purple); }
.secondary-button:hover { border-color: #c5b4d9; background: var(--purple-soft); }
.full-button { width: 100%; }
.primary-button:disabled, .save-button:disabled { cursor: wait; opacity: .65; transform: none; }
.message { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; font-weight: 650; }
.login-message { text-align: center; }

.admin-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 4px 18px rgb(48 37 70 / 4%);
  backdrop-filter: blur(16px);
}
.topbar-brand { display: flex; align-items: center; gap: 11px; }
.topbar-brand > div:last-child { display: grid; gap: 1px; }
.topbar-brand strong { font-size: 15px; }
.topbar-brand span { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.admin-identity { display: flex; align-items: center; gap: 9px; margin-right: 4px; color: var(--text); font-size: 13px; }
.admin-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 850;
}
.ghost-button, .icon-button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 720;
}
.ghost-button:hover { border-color: #d7d0df; background: #faf8fc; }
.danger-ghost { color: var(--danger); }
.icon-button { width: 40px; padding: 0; font-size: 20px; }
.mobile-menu-button { display: none; }

.workspace { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 26px 16px 18px;
  border-right: 1px solid var(--border);
  background: #fff;
}
.sidebar-copy { display: grid; gap: 6px; padding: 0 12px 22px; }
.sidebar-copy span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.sidebar-copy strong { font-size: 17px; }
.sidebar-nav { display: grid; gap: 6px; }
.nav-button {
  position: relative;
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
}
.nav-button:hover { background: #f7f4fa; }
.nav-button.active { background: var(--purple-soft); color: var(--purple); }
.nav-button:disabled { cursor: default; color: #aaa5b1; }
.nav-icon { width: 23px; color: currentColor; font-size: 19px; text-align: center; }
.coming-soon {
  margin-left: auto;
  border-radius: 99px;
  padding: 3px 7px;
  background: #f0eef3;
  color: #918b9b;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px; color: var(--muted); font-size: 11px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.sidebar-backdrop { display: none; }

.content { min-width: 0; width: 100%; max-width: 1440px; padding: 42px clamp(24px, 4vw, 58px) 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 6px 0 8px; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.045em; line-height: 1.05; }
.page-heading p, .section-heading p { margin: 0; color: var(--muted); line-height: 1.5; }
.page-eyebrow { color: var(--green-dark); }
.back-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--purple);
  font-weight: 760;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.search-field { position: relative; width: min(100%, 430px); }
.search-field span { position: absolute; z-index: 1; left: 15px; top: 50%; color: var(--muted); font-size: 21px; transform: translateY(-54%); }
.search-field input { padding-left: 44px; background: #fff; }
.result-count { color: var(--muted); font-size: 13px; }

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 15px 18px; border-bottom: 1px solid var(--border); background: #faf9fc; color: var(--muted); text-align: left; font-size: 10px; letter-spacing: .08em; }
td { padding: 17px 18px; border-bottom: 1px solid #efedf2; color: var(--text); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #fbf9fd; }
tbody tr:last-child td { border-bottom: 0; }
.company-link { border: 0; padding: 0; background: transparent; color: var(--ink); font-weight: 790; text-align: left; }
.company-link:hover { color: var(--purple); }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 99px;
  padding: 6px 10px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 780;
}
.status-badge.inactive { background: #fff0f2; color: var(--danger); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.row-arrow { color: #aaa5b2; font-size: 18px; }
.empty-state { display: grid; place-items: center; gap: 8px; padding: 70px 24px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 16px; }
.empty-state span { font-size: 13px; }
.empty-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 16px; background: var(--purple-soft); color: var(--purple); font-size: 24px; }

.form-section {
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
}
.simple-heading { justify-content: flex-start; }
.section-heading-copy { display: flex; align-items: center; gap: 14px; }
.section-icon {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 12px;
  font-weight: 850;
}
.section-heading h2 { margin: 0 0 4px; font-size: 17px; }
.section-heading p { font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 20px 24px; padding: 26px; }
.wide-field { grid-column: 1 / -1; }
.required { color: var(--danger); }
.checkbox-field { grid-template-columns: auto 1fr; align-items: center; }
.toggle-field { position: relative; display: flex; grid-column: 1 / -1; gap: 12px; width: fit-content; cursor: pointer; }
.toggle-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-control { position: relative; width: 44px; height: 25px; flex: 0 0 auto; border-radius: 99px; background: #d8d4de; transition: background .2s; }
.toggle-control::after { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgb(0 0 0 / 18%); content: ""; transition: transform .2s; }
.toggle-field input:checked + .toggle-control { background: var(--green); }
.toggle-field input:checked + .toggle-control::after { transform: translateX(19px); }
.toggle-field > span:last-child { display: grid; gap: 3px; }
.toggle-field small { color: var(--muted); font-weight: 500; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 14px; padding: 22px; }
.stat-grid article { min-height: 132px; display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--border); border-radius: 15px; padding: 18px; background: #fbfafd; }
.stat-grid article.accent-stat { border-color: #cfeedd; background: var(--green-soft); }
.stat-grid span, .group-info span { color: var(--muted); font-size: 11px; font-weight: 730; text-transform: uppercase; letter-spacing: .06em; }
.stat-grid strong, .group-info strong { margin: 7px 0 3px; color: var(--ink); font-size: 28px; letter-spacing: -.04em; }
.stat-grid small { color: var(--muted); font-size: 11px; }

.groups-container { display: grid; gap: 16px; padding: 22px; }
.group-card { overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: #fcfbfd; }
.group-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); background: #faf8fc; }
.group-heading h3 { margin: 3px 0 0; font-size: 16px; }
.group-label { color: var(--purple); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.remove-group { border: 0; border-radius: 9px; padding: 8px 10px; background: #fff0f2; color: var(--danger); font-size: 11px; font-weight: 750; }
.group-info { align-self: end; min-height: 72px; display: grid; align-content: center; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; background: #fff; }
.group-info strong { font-size: 21px; }
.form-actions {
  position: sticky;
  z-index: 10;
  bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 24px;
  border: 1px solid rgb(232 229 238 / 85%);
  border-radius: 16px;
  padding: 13px 15px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 14px 40px rgb(48 30 74 / 14%);
  backdrop-filter: blur(16px);
}
.form-actions .message { margin-right: auto; }
.save-button { min-width: 160px; }

.modal-dialog { width: min(calc(100% - 28px), 500px); padding: 0; border: 0; border-radius: 22px; background: transparent; color: var(--ink); box-shadow: 0 30px 90px rgb(32 20 50 / 35%); }
.modal-dialog::backdrop { background: rgb(25 17 38 / 58%); backdrop-filter: blur(5px); }
.modal-card { display: grid; gap: 17px; padding: 30px; border-radius: 22px; background: #fff; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 4px; }
.modal-heading .brand { margin: 0 0 7px; color: var(--purple); font-size: 11px; font-weight: 850; letter-spacing: .1em; }
.modal-heading h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.modal-close { width: 38px; height: 38px; border: 0; border-radius: 11px; background: #f4f1f7; color: var(--text); font-size: 27px; line-height: 1; }
.password-help { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; }
.modal-actions .save-button { min-width: 170px; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-identity span:last-child { display: none; }
}

@media (max-width: 780px) {
  .topbar { height: 64px; padding: 0 14px; }
  .workspace { min-height: calc(100vh - 64px); display: block; }
  .mobile-menu-button { display: inline-grid; }
  .topbar-brand .brand-mark, .topbar-brand > div:last-child { display: none; }
  .top-actions { gap: 7px; }
  .admin-identity { display: none; }
  .ghost-button { min-height: 36px; padding: 7px 9px; font-size: 10px; }
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: min(82vw, 310px);
    height: 100vh;
    padding-top: 28px;
    box-shadow: 18px 0 50px rgb(30 21 45 / 20%);
    transform: translateX(-105%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    display: block;
    border: 0;
    background: rgb(27 20 38 / 45%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .content { padding: 28px 16px 90px; }
  .page-heading { align-items: stretch; flex-direction: column; margin-bottom: 22px; }
  .page-heading .primary-button { width: 100%; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .result-count { padding-left: 3px; }
  .table-wrap { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 11px 16px; border: 1px solid var(--border); border-radius: 16px; padding: 17px; background: #fff; box-shadow: var(--shadow); }
  tbody tr:hover { background: #fff; }
  td { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; padding: 0; font-size: 13px; }
  td::before { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; }
  td:nth-child(1) { grid-column: 1 / -1; }
  td:nth-child(1) .company-link { font-size: 17px; }
  td:nth-child(2) { grid-column: 1 / -1; }
  td:nth-child(3)::before { content: "START"; }
  td:nth-child(4)::before { content: "SLUTT"; }
  td:nth-child(5)::before { content: "TILGANGER"; }
  td:nth-child(6)::before { content: "AKTIVE"; }
  td:nth-child(7) { display: none; }
  .form-grid { grid-template-columns: 1fr; gap: 17px; padding: 20px; }
  .wide-field, .toggle-field { grid-column: auto; }
  .section-heading { align-items: stretch; flex-direction: column; padding: 19px 20px; }
  .simple-heading, .section-heading-copy { align-items: center; flex-direction: row; }
  .section-heading .secondary-button { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); padding: 16px; gap: 10px; }
  .stat-grid article { min-height: 118px; padding: 14px; }
  .stat-grid strong { font-size: 24px; }
  .groups-container { padding: 15px; }
  .group-heading { padding: 14px; }
  .form-actions { bottom: 10px; align-items: stretch; flex-direction: column; }
  .form-actions .save-button { width: 100%; }
  .form-actions .message { margin: 0; text-align: center; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

@media (max-width: 440px) {
  .login-card { gap: 18px; padding: 28px 22px; border-radius: 22px; }
  .login-brand .brand-mark { width: 45px; height: 45px; border-radius: 14px; }
  .top-actions #changePasswordButton { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid article { min-height: 108px; }
  .stat-grid span { font-size: 9px; }
  .stat-grid strong { font-size: 22px; }
}
