/* Canonical Auth Shell, MFA, Workspace Picker, Tenant Users, and Platform Console v1 */

.auth-shell,
.platform-shell {
  min-height: 100dvh;
  background: radial-gradient(circle at top left, #e3f1f8, #f4f7fa 60%);
  color: #183449;
  padding: max(16px, env(safe-area-inset-top, 16px)) max(16px, env(safe-area-inset-right, 16px))
    max(24px, env(safe-area-inset-bottom, 24px)) max(16px, env(safe-area-inset-left, 16px));
}

.auth-shell {
  display: grid;
  place-items: center;
}

.auth-shell[hidden],
.platform-shell[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 460px);
  background: #ffffff;
  border: 1px solid #d6e2eb;
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 18px 48px rgba(17, 45, 68, 0.08);
  display: grid;
  gap: 16px;
}

.auth-card.wide {
  width: min(100%, 680px);
}

.auth-logo {
  height: 34px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  justify-self: start;
}

.auth-card h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
  text-wrap: balance;
}

.auth-card p {
  margin: 0;
  color: #4b677c;
  line-height: 1.5;
  text-wrap: pretty;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field label {
  font-weight: 600;
  font-size: 0.92rem;
  color: #1f4059;
}

.auth-password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.auth-actions .primary {
  flex: 1 1 180px;
}

.auth-link-btn {
  background: transparent;
  border: 0;
  color: #087ead;
  padding: 6px 4px;
  min-height: 44px;
  text-align: left;
  font-weight: 600;
  text-decoration: underline;
  justify-self: start;
}

.auth-link-btn:hover {
  background: transparent;
  color: #055b7d;
}

.auth-error {
  margin: 0;
  color: #b33a42;
  font-weight: 600;
  font-size: 0.92rem;
  min-height: 1.2em;
}

.auth-notice {
  background: #edf6fb;
  border: 1px solid #c6dfed;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.92rem;
  color: #183449;
  overflow-wrap: break-word;
}

.auth-oidc-list {
  display: grid;
  gap: 10px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #6b8496;
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #dce7ef;
}

.auth-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  background: #f8fbfd;
  border: 1px solid #d6e2eb;
  border-radius: 10px;
}

.auth-qr-wrap svg {
  width: min(210px, 100%);
  height: auto;
  background: #ffffff;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e2ecf2;
}

.auth-secret-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  background: #eef4f8;
  padding: 8px 10px;
  border-radius: 6px;
  overflow-wrap: anywhere;
  text-align: center;
}

.recovery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.recovery-grid li {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f2f7fa;
  border: 1px solid #d6e2eb;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.workspace-choice {
  display: grid;
  gap: 6px;
  text-align: left;
  padding: 16px;
  border-radius: 10px;
  border: 1px solid #cfe0ec;
  background: #fbfdff;
}

.workspace-choice.platform-choice {
  border-color: #087ead;
  background: #eef8fc;
}

.workspace-choice strong {
  font-size: 1.02rem;
  color: #143247;
}

.workspace-choice span {
  font-size: 0.88rem;
  color: #4b677c;
}

/* Sidebar workspace & account controls */
.aside-user-card {
  display: grid;
  gap: 8px;
}

.aside-switcher {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.aside-switcher label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
}

.aside-switcher select {
  min-height: 44px;
}

/* Platform Console v1 */
.platform-container {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.platform-header {
  background: #ffffff;
  border: 1px solid #d6e2eb;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.platform-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.platform-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.platform-header-actions select {
  width: auto;
  min-width: 210px;
}

.platform-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.platform-tabs [role='tab'][aria-selected='true'] {
  background: #087ead;
  border-color: #087ead;
  color: #ffffff;
}

.platform-panel {
  background: #ffffff;
  border: 1px solid #d6e2eb;
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.platform-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.platform-toolbar h2 {
  margin: 0;
  font-size: 1.18rem;
}

.platform-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid #e1ebf2;
  border-radius: 8px;
}

.platform-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.platform-table th,
.platform-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e9f0f5;
  text-align: left;
  vertical-align: middle;
}

.platform-table th {
  background: #f5f9fc;
  font-size: 0.86rem;
  color: #36566d;
}

.module-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.module-checks label,
.auth-check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.module-checks input[type='checkbox'],
.auth-check-label input[type='checkbox'] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.copy-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f5f9fc;
  border: 1px solid #cfe0ec;
  border-radius: 8px;
}

.copy-box code {
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

dialog {
  overscroll-behavior: contain;
}

.auth-hint {
  margin: 0;
  font-size: 0.88rem;
  color: #476277;
  line-height: 1.4;
  text-wrap: pretty;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-switch button[aria-pressed='true'] {
  background: #087ead;
  border-color: #087ead;
  color: #ffffff;
}

.user-picker-list {
  margin: 0;
  padding: 8px;
  border: 1px solid #d6e2eb;
  border-radius: 8px;
  background: #f8fbfd;
  max-height: 240px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}

.user-picker-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  min-height: 44px;
  border: 1px solid #d6e2eb;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.user-picker-item:has(input:checked) {
  border-color: #087ead;
  background: #eaf5fa;
}

.user-picker-item input[type='radio'] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.user-picker-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-picker-meta {
  font-size: 0.84rem;
  color: #476277;
  overflow-wrap: anywhere;
}

.user-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.user-badge {
  display: inline-block;
  font-size: 0.74rem;
  line-height: 1.3;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f1f8;
  color: #1c4a6b;
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.env-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  min-height: 36px;
  padding: max(6px, env(safe-area-inset-top, 6px)) max(14px, env(safe-area-inset-right, 14px)) 6px
    max(14px, env(safe-area-inset-left, 14px));
  background: #fef3c7;
  color: #78350f;
  border-bottom: 2px solid #d97706;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  font-size: 0.84rem;
  line-height: 1.35;
  text-align: center;
}

.env-banner-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #92400e;
  color: #ffffff;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.env-banner-text {
  font-weight: 600;
}

.support-banner {
  position: sticky;
  top: var(--env-banner-h, 0px);
  z-index: 29;
  width: 100%;
  min-height: 40px;
  padding: 6px max(14px, env(safe-area-inset-right, 14px)) 6px max(14px, env(safe-area-inset-left, 14px));
  background: #991b1b;
  color: #ffffff;
  border-bottom: 2px solid #7f1d1d;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 12px;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
}

.support-banner[hidden] {
  display: none;
}

.support-banner-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffffff;
  color: #7f1d1d;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.support-banner-text,
.support-banner-ticket,
.support-banner-timer {
  font-weight: 600;
}

.support-banner-timer {
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.24);
  padding: 2px 8px;
  border-radius: 6px;
}

.support-banner-exit {
  background: #ffffff;
  color: #7f1d1d;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 4px 12px;
  min-height: 32px;
  font-weight: 700;
  cursor: pointer;
}

.support-banner-exit:hover:not(:disabled) {
  background: #fef2f2;
}

.active-support-bar {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #7f1d1d;
}

.active-support-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.88rem;
}

.platform-audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.platform-audit-filters select,
.platform-audit-filters input {
  flex: 1 1 180px;
  min-width: 0;
}

html:has(.env-banner:not([hidden])),
html:has(.support-banner:not([hidden])) {
  scroll-padding-top: var(--top-banners-h, 40px);
}

:is(body.has-env-banner, body.has-support-banner) .auth-shell,
:is(body.has-env-banner, body.has-support-banner) .platform-shell {
  min-height: calc(100dvh - var(--top-banners-h, 36px));
}

@media (min-width: 901px) {
  :is(body.has-env-banner, body.has-support-banner) aside {
    top: var(--top-banners-h, 36px);
  }
}

@media print {
  .env-banner,
  .support-banner {
    display: none !important;
  }
}

@media (pointer: coarse) {
  .auth-shell button,
  .auth-shell input,
  .auth-shell select,
  .platform-shell button,
  .platform-shell input,
  .platform-shell select,
  .support-banner-exit {
    min-height: 44px;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 20px 16px;
  }

  .platform-header,
  .platform-panel {
    padding: 14px;
  }

  .platform-header-actions {
    width: 100%;
  }

  .platform-header-actions select,
  .platform-header-actions button,
  .platform-audit-filters button {
    width: 100%;
  }

  .platform-users-actions button {
    flex: 1 1 100%;
  }
}

/* In-app Platform & Company Settings (100% mobile-ready) */
.settings-panel,
.settings-form {
  display: grid;
  gap: 16px;
}

.settings-fieldset {
  border: 1px solid #d6e2eb;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0;
  display: grid;
  gap: 12px;
  background: #fbfdff;
  min-width: 0;
}

.settings-fieldset legend {
  font-weight: 700;
  font-size: 0.96rem;
  color: #143247;
  padding: 0 6px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px 16px;
}

.settings-field {
  min-width: 0;
}

.settings-field input,
.settings-field select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-size: max(1rem, 1em);
}

.settings-label-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.source-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #c7d9e6;
  background: #edf5fa;
  color: #1f4059;
}

.source-badge.source-db {
  background: #e6f6ef;
  border-color: #9bd6b8;
  color: #125c39;
}

.source-badge.source-env {
  background: #fff6e5;
  border-color: #f0ca7d;
  color: #6b4600;
}

.settings-stack {
  display: grid;
  gap: 6px;
}

.settings-check-wrap {
  display: grid;
  gap: 4px;
}

.settings-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
  color: #183449;
  cursor: pointer;
}

.settings-checkbox input[type='checkbox'] {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0;
}

.settings-status {
  margin: 0;
  color: #125c39;
  font-weight: 600;
  min-height: 1.2em;
}

.settings-diag-card {
  border: 1px solid #d6e2eb;
  border-radius: 10px;
  padding: 14px 16px;
  background: #f8fbfd;
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 10px;
}

.diag-badge {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d6e2eb;
  background: #ffffff;
  font-size: 0.85rem;
}

.diag-badge.is-ok {
  border-color: #9bd6b8;
  background: #f3fbf7;
}

.diag-badge.is-missing {
  border-color: #e6b8bc;
  background: #fdf5f6;
}

.diag-badge code {
  font-size: 0.76rem;
  color: #4b677c;
  overflow-wrap: anywhere;
}

.diag-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 135px), 1fr));
  gap: 8px;
}

.diag-kpi {
  background: #ffffff;
  border: 1px solid #d6e2eb;
  border-radius: 8px;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}

.diag-kpi span {
  font-size: 0.78rem;
  color: #4b677c;
}

.diag-kpi strong {
  font-size: 0.98rem;
  color: #143247;
}

.settings-section-title {
  margin: 0 0 4px;
  font-size: 1.15rem;
  text-wrap: balance;
}

.auth-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-lang-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-lang-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4b677c;
}

.auth-lang-select {
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #c5d7e3;
  background: #ffffff;
  color: #183449;
  font: inherit;
  font-size: 0.88rem;
  max-width: 100%;
}

@media (pointer: coarse) {
  .settings-fieldset input:not([type='checkbox']),
  .settings-fieldset select,
  .settings-form button {
    min-height: 44px;
  }
}

@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: max(1rem, 16px);
    min-height: 44px;
  }
}
