:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #edf3ff;
  background: #080e19;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; padding: 24px; }
h1 { margin: 0; letter-spacing: -.045em; }
input, button { font: inherit; }
:focus-visible { outline: 2px solid #86ecda; outline-offset: 4px; }

.auth-page {
  display: grid;
  place-items: center;
}
.auth-page, .app-page {
  background:
    radial-gradient(ellipse at 14% 0%, #16343a 0%, transparent 48%),
    radial-gradient(ellipse at 100% 100%, #121c33 0%, transparent 55%),
    #0a101b;
}
.shell {
  display: grid;
  grid-template-columns: 0.9fr 1fr;
  width: min(100%, 850px);
  border: 1px solid #30414b;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 24px 80px #0006;
}
.identity {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: clamp(26px, 5vw, 54px);
  background: radial-gradient(ellipse at 85% 20%, #23474b, transparent 78%), #10272d;
}
.identity::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background-image: linear-gradient(#8bebd816 1px, transparent 1px), linear-gradient(90deg, #8bebd816 1px, transparent 1px);
  background-size: 27px 27px;
  mask-image: linear-gradient(145deg, transparent 12%, #000 71%);
}
.identity:not(.app-header)::after, .app-header-pattern::after {
  position: absolute;
  z-index: -1;
  content: "";
  width: 240px;
  aspect-ratio: 1;
  right: -135px;
  bottom: -145px;
  border: 1px solid #8bebd83a;
  border-radius: 40px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 24px #8bebd817, 0 0 0 48px #8bebd80a;
}
.brand { display: grid; gap: 22px; }
.mark {
  display: grid;
  place-items: center;
  width: 78px;
  aspect-ratio: 1;
  border: 1px solid #578a85;
  border-radius: 21px;
  background: linear-gradient(145deg, #244b50, #10262e);
  box-shadow: 0 8px 22px #071a2080, inset 0 1px #c3f6e61c;
}
.mark svg { width: 59%; height: 59%; }
.wordmark { font-size: clamp(2.5rem, 6vw, 3.5rem); font-weight: 740; line-height: 1; letter-spacing: -.065em; }
.product { margin: 12px 0 0; color: #bfdbdb; font-size: .84rem; line-height: 1.45; }
.access {
  display: flex;
  flex-direction: column;
  gap: 30px;
  min-height: 398px;
  padding: 25px clamp(24px, 5vw, 48px) 42px;
  background: #111a28;
}
.access nav {
  align-self: flex-end;
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid #354459;
  border-radius: 9px;
}
.access nav a {
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 28px;
  color: #bdcada;
  border-radius: 5px;
  text-decoration: none;
  font-size: .75rem;
  font-weight: 660;
}
.access nav a:hover { color: #fff; }
.access nav [aria-current] { background: #283745; color: #f2fbfc; }
.access h1 { font-size: clamp(1.8rem, 5vw, 2.25rem); line-height: 1.1; }
.access p { margin: 12px 0 26px; color: #b6c5d6; line-height: 1.55; }
.access label { display: block; margin-bottom: 8px; font-size: .875rem; font-weight: 660; }
.access input, .access button { width: 100%; min-height: 48px; border-radius: 9px; }
.access input { border: 1px solid #506176; background: #0b1320; color: inherit; padding: 10px 13px; }
.access input:hover { border-color: #8195a9; }
.otp { letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.access button {
  margin-top: 14px;
  border: 0;
  background: #8ce4d3;
  color: #0b282a;
  padding: 10px 16px;
  font-weight: 750;
  cursor: pointer;
}
.access button:hover { background: #a9f2e4; }
.access .notice { color: #ffbbb3; }
.back { display: inline-block; margin-top: 18px; color: #a9e7dd; font-size: .875rem; line-height: 1.5; text-underline-offset: 3px; }

body.app-page { padding: 0; }
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100dvh;
  background: #111a28;
}
.app-header {
  position: sticky;
  top: 0;
  overflow: visible;
  z-index: 1;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid #30414b;
}
.app-header-pattern {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-header .mark { width: 40px; flex: 0 0 40px; border-radius: 10px; }
.app-header .wordmark { font-size: 1.45rem; }
.app-header .product { margin-top: 3px; font-size: .7rem; line-height: 1.25; }
.app-workspace {
  flex: 1;
  display: flex;
}
.app-workspace > .app-content { flex: 1; min-width: 0; }
.app-content { padding: 10px 14px; }
.app-sidebar {
  flex: 0 0 44px;
  min-width: 0;
  border-inline-end: 1px solid #30414b;
  background: #101c28;
}
.app-sidebar[open] { flex-basis: clamp(126px, 23vw, 208px); }
.app-sidebar summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  list-style: none;
  cursor: pointer;
  border-bottom: 1px solid #30414b;
  color: #d2f4ee;
  font-size: .8rem;
  font-weight: 650;
}
.app-sidebar summary::-webkit-details-marker { display: none; }
.app-sidebar summary:focus-visible { outline-offset: -4px; }
.sidebar-icon {
  display: block;
  width: 17px;
  height: 14px;
  flex: 0 0 17px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: linear-gradient(90deg, #72b8ad 30%, transparent 30%);
}
.app-sidebar:not([open]) .sidebar-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.app-sidebar summary:hover { background: #254047; }
.app-content h1 { font-size: clamp(1.4rem, 4vw, 1.75rem); line-height: 1.15; }
.app-nav {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex: none;
  margin-inline: 12px auto;
  padding-inline-start: 22px;
  border-inline-start: 1px solid #57807e;
}
.app-nav a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: -9px;
  padding: 6px 14px;
  border: 1px solid #48676c;
  border-radius: 3px 3px 0 0;
  background: #152b31;
  color: #d2f4ee;
  font-size: .875rem;
  font-weight: 700;
  text-decoration: none;
}
.app-nav a:hover { background: #1e393e; }
.app-nav a[aria-current] {
  border-color: #63928e;
  border-bottom-color: #111a28;
  background: #111a28;
  color: #d2f4ee;
  box-shadow: inset 0 1px #79b3a9;
}
.app-nav a:focus-visible { outline-offset: -4px; }
.profile { position: relative; flex: none; }
.profile summary {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  list-style: none;
  cursor: pointer;
  border: 1px solid #578a85;
  border-radius: 50%;
  background: #10272d;
  color: #d2f4ee;
}
.profile summary::-webkit-details-marker { display: none; }
.profile summary:hover, .profile[open] summary { background: #254a4c; }
.profile-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 168px;
  padding: 4px;
  border: 1px solid #3d5964;
  border-radius: 10px;
  background: #142331;
  box-shadow: 0 8px 24px #0006;
}
.profile-menu a, .profile-menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #edf3ff;
  text-align: start;
  text-decoration: none;
  font-size: .875rem;
  cursor: pointer;
}
.profile-menu a:hover, .profile-menu button:hover { background: #254a4c; }

@media (max-width: 640px) {
  body.auth-page { padding: 16px; }
  .app-header, .app-content { padding-inline: 10px; }
  .app-header .mark { width: 34px; flex-basis: 34px; }
  .app-header .wordmark { font-size: 1.25rem; }
  .app-header { gap: 8px; }
  .app-header .brand { gap: 7px; }
  .app-nav { margin-inline-start: 3px; padding-inline-start: 10px; }
  .app-nav a { padding-inline: 9px; }
  .shell { grid-template-columns: 1fr; width: min(100%, 430px); border-radius: 19px; }
  .identity { padding: 24px; }
  .brand { display: flex; align-items: center; gap: 14px; }
  .mark { width: 54px; flex: 0 0 54px; border-radius: 14px; }
  .wordmark { font-size: 2rem; }
  .product { margin-top: 6px; font-size: .75rem; }
  .access { gap: 18px; min-height: 0; padding: 18px 24px 30px; }
}

@media (max-width: 520px) {
  .app-header .product { display: none; }
}

@media (max-width: 385px) {
  .app-header .mark { display: none; }
  .app-nav a { padding-inline: 7px; }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.settings-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid #30434e;
  border-radius: 8px;
  background: #131f2c;
}
.settings-verify { margin-top: 12px; }
.settings-card h2 { margin: 0; font-size: 1.05rem; }
.settings-card p, .settings-status { margin: 8px 0; color: #bdcada; font-size: .875rem; overflow-wrap: anywhere; }
.settings-card label { display: block; margin: 10px 0; font-size: .875rem; }
.settings-card input {
  display: block;
  width: min(100%, 28rem);
  min-height: 42px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid #506176;
  border-radius: 6px;
  background: #0b1320;
  color: inherit;
}
.settings-card button {
  min-height: 42px;
  margin-top: 6px;
  padding: 7px 12px;
  border: 1px solid #578a85;
  border-radius: 6px;
  background: #173437;
  color: #d2f4ee;
  cursor: pointer;
}
.settings-card button:hover { background: #254a4c; }
.settings-card details { margin: 8px 0; font-size: .875rem; }
.settings-card code { overflow-wrap: anywhere; }
.totp-qr { width: min(100%, 10rem); padding: 4px; background: #fff; }
.totp-qr svg { display: block; width: 100%; height: auto; }
.access form label + label { margin-top: 12px; }
.access form label input { display: block; margin-top: 8px; }
.access .return-form button { margin-top: 8px; background: transparent; color: #a9e7dd; }
.access .status { color: #a9e7dd; }
.app-content > .notice { margin: 10px 0; color: #ffbbb3; font-size: .875rem; }

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

.profile-languages {
  display: flex;
  width: fit-content;
  gap: 3px;
  margin: 3px 3px 5px auto;
  padding: 3px;
  border: 1px solid #354459;
  border-radius: 9px;
}
.profile-languages a {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 28px;
  padding: 0;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 660;
}
.profile-languages [aria-current] { background: #283745; color: #f2fbfc; }

.app-sidebar nav { display: grid; gap: 3px; padding: 6px; }
.app-sidebar nav a {
  padding: 8px;
  border-radius: 4px;
  color: #d2f4ee;
  font-size: .85rem;
  line-height: 1.3;
  text-decoration: none;
}
.app-sidebar nav a:hover, .app-sidebar nav [aria-current] { background: #254047; }
.app-sidebar nav [aria-current] { box-shadow: inset 2px 0 #79b3a9; }

.tenant-identity {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: baseline;
  column-gap: 6px;
}
.tenant-identity > .wordmark { grid-column: 1; grid-row: 1; }
.tenant-identity > .tenant-badge { grid-column: 2; grid-row: 1; }
.tenant-identity > .product { grid-column: 1 / -1; grid-row: 2; }
.auth-page .identity:has(.tenant-identity) { padding-inline: clamp(20px, 4vw, 42px); }
.auth-page .tenant-identity .wordmark { font-size: clamp(2rem, 4.4vw, 3rem); }
.tenant-badge {
  display: inline-block;
  max-width: 72px;
  overflow: hidden;
  font-size: .68rem;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: normal;
  color: #a9e7dd;
}
.tenant-badge:has(.tenant-logo:not([hidden])) { max-width: 78px; overflow: visible; }
.tenant-badge-text { display: inline-block; white-space: nowrap; transform-origin: left center; }
.tenant-logo { display: block; width: auto; height: auto; max-width: 78px; max-height: 25px; object-fit: contain; }
.auth-page .tenant-badge:has(.tenant-logo) { max-width: clamp(88px, 15vw, 104px); }
.auth-page .tenant-logo { max-width: clamp(88px, 15vw, 104px); max-height: 32px; }
.tenant-badge[hidden], .tenant-badge [hidden], .company-form [hidden] { display: none; }
.company-form, .company-directory { margin-top: 12px; }
.company-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.company-form label { min-width: 0; }
.company-form small { display: block; margin-top: 5px; color: #bdcada; line-height: 1.4; }
.company-form select {
  display: block;
  width: min(100%, 28rem);
  min-height: 42px;
  margin-top: 5px;
  padding: 7px 10px;
  border: 1px solid #506176;
  border-radius: 6px;
  background: #0b1320;
  color: inherit;
  font: inherit;
}
.company-form fieldset {
  min-width: 0;
  margin: 12px 0 6px;
  padding: 8px 12px 12px;
  border: 1px solid #30434e;
  border-radius: 6px;
}
.company-form legend { padding: 0 4px; font-size: .9rem; }
.company-preview { width: fit-content; max-width: 100%; padding: 8px 12px; border: 1px solid #30434e; border-radius: 6px; background: #10272d; }
.company-preview .brand { display: flex; align-items: center; gap: 8px; }
.company-preview .mark { width: 40px; flex: 0 0 40px; border-radius: 10px; }
.company-preview .wordmark { font-size: 1.45rem; }
.company-preview .product { margin: 3px 0 0; font-size: .7rem; }
.company-table { margin-top: 8px; overflow: auto; }
.company-table table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.company-table th, .company-table td { padding: 8px; border-bottom: 1px solid #30434e; text-align: start; }
.company-table td a, #company-host { color: #a9e7dd; overflow-wrap: anywhere; }
@media (max-width: 940px) {
  .company-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .company-fields { grid-template-columns: minmax(0, 1fr); }
  .app-workspace:has(.company-form) { flex-wrap: wrap; align-content: start; }
  .app-workspace:has(.company-form) > .app-content { flex-basis: 100%; }
  .app-workspace:has(.company-form) > .app-sidebar[open] { flex: 1 1 100%; }
}

@media (max-width: 385px) {
  .auth-page .identity:has(.tenant-identity) { padding-inline: 16px; }
  .auth-page .tenant-identity .wordmark { font-size: 1.45rem; }
  .auth-page .brand:has(.tenant-identity) .mark { width: 42px; flex-basis: 42px; }
}

.company-actions { display: flex; gap: 5px; align-items: center; white-space: nowrap; }
.company-actions a, .company-actions button {
  display: inline-block;
  margin: 0;
  padding: 4px 7px;
  min-height: 0;
  border: 1px solid #42626b;
  border-radius: 5px;
  background: #173437;
  color: #d2f4ee;
  font-size: .75rem;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.company-actions a:hover, .company-actions button:hover { background: #254a4c; }
.company-actions .danger, .delete-company .danger { border-color: #8e514e; color: #ffc2ba; background: #41282d; }
.company-actions .danger:hover, .delete-company .danger:hover { background: #603640; }
.delete-company { max-width: 46rem; margin-top: 12px; }
.delete-company a, .company-form > a { color: #a9e7dd; }
