:root {
  --panel: rgba(20, 39, 64, .88);
  --panel-soft: rgba(13, 29, 49, .80);
  --border: rgba(255,255,255,.08);
  --text: #f4f7fb;
  --muted: rgba(230,238,250,.68);
  --accent: #49f2d6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  color: var(--text);
}

body {
  min-height: 100vh;
  padding: 30px 16px;
  display: grid;
  place-items: center;

  background:
    linear-gradient(rgba(4,10,18,.48), rgba(4,10,18,.66)),
    url("/static/dashboard-bg.png") center/cover fixed no-repeat;
}

.login-shell {
  width: min(440px, calc(100% - 32px));
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.login-logo img {
  width: 500px;
  height: 500px;
  object-fit: contain;
  display: flex;
  justify-conten: center;
  margin-bottom: 20px;
  margin: 0 auto 28px auto;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.35));
}

.login-card {
  padding: 32px;
  border-radius: 26px;

  background:
    linear-gradient(
      145deg,
      var(--panel),
      var(--panel-soft)
    );

  border: 1px solid var(--border);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  box-shadow: 0 22px 60px rgba(0,0,0,.35);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.login-subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--muted);
}

.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 14px;

  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
  outline: none;

  background: rgba(255,255,255,.045);
  color: white;

  font-size: 15px;

  transition:
    border-color .18s ease,
    background .18s ease,
    box-shadow .18s ease;
}

.form-group input:focus {
  border-color: rgba(73,242,214,.45);
  background: rgba(255,255,255,.065);
  box-shadow: 0 0 0 3px rgba(73,242,214,.07);
}

.login-button {
  width: 100%;
  height: 50px;
  margin-top: 6px;

  border: 0;
  border-radius: 14px;

  cursor: pointer;

  background: linear-gradient(
    135deg,
    #49f2d6,
    #66d7ff
  );

  color: #07111d;

  font-size: 15px;
  font-weight: 700;

  transition:
    transform .18s ease,
    filter .18s ease;
}

.login-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.error {
  margin-bottom: 18px;
  padding: 11px 13px;

  border-radius: 12px;

  color: #ffb6bd;
  background: rgba(255,85,101,.10);
  border: 1px solid rgba(255,85,101,.18);

  font-size: 13px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,.38);
}

/* ===== LOGIN POSITIONING ===== */

body {
  min-height: 100vh;
  display: block;
  padding: 0 16px 40px;
}

.login-shell {
  width: min(440px, calc(100% - 32px));
  margin: 0 auto;
  transform: none !important;
}

.login-logo {
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.login-logo img {
  width: 500px;
  height: 500px;
  object-fit: contain;
}

/* Alleen het loginblok omhoog */
.login-card {
  position: relative;
  margin-top: -125px;
}

/* ===== USER PORTAL ===== */

.portal-body {
  min-height: 100vh;
  display: block;

  background:
    linear-gradient(rgba(4,10,18,.48), rgba(4,10,18,.68)),
    url("/static/dashboard-bg.png") center/cover fixed no-repeat;
}

.portal-shell {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 60px;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;

  margin-bottom: 48px;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.portal-brand img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.portal-brand h1 {
  margin: 0;
  font-size: 30px;
}

.portal-brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.portal-actions {
  display: flex;
  gap: 10px;
}

.portal-link {
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 11px 14px;

  border-radius: 12px;

  color: var(--text);
  text-decoration: none;

  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
}

.portal-link svg {
  width: 17px;
}

.portal-link.danger {
  color: #ff9aa4;
}

.portal-intro {
  margin-bottom: 20px;
}

.portal-intro h2 {
  margin: 0;
  font-size: 26px;
}

.portal-intro p {
  color: var(--muted);
  margin-top: 6px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.device-card {
  min-height: 310px;

  padding: 24px;

  display: flex;
  flex-direction: column;

  border-radius: 24px;

  background:
    linear-gradient(
      145deg,
      rgba(20,39,64,.90),
      rgba(13,29,49,.82)
    );

  border: 1px solid var(--border);

  box-shadow: 0 18px 48px rgba(0,0,0,.25);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.device-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.device-icon {
  width: 64px;
  height: 64px;

  display: grid;
  place-items: center;

  border-radius: 18px;

  background: rgba(255,255,255,.055);
}

.device-icon svg {
  width: 32px;
  height: 32px;
}

.device-status {
  padding: 5px 10px;

  border-radius: 999px;

  color: var(--muted);
  background: rgba(255,255,255,.06);

  font-size: 12px;
  font-weight: 700;
}

.device-status.active {
  background: rgba(73,242,214,.14);
  color: #64f2cf;
}

.device-info {
  margin-top: 30px;
}

.device-info h3 {
  margin: 0;
  font-size: 23px;
}

.device-info p {
  margin: 8px 0 0;
  color: var(--muted);
}

.device-actions {
  margin-top: auto;

  display: flex;
  flex-wrap: wrap;

  gap: 9px;
}

.device-actions form {
  margin: 0;
}

.device-button {
  min-height: 42px;

  padding: 0 14px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  border: 0;
  border-radius: 12px;

  cursor: pointer;

  text-decoration: none;

  font-size: 13px;
  font-weight: 700;
}

.device-button svg {
  width: 16px;
  height: 16px;
}

.device-button.primary {
  width: 100%;

  color: #07111d;

  background: linear-gradient(
    135deg,
    #49f2d6,
    #66d7ff
  );
}

.device-button.secondary {
  color: var(--text);
  background: rgba(255,255,255,.07);
}

.device-button.danger {
  color: #ff9aa4;
  background: rgba(255,80,95,.10);
}

.portal-help {
  margin-top: 24px;
  padding: 18px 20px;

  display: flex;
  gap: 14px;
  align-items: flex-start;

  border-radius: 18px;

  background: rgba(20,39,64,.60);
  border: 1px solid var(--border);
}

.portal-help svg {
  width: 22px;
  flex-shrink: 0;
}

.portal-help strong {
  display: block;
}

.portal-help p {
  margin: 4px 0 0;
  color: var(--muted);
}

@media (max-width: 850px) {
  .device-grid {
    grid-template-columns: 1fr;
  }

  .portal-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* =========================================
   WireGuard QR modal
   ========================================= */

body.modal-open {
    overflow: hidden;
}

.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.qr-modal.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.qr-modal-backdrop {
    position: absolute;
    inset: 0;

    background: rgba(2, 8, 15, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.qr-modal-card {
    position: relative;
    z-index: 1;

    width: min(650px, 100%);
    padding: 28px;

    background:
        linear-gradient(
            145deg,
            rgba(20, 45, 73, 0.98),
            rgba(10, 27, 45, 0.98)
        );

    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;

    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);

    transform: translateY(12px) scale(0.98);

    transition:
        transform 0.2s ease;
}

.qr-modal.open .qr-modal-card {
    transform: translateY(0) scale(1);
}

.qr-modal-close {
    position: absolute;
    top: 18px;
    right: 20px;

    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.07);

    color: #dfe9f4;
    font-size: 26px;
    line-height: 1;

    cursor: pointer;
}

.qr-modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.qr-modal-header {
    display: flex;
    align-items: center;
    gap: 14px;

    padding-right: 45px;
    margin-bottom: 24px;
}

.qr-modal-icon {
    width: 50px;
    height: 50px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 15px;

    background: rgba(73, 225, 225, 0.12);
    color: #58e6e1;

    font-size: 26px;
}

.qr-modal-header h2 {
    margin: 0 0 4px;

    color: #ffffff;
    font-size: 22px;
}

.qr-modal-header p {
    margin: 0;

    color: #aab9ca;
    font-size: 14px;
}

.qr-code-box {
    display: flex;
    align-items: center;
    justify-content: center;
    
    width: 550px;
    height: 550px;
    margin: 0 auto;

    padding: 18px;

    background: #ffffff;
    border-radius: 22px;
}

.qr-code-box img {
    display: block;

    width: 500px;
    height: 500px;
    max-width: 100%;
    
    object-fit: contain;
}

.qr-modal-help {
    margin: 20px 4px 22px;

    color: #aebccd;
    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}

.qr-modal-help strong {
    color: #ffffff;
}

.qr-done-btn {
    width: 100%;

    padding: 13px 18px;

    border: 0;
    border-radius: 14px;

    background: linear-gradient(
        135deg,
        #45e0da,
        #5ed7f4
    );

    color: #071521;
    font-weight: 700;
    font-size: 15px;

    cursor: pointer;
}

.qr-done-btn:hover {
    filter: brightness(1.07);
}

/* =========================================
   ADMIN
   ========================================= */

.admin-create-card,
.admin-user-card,
.admin-wg-card {
    background: rgba(12, 31, 51, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.20);
}

.admin-create-card {
    padding: 24px;
    margin-bottom: 34px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.admin-create-card h2,
.admin-section-title h2 {
    margin: 0 0 6px;
    color: #fff;
}

.admin-create-card p,
.admin-section-title p {
    margin: 0;
    color: #9eafc1;
}

.admin-create-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-create-form input {
    min-width: 190px;

    padding: 12px 14px;

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;

    background: rgba(255, 255, 255, 0.06);

    color: #fff;
    outline: none;
}

.admin-create-form input::placeholder {
    color: #8393a4;
}

.admin-create-form input:focus {
    border-color: rgba(80, 224, 219, 0.65);
}

.admin-create-form button {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 12px 18px;

    border: 0;
    border-radius: 12px;

    background: linear-gradient(
        135deg,
        #46dfd9,
        #5fd7f4
    );

    color: #071521;
    font-weight: 700;

    cursor: pointer;
}

.admin-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 16px;
}

.admin-section-title.compact {
    margin: 0;
    padding: 22px 24px 12px;
}

.admin-wg-status {
    display: flex;
    align-items: center;
    gap: 8px;

    color: #a9b8c7;
    font-size: 14px;
}

.status-dot {
    display: inline-block;

    width: 8px;
    height: 8px;

    border-radius: 50%;
}

.status-dot.online {
    background: #4ee0a1;
    box-shadow: 0 0 12px rgba(78, 224, 161, 0.7);
}

.admin-users {
    display: grid;
    gap: 18px;

    margin-bottom: 32px;
}

.admin-user-card {
    overflow: hidden;
}

.admin-user-header {
    padding: 20px 22px;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.06);
}

.admin-user-identity {
    display: flex;
    align-items: center;
    gap: 14px;
}

.admin-user-avatar {
    width: 44px;
    height: 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 14px;

    background:
        rgba(74, 221, 218, 0.12);

    color: #58e5e0;

    font-size: 19px;
    font-weight: 800;
}

.admin-user-identity h3 {
    margin: 0 0 4px;

    color: #fff;
    font-size: 18px;
}

.admin-role,
.user-role {
    font-size: 12px;
    color: #8fa1b3;
}

.admin-device-list {
    display: grid;
}

.admin-device-row {
    min-height: 72px;

    padding: 14px 22px;

    display: grid;
    grid-template-columns:
        minmax(220px, 1fr)
        150px
        150px;

    align-items: center;
    gap: 18px;

    border-bottom:
        1px solid rgba(255, 255, 255, 0.05);
}

.admin-device-row:last-child {
    border-bottom: 0;
}

.admin-device-name {
    display: flex;
    align-items: center;
    gap: 13px;
}

.admin-device-name > svg {
    width: 22px;
    color: #5ed7f4;
}

.admin-device-name strong {
    display: block;

    color: #fff;
    font-size: 14px;
}

.admin-device-name span {
    display: block;

    margin-top: 3px;

    color: #8395a7;
    font-size: 12px;
}

.admin-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    font-size: 13px;
}

.admin-state.active {
    color: #8ff0c3;
}

.admin-state.free {
    color: #8293a4;
}

.admin-device-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.admin-action {
    width: 38px;
    height: 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: rgba(255, 255, 255, 0.06);

    color: #c7d4e1;
}

.admin-action:hover {
    background: rgba(255, 255, 255, 0.11);
}

.admin-action svg {
    width: 18px;
}

.admin-muted {
    color: #7f90a2;
    font-size: 13px;
}

.admin-wg-card {
    overflow: hidden;
}

.admin-wg-list {
    display: grid;
}

.admin-wg-row {
    padding: 15px 24px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-top:
        1px solid rgba(255, 255, 255, 0.05);
}

.admin-wg-row strong {
    display: block;

    color: #fff;
    font-size: 14px;
}

.admin-wg-row span {
    color: #8395a7;
    font-size: 11px;
}

@media (max-width: 850px) {

    .admin-create-card {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-create-form {
        flex-direction: column;
    }

    .admin-create-form input {
        width: 100%;
    }

    .admin-device-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .admin-device-actions {
        justify-content: flex-start;
    }
}


