:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --soft: #f8fafc;
  --line: #e2e8f0;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --indigo: #6366f1;
  --slate-dark: #1e293b;
  --danger: #ef4444;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 54px;
}

.auth-card {
  width: min(100%, 448px);
  overflow: hidden;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

body[data-screen="profile"] .auth-card,
body[data-screen="user-detail"] .auth-card,
body[data-screen="auth-methods"] .auth-card,
body[data-screen="organization-info"] .auth-card,
body[data-screen="sessions"] .auth-card {
  width: min(100%, 1040px);
}

body[data-screen="profile"] .auth-shell,
body[data-screen="user-detail"] .auth-shell,
body[data-screen="auth-methods"] .auth-shell,
body[data-screen="organization-info"] .auth-shell,
body[data-screen="sessions"] .auth-shell {
  align-items: flex-start;
}

.top-bar {
  height: 8px;
  background: linear-gradient(90deg, #60a5fa, var(--indigo));
}

.card-inner {
  padding: 32px;
}

.brand-block {
  margin-bottom: 28px;
  text-align: center;
}

.brand-icon,
.otp-icon {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 14px;
  color: var(--blue);
  background: #eff6ff;
}

.brand-icon img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}

.brand-icon-large {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.10);
}

.brand-icon-large img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 1.55rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.brand-block p,
.policy-note,
.muted {
  color: var(--muted);
}

.brand-block p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.view-stack,
.form-stack {
  display: grid;
  gap: 16px;
}

.api-view {
  animation: view-in 180ms ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-intro {
  display: grid;
  gap: 4px;
  text-align: center;
}

.step-intro h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.step-intro p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  width: fit-content;
  justify-self: center;
  margin: 0 0 4px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 0.74rem;
  font-weight: 800;
}

.passkey-first {
  gap: 10px;
}

.back-button {
  justify-self: flex-start;
}

.account-chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-self: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #334155;
  background: var(--soft);
  font-size: 0.88rem;
  font-weight: 800;
}

.account-chip img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.chip-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.field-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label {
  color: #334155;
  font-size: 0.9rem;
  font-weight: 700;
}

label span {
  margin-left: 4px;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 500;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.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;
}

.input-shell {
  position: relative;
}

.input-shell i {
  position: absolute;
  top: 50%;
  left: 13px;
  color: #94a3b8;
  transform: translateY(-50%);
  pointer-events: none;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.input-shell input {
  padding-left: 40px;
}

#passkey-email {
  min-height: 42px;
  font-size: 0.9rem;
}

#otp-code {
  min-height: 56px;
  padding: 10px 18px;
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.42em;
}

input:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

select:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.primary-button,
.secondary-button,
.outline-button,
.passkey-button,
.dark-button,
.text-button,
.icon-button {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button,
.secondary-button,
.outline-button,
.passkey-button,
.dark-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.primary-button {
  border: 1px solid var(--blue);
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.24);
}

.primary-button:hover,
.primary-button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
  background: var(--blue-dark);
}

.passkey-button {
  border: 2px solid var(--blue);
  color: var(--blue);
  background: #fff;
}

.passkey-button:hover,
.passkey-button:focus-visible {
  background: #eff6ff;
}

.dark-button {
  border: 1px solid var(--slate-dark);
  color: #fff;
  background: var(--slate-dark);
}

.dark-button:hover,
.dark-button:focus-visible {
  background: #0f172a;
}

.secondary-button {
  border: 1px solid var(--blue);
  color: #fff;
  background: var(--blue);
}

.outline-button {
  border: 1px solid #cbd5e1;
  color: #334155;
  background: #fff;
}

.outline-button:hover,
.outline-button:focus-visible {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eff6ff;
}

.compact-button {
  width: fit-content;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.text-button {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0;
  border: 0;
  color: var(--blue-dark);
  background: transparent;
}

.text-button:hover,
.text-button:focus-visible,
.card-link:hover,
.card-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.danger {
  color: var(--danger);
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 700;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.form-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.form-status.compact {
  min-height: 0;
}

.form-status[data-kind="ok"] {
  color: #047857;
}

.form-status[data-kind="working"] {
  color: var(--blue-dark);
}

.form-status[data-kind="error"] {
  color: var(--danger);
}

.policy-note {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
}

.center-button {
  justify-self: center;
}

.separate-link-row {
  display: flex;
  justify-content: center;
  padding-top: 2px;
}

.account-type-note {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  color: #1e3a8a;
  background: #eff6ff;
}

.account-type-note i {
  margin-top: 3px;
  color: var(--blue-dark);
}

.account-type-note strong,
.account-type-note p {
  margin: 0;
}

.account-type-note strong {
  display: block;
  font-size: 0.9rem;
}

.account-type-note p {
  color: #1d4ed8;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

.notice {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  border-radius: 12px;
  color: #991b1b;
  background: #fef2f2;
}

.otp-card {
  padding-top: 4px;
  text-align: center;
}

.otp-card h2,
.passkey-promo h2,
.passkey-section h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.otp-card p,
.passkey-promo p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid #f1f5f9;
  border-radius: 14px;
  background: var(--soft);
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 16px;
  border: 1px solid #f1f5f9;
  border-radius: 16px;
  background: var(--soft);
}

.dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, auto);
  gap: 16px;
  align-items: stretch;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-actions .compact-button {
  flex: 0 1 auto;
  white-space: nowrap;
}

.profile-hero > div {
  min-width: 0;
}

.profile-hero img {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  padding: 8px;
  border-radius: 16px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.profile-hero h2,
.profile-hero p {
  margin-bottom: 0;
}

.profile-hero h2 {
  font-size: 1.18rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.profile-hero [data-profile-id] {
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-details {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-details div {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.profile-details dt {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: #1e293b;
  font-size: 0.9rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stats-grid div {
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.stats-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stats-grid strong {
  color: #0f172a;
  font-size: 1.35rem;
  line-height: 1.1;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(300px, 0.72fr);
  gap: 16px;
}

.dashboard-side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.management-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.account-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.account-action {
  justify-content: flex-start;
  min-height: 58px;
  padding: 12px 14px;
}

.account-action i {
  width: 18px;
  text-align: center;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.1rem;
  line-height: 1.35;
}

.section-heading > span {
  max-width: 280px;
  color: var(--muted);
  text-align: right;
  font-size: 0.8rem;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px) auto;
  gap: 10px;
  align-items: center;
}

.search-row .input-shell {
  min-width: 0;
}

.user-results,
.organization-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.user-result,
.organization-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}

.result-main,
.organization-head,
.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.result-main strong,
.organization-head strong,
.member-row strong {
  display: block;
  color: #1e293b;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.result-main span,
.organization-head span,
.member-row span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 0.72rem;
  font-weight: 800;
}

.mini-badge.is-org {
  border-color: #fed7aa;
  color: #9a3412;
  background: #fff7ed;
}

.detail-form {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.service-toggle-group {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.service-toggle-group legend {
  padding: 0 4px;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
}

.service-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  flex: 0 0 auto;
  padding: 0;
}

.check-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-form > .primary-button {
  width: fit-content;
  min-width: 220px;
}

.standalone-check {
  align-self: end;
  min-height: 46px;
}

.organization-services,
.member-list {
  display: grid;
  gap: 8px;
}

.organization-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.member-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.member-row select {
  width: 140px;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #60a5fa, var(--indigo));
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.28);
}

.profile-card h2,
.profile-card p {
  margin-bottom: 0;
}

.profile-card h2 {
  font-size: 1.05rem;
}

.profile-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.passkey-promo {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #eff6ff;
}

.passkey-promo > *:not(.promo-mark) {
  position: relative;
  z-index: 1;
}

.promo-mark {
  position: absolute;
  top: -12px;
  right: -10px;
  color: #bfdbfe;
  font-size: 4.4rem;
  opacity: 0.68;
}

.passkey-promo h2 {
  color: #1e3a8a;
}

.passkey-promo p {
  margin-bottom: 12px;
  color: #1d4ed8;
  font-size: 0.82rem;
}

.passkey-promo .secondary-button {
  width: fit-content;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
}

.service-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #dcfce7;
  border-radius: 14px;
  background: #f0fdf4;
}

.service-panel h2,
.service-panel p {
  margin: 0;
}

.service-panel h2 {
  color: #14532d;
  font-size: 1.05rem;
  line-height: 1.35;
}

.service-panel p:not(.status-badge) {
  color: #166534;
  font-size: 0.82rem;
}

.service-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.service-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 197, 94, 0.24);
  border-radius: 10px;
  background: #fff;
}

.service-item strong {
  color: #14532d;
  font-size: 0.9rem;
}

.service-item span {
  color: #64748b;
  font-size: 0.8rem;
}

.service-item.is-blocked {
  border-color: rgba(239, 68, 68, 0.24);
  background: #fff7f7;
}

.service-item.is-blocked strong {
  color: #991b1b;
}

.service-item.is-muted {
  color: #64748b;
  background: rgba(255, 255, 255, 0.72);
}

.passkey-section {
  display: grid;
  gap: 12px;
}

.passkey-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.passkey-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.passkey-list strong,
.passkey-list span {
  display: block;
}

.passkey-list span,
.muted {
  font-size: 0.86rem;
}

.icon-button {
  min-width: 58px;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: var(--danger);
  background: #fff;
}

.logout-row {
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}

.page-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 16px;
  color: #94a3b8;
  text-align: center;
  font-size: 0.76rem;
  pointer-events: none;
}

.card-link {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  color: var(--blue-dark);
  font-weight: 800;
  text-decoration: none;
}

.primary-button.card-link {
  width: 100%;
  justify-content: center;
  color: #fff;
}

@media (max-width: 820px) {
  .dashboard-header,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-actions {
    justify-content: flex-start;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) minmax(130px, 160px);
  }

  .search-row .primary-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 680px) {
  body[data-screen="profile"] .auth-shell,
  body[data-screen="user-detail"] .auth-shell,
  body[data-screen="auth-methods"] .auth-shell,
  body[data-screen="organization-info"] .auth-shell,
  body[data-screen="sessions"] .auth-shell {
    padding: 12px 10px 36px;
  }

  body[data-screen="profile"] .auth-card,
  body[data-screen="user-detail"] .auth-card,
  body[data-screen="auth-methods"] .auth-card,
  body[data-screen="organization-info"] .auth-card,
  body[data-screen="sessions"] .auth-card {
    border-radius: 14px;
  }

  body[data-screen="profile"] .card-inner,
  body[data-screen="user-detail"] .card-inner,
  body[data-screen="auth-methods"] .card-inner,
  body[data-screen="organization-info"] .card-inner,
  body[data-screen="sessions"] .card-inner {
    padding: 20px 14px;
  }

  .profile-details div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .form-grid,
  .service-toggle-grid,
  .result-main,
  .organization-head,
  .member-row,
  .organization-name-row {
    grid-template-columns: 1fr;
  }

  .detail-form > .primary-button,
  .member-row select {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .auth-shell {
    align-items: flex-start;
    padding-top: 18px;
  }

  .card-inner {
    padding: 28px 22px;
  }

  h1 {
    font-size: 1.36rem;
  }

  #otp-code {
    font-size: 1.72rem;
  }

  .dashboard-header,
  .dashboard-layout,
  .stats-grid,
  .form-grid,
  .account-action-grid {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
  }

  .profile-hero img {
    width: 54px;
    height: 54px;
  }

  .dashboard-actions,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading > span {
    max-width: none;
    text-align: left;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .compact-button,
  .detail-form > .primary-button,
  .member-row select {
    width: 100%;
  }
}

@media (max-height: 760px) {
  .auth-shell {
    align-items: flex-start;
    padding-top: 18px;
  }

  .page-footer {
    position: static;
    margin-top: 18px;
  }
}
