:root {
  --bg:#04040f;
  --bg-card:#0b0d16;
  --bg-hover:#141927;
  --accent:#2f7be0;
  --accent-dim:#1a4f9c;
  --active:#12407f;
  --silver:#c7ccd4;
  --border:#22293a;
  --text:#e8e8f0;
  --muted:#a2a9b6;
  --success:#00e676;
  --warning:#ff9800;
  --error:#ff4655;
  --surface:rgba(10,13,24,0.78);
  --surface-strong:rgba(10,13,24,0.92);
  --surface-soft:rgba(9,12,21,0.62);
  --radius:8px;
  --radius-lg:8px;
  --shadow:0 24px 70px rgba(0,0,0,0.42);
  --depth-shadow:0 16px 34px rgba(0,0,0,0.34), 0 1px 0 rgba(255,255,255,0.04) inset;
  --focus:0 0 0 3px rgba(47,123,224,0.25);
}

* { box-sizing:border-box; }
html { min-height:100%; }
body {
  margin:0;
  min-height:100vh;
  font-family:"Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color:var(--text);
  background:
    linear-gradient(180deg, rgba(3,5,11,0.98), rgba(6,8,17,1) 46%, rgba(3,5,11,1));
  font-size:15px;
  line-height:1.5;
}

a { color:inherit; text-decoration:none; }
a:hover { color:var(--accent); }
:focus-visible { outline:0; box-shadow:var(--focus); }

.layout { display:flex; min-height:100vh; }
.sidebar {
  position:fixed;
  inset:0 auto 0 0;
  z-index:120;
  width:244px;
  padding:22px 18px;
  background:rgba(5,7,14,0.92);
  border-right:1px solid var(--border);
  backdrop-filter:blur(18px);
  display:flex;
  flex-direction:column;
  gap:24px;
}
.brand { display:block; margin:0; }
.mobile-brand img,
.brand img {
  display:block;
  width:auto;
  max-width:200px;
  object-fit:contain;
  border-radius:4px;
}
.mobile-brand img { height:34px; max-width:180px; }
.brand img { height:58px; }
.nav { display:grid; gap:6px; }
.nav a {
  min-height:44px;
  display:flex;
  align-items:center;
  padding:10px 12px;
  border:1px solid transparent;
  border-radius:var(--radius);
  color:var(--muted);
  font-weight:600;
  font-size:0.94rem;
  transition:background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.nav a:hover {
  background:var(--bg-hover);
  color:var(--text);
  border-color:var(--border);
  transform:translateX(3px);
}
.nav a.active {
  background:rgba(18,64,127,0.42);
  color:var(--accent);
  border-color:rgba(47,123,224,0.36);
}
.sidebar-footer {
  margin-top:auto;
  display:grid;
  gap:9px;
}
.sidebar-user {
  color:var(--muted);
  font-size:0.78rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.logout-link {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:9px 12px;
  border-radius:var(--radius);
  border:1px solid var(--border);
  color:var(--muted);
  font-size:0.88rem;
  font-weight:600;
  transition:background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.logout-link:hover { background:rgba(255,70,85,0.08); color:var(--error); border-color:rgba(255,70,85,0.34); }

.mobile-header { display:none; }
.nav-toggle {
  position:absolute;
  width:1px;
  height:1px;
  opacity:0;
}
.nav-toggle:focus-visible + .mobile-header .nav-toggle-label { box-shadow:var(--focus); }
.nav-backdrop { display:none; }

.content {
  flex:1;
  min-width:0;
  margin-left:244px;
  padding:28px;
}
.page {
  width:100%;
  max-width:1680px;
  margin:0 auto;
  display:grid;
  gap:24px;
}
h1, h2, h3, p { margin-top:0; }
h1 { font-size:2.2rem; line-height:1.08; margin-bottom:0; }
.panel h2, .panel h3 { margin:0; }
.panel h2 { font-size:1.22rem; line-height:1.25; }
.panel h3 { font-size:1rem; line-height:1.3; }
.muted { color:var(--muted); }
.is-hidden { display:none !important; }
.section-heading { margin:0 0 8px; }
.section-copy { margin:0 0 18px; color:var(--muted); max-width:760px; }
.meta-line { margin:0; padding:0 4px; color:var(--muted); font-size:0.86rem; }
.error-text { color:var(--error); }

.page-hero {
  min-height:250px;
  display:grid;
  align-content:end;
  gap:10px;
  overflow:hidden;
  padding:34px;
  border:1px solid rgba(199,204,212,0.14);
  border-radius:var(--radius-lg);
  background-image:
    linear-gradient(90deg, rgba(3,5,11,0.94), rgba(3,5,11,0.62) 48%, rgba(3,5,11,0.28)),
    var(--hero-image);
  background-position:center;
  background-size:cover;
  box-shadow:var(--shadow);
  transform-style:preserve-3d;
}
.page-hero-dashboard { --hero-image:url("/app-static/img/pexels-brett-sayles-5408005.jpg"); }
.page-hero-domains { --hero-image:url("/app-static/img/pexels-cottonbro-6803525.jpg"); }
.page-hero-users { --hero-image:url("/app-static/img/pexels-shvetsa-4312862.jpg"); }
.page-hero-emails { --hero-image:url("/app-static/img/pexels-brett-sayles-5408005.jpg"); }
.page-hero-account { --hero-image:url("/app-static/img/pexels-cottonbro-6803525.jpg"); }
.page-hero h1 {
  max-width:760px;
  margin:0;
  color:#fff;
  font-size:3.35rem;
  font-weight:850;
  line-height:0.98;
  text-transform:uppercase;
  letter-spacing:0;
  text-shadow:0 12px 28px rgba(0,0,0,0.42);
}
.page-hero p {
  max-width:620px;
  margin:0;
  color:var(--silver);
  font-size:1.05rem;
}
.hero-kicker {
  color:var(--silver);
  font-size:0.8rem;
  font-weight:850;
  letter-spacing:0;
  text-transform:uppercase;
}

.panel {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px;
  box-shadow:var(--depth-shadow);
  backdrop-filter:blur(18px);
  transform-style:preserve-3d;
  transition:border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.panel:hover {
  border-color:rgba(47,123,224,0.32);
  box-shadow:var(--shadow);
  transform:perspective(900px) rotateX(0.5deg) rotateY(-0.5deg) translateY(-2px);
}
.sub-panel {
  padding:16px;
  background:rgba(7,10,22,0.48);
  box-shadow:none;
}
.panel-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:16px;
}
.stack { display:grid; gap:16px; }
.stack-tight { display:grid; gap:12px; }
.reveal-panel { margin-bottom:16px; }
.form-stack { margin-top:12px; }
.split { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:20px; align-items:start; }
.grid-2 { display:grid; grid-template-columns:minmax(0,2fr) minmax(320px,1fr); gap:24px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.table-wrap { width:100%; overflow-x:auto; border-radius:var(--radius); }

.flash, .banner, .error-banner, .message {
  padding:13px 15px;
  border-radius:var(--radius);
  border:1px solid transparent;
  font-size:0.92rem;
}
.flash.success, .banner.success {
  color:var(--success);
  background:rgba(0,230,118,0.09);
  border-color:rgba(0,230,118,0.28);
}
.flash.error, .banner.error, .error-banner {
  color:var(--error);
  background:rgba(255,70,85,0.10);
  border-color:rgba(255,70,85,0.30);
}
.flash.info, .banner.info, .message {
  color:var(--text);
  background:rgba(47,123,224,0.10);
  border-color:rgba(47,123,224,0.26);
}

table { width:100%; border-collapse:collapse; min-width:720px; }
th, td {
  padding:13px 12px;
  border-bottom:1px solid var(--border);
  text-align:left;
  vertical-align:top;
}
th {
  color:var(--muted);
  font-size:0.78rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0;
}
tbody tr { transition:background 0.15s ease; }
tbody tr:hover { background:rgba(19,19,40,0.56); }
.code-pill {
  display:inline-block;
  max-width:56rem;
  padding:4px 8px;
  border-radius:6px;
  background:rgba(0,0,0,0.28);
  border:1px solid rgba(255,255,255,0.05);
  color:var(--text);
  font-family:ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size:0.9rem;
  overflow-wrap:anywhere;
}

.badge {
  display:inline-flex;
  align-items:center;
  gap:6px;
  width:max-content;
  padding:5px 9px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:0.82rem;
  font-weight:700;
  white-space:nowrap;
  background:rgba(7,10,22,0.62);
}
.badge.success { color:var(--success); border-color:rgba(0,230,118,0.32); }
.badge.warning { color:var(--warning); border-color:rgba(255,152,0,0.34); }
.badge.error { color:var(--error); border-color:rgba(255,70,85,0.34); }
.badge.active { color:var(--accent); border-color:rgba(47,123,224,0.34); }
.badge.small { font-size:0.75rem; }

form { display:grid; gap:14px; }
label { display:grid; gap:7px; color:var(--text); font-size:0.92rem; font-weight:600; }
input, select, button, .button, .btn-primary, .btn-secondary, .ms-btn {
  border-radius:var(--radius);
  font:inherit;
}
input, select {
  width:100%;
  min-height:44px;
  padding:10px 12px;
  border:1px solid var(--border);
  background:rgba(7,10,22,0.95);
  color:var(--text);
  transition:border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input::placeholder { color:rgba(107,114,128,0.78); }
input:focus, select:focus { outline:0; border-color:rgba(47,123,224,0.60); box-shadow:var(--focus); }
input[readonly], input:disabled, select:disabled {
  color:var(--muted);
  opacity:0.78;
  cursor:not-allowed;
}

button, .button, .btn-primary, .btn-secondary, .ms-btn {
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  width:auto;
  padding:10px 16px;
  border:1px solid transparent;
  background:linear-gradient(135deg, var(--active), var(--accent-dim));
  color:var(--text);
  font-weight:700;
  cursor:pointer;
  text-decoration:none;
  box-shadow:0 10px 22px rgba(0,0,0,0.22);
  transform-style:preserve-3d;
  transition:background 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease, opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
button:hover, .button:hover, .btn-primary:hover {
  color:var(--text);
  filter:brightness(1.08);
  box-shadow:0 16px 30px rgba(0,0,0,0.32);
  transform:perspective(700px) rotateX(1deg) rotateY(-1deg) translateY(-1px);
}
button.secondary, .button.secondary, .btn-secondary {
  background:transparent;
  border-color:var(--border);
  color:var(--text);
}
button.secondary:hover, .button.secondary:hover, .btn-secondary:hover {
  background:rgba(47,123,224,0.09);
  border-color:rgba(47,123,224,0.34);
  color:var(--accent);
  filter:none;
}
.button.ghost, button.ghost { background:transparent; border-color:transparent; color:var(--muted); }
.button.outline, button.outline { background:transparent; border-color:rgba(47,123,224,0.40); color:var(--accent); }
.button.destructive, button.destructive { background:rgba(255,70,85,0.12); border-color:rgba(255,70,85,0.34); color:var(--error); }
button:disabled, .button[aria-disabled="true"] { opacity:0.55; cursor:not-allowed; filter:none; }
.actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.actions a { display:inline-flex; }
.compact-button { min-height:36px; padding:7px 12px; font-size:0.86rem; }

details {
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:11px 13px;
  background:rgba(7,10,22,0.70);
}
summary { cursor:pointer; color:var(--accent); font-weight:700; }

.stat-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:18px; }
.stat-card { padding:22px; display:grid; gap:8px; align-content:start; text-align:left; min-height:150px; }
.stat-icon {
  width:42px;
  height:30px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  border:1px solid rgba(47,123,224,0.28);
  background:rgba(47,123,224,0.10);
  color:var(--accent);
  font-size:0.72rem;
  font-weight:800;
  letter-spacing:0;
}
.stat-number {
  min-height:3rem;
  display:flex;
  align-items:center;
  color:var(--accent);
  font-size:3rem;
  font-weight:800;
  line-height:1;
}
.stat-label { color:var(--muted); font-size:0.9rem; font-weight:700; }
.spinner-inline, .spinner {
  display:inline-block;
  width:20px;
  height:20px;
  border:2px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin 0.8s linear infinite;
}
.spinner-wrap { display:flex; align-items:center; gap:10px; padding:18px 4px; color:var(--muted); }
@keyframes spin { to { transform:rotate(360deg); } }

.scroll-panel {
  max-height:60vh;
  overflow:auto;
  scrollbar-width:thin;
  scrollbar-color:#28476e transparent;
}
.domain-card, .user-card, .mailbox-card {
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:rgba(13,13,31,0.84);
  transition:border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.domain-card {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  margin-bottom:8px;
}
.domain-card:hover, .user-card:hover, .mailbox-card:hover {
  background:rgba(17,22,34,0.82);
  border-color:rgba(47,123,224,0.30);
}
.domain-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.domain-dot.success { background:var(--success); }
.domain-dot.warning { background:var(--warning); }
.domain-name { flex:1; min-width:0; font-weight:700; overflow-wrap:anywhere; }
.domain-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.domain-actions form { margin:0; display:inline-flex; }
.help-box { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }
.help-box p { margin:0; color:var(--muted); font-size:0.88rem; }

.user-card {
  display:flex;
  align-items:flex-start;
  gap:14px;
  padding:14px 16px;
  margin-bottom:8px;
  cursor:pointer;
}
.user-card.selected { border-color:var(--accent); background:rgba(47,123,224,0.09); box-shadow:0 0 0 1px rgba(47,123,224,0.16); }
.avatar {
  width:40px;
  height:40px;
  border-radius:50%;
  background:rgba(18,64,127,0.92);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  color:#fff;
  flex-shrink:0;
  letter-spacing:0;
}
.user-info { flex:1; min-width:0; }
.user-name { font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-upn, .user-lic, .user-badge { color:var(--muted); font-size:0.83rem; overflow:hidden; text-overflow:ellipsis; }
.user-upn { white-space:nowrap; }
.user-lic { margin-top:4px; }
.user-actions { display:flex; flex-direction:column; align-items:flex-end; gap:6px; flex-shrink:0; }
.domain-tag {
  display:inline-flex;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  background:rgba(18,64,127,0.16);
  font-size:0.76rem;
  font-weight:700;
  white-space:nowrap;
}
.btn-alias, .btn-dots {
  min-height:32px !important;
  width:auto !important;
  padding:4px 10px !important;
  border-radius:7px !important;
  background:transparent !important;
  border:1px solid var(--border) !important;
  color:var(--muted) !important;
  font-size:0.78rem !important;
  white-space:nowrap;
}
.btn-alias:hover, .btn-dots:hover { border-color:rgba(47,123,224,0.36) !important; color:var(--accent) !important; }
.btn-dots { font-size:1rem !important; line-height:1; }

.mailbox-card { padding:14px 16px; margin-bottom:8px; }
.mailbox-card.highlighted { border-color:var(--accent); background:rgba(47,123,224,0.08); }
.mailbox-header { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; margin-bottom:6px; }
.mailbox-title { font-weight:700; margin-bottom:3px; }
.mailbox-email, .mailbox-email-link { color:var(--muted); font-size:0.86rem; overflow-wrap:anywhere; }
.mailbox-email-link { color:var(--accent); }
.mailbox-users-label {
  margin-top:9px;
  margin-bottom:3px;
  color:var(--muted);
  font-size:0.74rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:0;
}
.mailbox-users { color:var(--muted); font-size:0.82rem; overflow-wrap:anywhere; }
.inline-field { display:flex; gap:6px; align-items:center; }
.inline-field > input, .inline-field > select { flex:1; min-width:0; }
.inline-separator { color:var(--muted); font-size:1rem; }
.alias-panel {
  position:fixed;
  z-index:400;
  min-width:340px;
  max-width:min(440px, calc(100vw - 16px));
  padding:18px;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:var(--bg-card);
  box-shadow:0 16px 44px rgba(0,0,0,0.52);
}
.alias-panel input, .alias-panel select { min-height:38px; padding:8px 10px; font-size:0.88rem; }
.alias-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.alias-title { font-weight:700; font-size:0.95rem; }
.alias-divider { margin-top:14px; border-top:1px solid var(--border); padding-top:12px; }
.alias-addr { display:flex; align-items:center; gap:8px; margin-bottom:6px; font:0.84rem ui-monospace, SFMono-Regular, Consolas, monospace; }
.alias-primary { color:var(--accent); }
.alias-secondary { color:var(--muted); }
.alias-badge { color:var(--muted); font:0.72rem "Segoe UI", system-ui, sans-serif; }
.inline-form { display:grid; gap:8px; margin-top:6px; }
.inline-form label { font-size:0.88rem; }
.inline-form button { font-size:0.88rem; padding:8px 14px; }
.inline-form input, .inline-form select { padding:8px 10px; }
.inline-note { color:var(--muted); font-size:0.88rem; margin:0; }
.inline-error { color:var(--error); font-size:0.88rem; margin:0; }
.perm-form { display:none; margin-top:12px; }
.page-emails .content { display:flex; flex-direction:column; }
.page-emails .page { flex:1; min-height:0; display:flex; flex-direction:column; }
.page-emails .split { flex:1; align-items:stretch; min-height:0; }
.page-emails .split > .panel { display:flex; flex-direction:column; min-height:0; }
.page-emails #user-list { flex:1; max-height:none; }
.page-emails #mailbox-container { flex:1; min-height:0; overflow-y:auto; scrollbar-width:thin; scrollbar-color:#28476e transparent; }
.page-emails #mailbox-container .scroll-panel { max-height:none; overflow:visible; }

.qr-box {
  width:180px;
  height:180px;
  border:1px solid var(--border);
  background:#fff;
  padding:10px;
  border-radius:var(--radius);
}

.portal-page {
  min-height:100vh;
  background:
    linear-gradient(90deg, rgba(3,5,11,0.94), rgba(3,5,11,0.70) 52%, rgba(3,5,11,0.30)),
    url("/app-static/img/pexels-fauxels-3184359.jpg") center/cover fixed;
}
.portal-shell {
  position:relative;
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:32px;
  perspective:1200px;
}
.portal-top-left {
  position:absolute;
  top:32px;
  left:32px;
  z-index:3;
  display:grid;
  gap:14px;
  justify-items:start;
}
.portal-logo img {
  display:block;
  height:64px;
  max-width:240px;
  border-radius:4px;
  object-fit:contain;
  box-shadow:0 14px 34px rgba(0,0,0,0.36);
}
.portal-ms-connect {
  min-width:216px;
  justify-content:flex-start;
  background:rgba(10,13,24,0.76);
  border-color:rgba(199,204,212,0.22);
  backdrop-filter:blur(14px);
}
.portal-menu {
  position:absolute;
  top:32px;
  right:32px;
  z-index:5;
  display:flex;
  align-items:flex-start;
  gap:12px;
}
.settings-menu {
  position:relative;
  padding:0;
  border:0;
  background:transparent;
}
.settings-menu summary {
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 16px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:rgba(10,13,24,0.76);
  color:var(--text);
  box-shadow:0 10px 22px rgba(0,0,0,0.22);
  backdrop-filter:blur(14px);
  list-style:none;
}
.settings-menu summary::-webkit-details-marker { display:none; }
.settings-menu-panel {
  position:absolute;
  top:52px;
  right:0;
  min-width:210px;
  display:grid;
  gap:4px;
  padding:8px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--surface-strong);
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px);
}
.settings-menu-panel a {
  padding:10px 12px;
  border-radius:6px;
  color:var(--muted);
  font-weight:700;
}
.settings-menu-panel a:hover {
  background:rgba(47,123,224,0.12);
  color:var(--text);
}
.portal-logout {
  background:rgba(10,13,24,0.76);
  backdrop-filter:blur(14px);
}
.portal-center {
  width:min(100%, 760px);
  display:grid;
  gap:24px;
  justify-items:center;
  text-align:center;
}
.portal-copy h1 {
  margin:0;
  color:#fff;
  font-size:4rem;
  line-height:0.95;
  text-transform:uppercase;
  letter-spacing:0;
  text-shadow:0 16px 38px rgba(0,0,0,0.48);
}
.subscription-card {
  width:min(100%, 520px);
  display:grid;
  gap:12px;
  padding:30px;
  text-align:left;
  background:rgba(10,13,24,0.70);
  transform:perspective(1000px) rotateX(2deg) translateZ(0);
}
.subscription-card:hover {
  transform:perspective(1000px) rotateX(0.5deg) rotateY(-1deg) translateY(-4px);
}
.subscription-topline {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--silver);
  font-weight:800;
  text-transform:uppercase;
}
.subscription-plan {
  color:#fff;
  font-size:2.1rem;
  font-weight:850;
  line-height:1;
  text-transform:uppercase;
}
.subscription-status {
  color:var(--muted);
  font-weight:700;
}
.subscription-time {
  display:grid;
  gap:4px;
  color:var(--accent);
  font-size:1.5rem;
  font-weight:850;
}
.subscription-time span {
  color:var(--silver);
  font-size:0.9rem;
  font-weight:700;
}

.auth-page {
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    linear-gradient(90deg, rgba(3,5,11,0.94), rgba(3,5,11,0.72) 54%, rgba(3,5,11,0.36)),
    url("/app-static/img/pexels-fauxels-3184359.jpg") center/cover fixed;
}
.auth-shell {
  width:min(100%, 920px);
  display:grid;
  grid-template-columns:minmax(280px, 0.9fr) minmax(320px, 420px);
  gap:22px;
  align-items:stretch;
  perspective:1100px;
}
.auth-aside {
  display:grid;
  align-content:space-between;
  min-height:430px;
  padding:32px;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  overflow:hidden;
  background:
    linear-gradient(180deg, rgba(3,5,11,0.38), rgba(3,5,11,0.92)),
    url("/app-static/img/pexels-fauxels-3184359.jpg") center/cover;
  box-shadow:var(--shadow);
  transform:perspective(1000px) rotateY(1deg);
}
.auth-aside img { height:48px; width:auto; max-width:220px; border-radius:4px; }
.auth-copy { align-self:end; max-width:28rem; }
.auth-copy h1 {
  margin:0 0 10px;
  color:#fff;
  font-size:2rem;
  line-height:1.02;
  text-transform:uppercase;
  letter-spacing:0;
}
.auth-copy p { margin:0; color:var(--silver); }
.box {
  width:100%;
  max-width:420px;
  padding:38px 34px;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:rgba(10,13,24,0.78);
  box-shadow:var(--shadow);
  text-align:center;
}
.auth-shell .box { max-width:none; }
.logo { height:38px; margin:0 auto 10px; display:block; max-width:210px; }
.sub { color:var(--muted); font-size:0.92rem; margin:0 0 28px; }
.box form { gap:12px; text-align:left; }
.box .btn-primary, .box .btn-secondary, .box .ms-btn { width:100%; }
.btn-primary { background:var(--accent); color:var(--bg); }
.btn-primary:hover { color:var(--bg); }
.divider { color:var(--muted); font-size:0.82rem; margin:22px 0 12px; }
.link { color:var(--accent); font-size:0.9rem; font-weight:700; }
.links, .forgot { margin-top:16px; }
.ms-btn {
  background:#2f2f2f;
  border-color:#444;
  color:#fff;
}
.ms-btn:hover { background:#3a3a3a; color:#fff; filter:none; }
.ms-logo { width:20px; height:20px; flex-shrink:0; }
.role { color:var(--muted); font-size:0.84rem; font-weight:700; }
.tenant-list { display:grid; gap:12px; }
.tenant-list form { margin:0; }

/* <= 1024px: tablet layouts collapse dense two-column work areas. */
@media (max-width:1024px) {
  .grid-2, .grid-3, .split { grid-template-columns:1fr; }
  .stat-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .auth-shell { grid-template-columns:1fr; max-width:460px; }
  .auth-aside { display:none; }
}

/* <= 800px: mobile shell switches to top bar plus off-canvas navigation. */
@media (max-width:800px) {
  body { font-size:15px; }
  .layout { display:block; }
  .mobile-header {
    position:sticky;
    top:0;
    z-index:220;
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:60px;
    padding:12px 16px;
    border-bottom:1px solid var(--border);
    background:rgba(8,8,20,0.96);
    backdrop-filter:blur(16px);
  }
  .nav-toggle-label {
    width:44px;
    height:44px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border:1px solid var(--border);
    border-radius:var(--radius);
    color:var(--text);
    cursor:pointer;
  }
  .nav-toggle-label span,
  .nav-toggle-label span::before,
  .nav-toggle-label span::after {
    display:block;
    width:18px;
    height:2px;
    border-radius:2px;
    background:currentColor;
    content:"";
  }
  .nav-toggle-label span::before { transform:translateY(-6px); }
  .nav-toggle-label span::after { transform:translateY(4px); }
  .sidebar {
    width:min(82vw, 320px);
    transform:translateX(-105%);
    transition:transform 0.18s ease;
    box-shadow:20px 0 44px rgba(0,0,0,0.36);
  }
  .nav-backdrop {
    position:fixed;
    inset:0;
    z-index:110;
    background:rgba(4,4,15,0.58);
  }
  .nav-toggle:checked ~ .sidebar { transform:translateX(0); }
  .nav-toggle:checked ~ .nav-backdrop { display:block; }
  .content { margin-left:0; padding:18px 16px 28px; }
  .page { gap:18px; }
  .panel { padding:18px; }
  .panel-header { align-items:flex-start; flex-direction:column; }
  .domain-card { align-items:flex-start; flex-direction:column; }
  .domain-actions { justify-content:flex-start; }
  .page-emails .page { display:grid; }
  .page-emails .split > .panel { min-height:auto; }
}

/* <= 480px: small phones get single-column metrics and full-width actions. */
@media (max-width:480px) {
  .stat-grid { grid-template-columns:1fr; }
  .content { padding-left:12px; padding-right:12px; }
  .box { padding:30px 22px; }
  .actions { flex-direction:column; align-items:stretch; }
  .actions button, .actions .button, .actions a { width:100%; }
  .inline-field { align-items:stretch; flex-direction:column; }
  .user-card { display:grid; grid-template-columns:40px 1fr; }
  .user-actions { grid-column:2; flex-direction:row; align-items:center; justify-content:space-between; }
}

/* >= 2560px: ultrawide keeps work surfaces centered instead of stretching endlessly. */
@media (min-width:2560px) {
  .content { padding-top:40px; }
  .page { max-width:1680px; }
}

/* ── Konto-Seite: 2-Spalten-Layout ── */

/* Avatar-Block (oben in der linken Sidebar, Vorlage x=40..104) */
.account-avatar-block {
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 0 16px;
  border-bottom:1px solid var(--border);
  margin-bottom:12px;
}
.account-avatar {
  width:44px;
  height:44px;
  border-radius:50%;
  background:rgba(47,123,224,0.16);
  border:1px solid rgba(47,123,224,0.30);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:0.94rem;
  color:var(--accent);
  flex-shrink:0;
  letter-spacing:0;
}
.account-avatar-info { min-width:0; }
.account-avatar-name {
  font-weight:700;
  font-size:0.92rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.account-avatar-email {
  color:var(--muted);
  font-size:0.78rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* MS-Status-Banner oben im Hauptbereich (Vorlage x=420, y=110, grün/blau) */
.ms-status-banner {
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 18px;
  border-radius:var(--radius);
  border:1px solid var(--border);
}
.ms-status-banner--success {
  background:rgba(0,230,118,0.07);
  border-color:rgba(0,230,118,0.28);
}
.ms-status-banner--warn {
  background:rgba(47,123,224,0.08);
  border-color:rgba(47,123,224,0.34);
}
.ms-status-banner-info { flex:1; min-width:0; }
.ms-status-title { font-weight:700; font-size:0.95rem; display:block; }
.ms-status-sub { color:var(--muted); font-size:0.86rem; display:block; margin-top:2px; }

.account-layout {
  display:grid;
  grid-template-columns:220px 1fr;
  gap:24px;
  align-items:start;
}
.account-subnav {
  position:sticky;
  top:24px;
  display:grid;
  gap:4px;
  padding:14px;
}
.account-subnav-link {
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:var(--radius);
  color:var(--muted);
  font-size:0.91rem;
  font-weight:600;
  border:1px solid transparent;
  transition:background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.account-subnav-link:hover {
  background:var(--bg-hover);
  color:var(--text);
  border-color:var(--border);
}
.account-content { display:grid; gap:32px; }
.account-section { display:grid; gap:14px; }
.account-section-head { padding:0 2px; }
.account-section-head h2 {
  font-size:1.35rem;
  font-weight:800;
  letter-spacing:-.01em;
  margin-bottom:4px;
}

/* Profil-Karte */
.account-profile-card { display:grid; gap:0; }
.account-profile-card h3 { margin-bottom:14px; }
.account-profile-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:11px 0;
  border-bottom:1px solid var(--border);
  font-size:0.92rem;
}
.account-profile-row:last-child { border-bottom:none; }
.account-profile-label { font-weight:700; color:var(--text); }
.account-profile-value { color:var(--muted); }

/* MS-Verbunden-Zeile */
.account-info-ms {
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
  font-size:0.96rem;
}

/* MS-CTA-Banner (vor Verbindung) */
.ms-cta-banner {
  display:grid;
  gap:16px;
  border-color:rgba(47,123,224,0.34);
  background:rgba(10,13,24,0.88);
}
.ms-cta-body {
  display:flex;
  align-items:flex-start;
  gap:16px;
}
.ms-cta-logo { flex-shrink:0; }
.ms-cta-title { font-weight:800; font-size:1.05rem; margin-bottom:5px; }
.ms-cta-sub { color:var(--muted); font-size:0.9rem; line-height:1.5; }
.ms-cta-btn { align-self:start; }

/* Sidebar: MS-Verbinden-Link */
.nav-ms-connect {
  display:flex;
  align-items:center;
  gap:9px;
  min-height:44px;
  padding:10px 12px;
  border-radius:var(--radius);
  border:1px solid rgba(47,123,224,0.32);
  color:var(--accent);
  font-weight:700;
  font-size:0.91rem;
  background:rgba(47,123,224,0.06);
  transition:background 0.15s ease, border-color 0.15s ease;
}
.nav-ms-connect:hover {
  background:rgba(47,123,224,0.12);
  border-color:rgba(47,123,224,0.52);
  color:var(--accent);
}

@media (max-width:768px) {
  .account-layout { grid-template-columns:1fr; }
  .account-subnav { position:static; flex-direction:row; display:flex; flex-wrap:wrap; }
}

/* ── Portal-Kacheln (MS verbunden) ── */
.portal-tile-grid {
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:16px;
  width:min(100%, 520px);
}
.portal-tile {
  display:grid;
  gap:8px;
  padding:22px;
  align-content:start;
  text-align:left;
  color:var(--text);
}
.portal-tile:hover {
  color:var(--text);
  border-color:rgba(47,123,224,0.52);
}
.portal-tile-icon { color:var(--accent); margin-bottom:4px; }
.portal-tile-label { font-weight:800; font-size:0.97rem; }
.portal-tile-sub { color:var(--muted); font-size:0.84rem; line-height:1.4; }

/* ── Portal-MS-CTA (nicht verbunden) ── */
.portal-ms-cta {
  width:min(100%, 520px);
  display:grid;
  gap:18px;
  text-align:left;
  border-color:rgba(47,123,224,0.40);
  background:rgba(10,13,24,0.88);
}
.portal-ms-cta-body { display:flex; align-items:flex-start; gap:16px; }
.portal-ms-cta-title { font-weight:800; font-size:1.08rem; margin-bottom:6px; }
.portal-ms-cta-sub { color:var(--muted); font-size:0.9rem; line-height:1.5; }
.portal-ms-cta-btn { align-self:start; }
.portal-ms-cta-konto {
  color:var(--muted);
  font-size:0.88rem;
  font-weight:600;
  text-align:center;
}
.portal-ms-cta-konto:hover { color:var(--accent); }
