:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #142033;
  --muted: #64748b;
  --line: #d8e1ee;
  --blue: #1f63d0;
  --blue-dark: #184ea4;
  --soft: #eef3fb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  background: #e9eff8;
  opacity: .7;
}
body::before {
  width: 38rem;
  height: 18rem;
  top: -4rem;
  right: -10rem;
  clip-path: polygon(0 12%, 100% 0, 82% 100%, 12% 88%);
  transform: rotate(8deg);
}
body::after {
  width: 26rem;
  height: 13rem;
  bottom: 4rem;
  left: -8rem;
  clip-path: polygon(8% 0, 100% 14%, 90% 100%, 0 86%);
  transform: rotate(-12deg);
}

.brand-mark {
  position: fixed;
  top: 1.5rem;
  left: 1.75rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  z-index: 2;
}
.brand-glyph {
  width: 2rem;
  height: 2rem;
  border-radius: .35rem;
  background: linear-gradient(135deg, var(--blue), #6ca2ff);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}
.brand-glyph::before,
.brand-glyph::after {
  content: "";
  position: absolute;
}
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 4rem 1rem 1.5rem;
}

.card {
  position: relative;
  width: min(100%, 34rem);
  background: var(--card);
  border: 1px solid rgba(20,32,51,.08);
  border-radius: .5rem;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .08);
  padding: 1.5rem;
  z-index: 1;
}

.login-logo {
  display: block;
  width: min(16rem, 100%);
  height: auto;
  margin: -.25rem auto .75rem;
}

.card-head h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}
.eyebrow {
  margin: 0 0 .35rem;
  color: var(--blue);
  font-weight: 700;
}
.lead, .panel-copy {
  margin: .45rem 0 0;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: .5rem;
  margin: 1.25rem 0 1rem;
}
.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: .35rem;
  padding: .7rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.active {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: var(--soft);
}

.status {
  min-height: 1.25rem;
  margin-bottom: .75rem;
  color: var(--muted);
}
.status.error { color: #b42318; }
.status.ok { color: #116329; }

.panel { display: none; }
.panel.active { display: grid; gap: .85rem; }
.success { text-align: center; padding: 1.25rem 0 .5rem; }

label { display: grid; gap: .35rem; }
label span { font-weight: 600; }

input {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  padding: .65rem .75rem;
  font: inherit;
  color: var(--text);
  background: #fff;
}
input:focus {
  outline: 2px solid rgba(31, 99, 208, .18);
  border-color: var(--blue);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}

.field-row {
  display: flex;
  align-items: stretch;
}
.field-row input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.toggle {
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 .35rem .35rem 0;
  background: #f8fafc;
  color: var(--muted);
  padding: 0 .8rem;
  font-weight: 600;
  cursor: pointer;
}

.check {
  grid-template-columns: 1rem 1fr;
  align-items: start;
  gap: .6rem;
}
.check input { width: 1rem; min-height: 1rem; margin-top: .2rem; }

.row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  align-items: center;
}

.primary, .secondary, .link {
  border-radius: .35rem;
  border: 1px solid transparent;
  min-height: 2.6rem;
  padding: 0 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.primary {
  background: var(--blue);
  color: #fff;
}
.primary:hover { background: var(--blue-dark); }
.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.link {
  background: transparent;
  color: var(--blue);
  padding-left: 0;
}

@media (max-width: 640px) {
  .card { padding: 1.1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .brand-mark { left: 1rem; top: 1rem; }
}

/* Shorter desktop screens (1080p laptops etc.): compress the auth card so the
   whole form — register included — fits without scrolling. Scoped to the login
   card; the tenant-admin pages share this stylesheet. */
@media (min-width: 641px) and (max-height: 1000px) {
  .shell { padding: 3rem 1rem 1rem; }
  .login-logo { width: min(12rem, 100%); margin-bottom: .5rem; }
  .card-head h1 { font-size: 1.35rem; }
  .card .tabs { margin: .9rem 0 .75rem; }
  .card .tab { padding: .55rem .9rem; }
  .card .status { margin-bottom: .5rem; }
  .card .panel.active { gap: .65rem; }
  .card input { min-height: 2.4rem; padding: .5rem .75rem; }
  .card .oidc-row { margin-top: .65rem; }
}

.admin-shell {
  min-height: 100vh;
  padding: 5.5rem 1.5rem 2rem;
  position: relative;
  z-index: 1;
}
.admin-header {
  width: min(72rem, 100%);
  margin: 0 auto 1rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}
.admin-header h1 { margin: 0; font-size: 1.8rem; }
.admin-grid {
  width: min(72rem, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) 1fr;
  gap: 1rem;
}
.admin-card {
  width: 100%;
  display: grid;
  gap: .85rem;
}
.admin-card h2 { margin: 0; font-size: 1.15rem; }
.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .6rem;
}
.summary div {
  border: 1px solid var(--line);
  border-radius: .35rem;
  padding: .65rem;
  background: #f8fafc;
}
.summary strong { display: block; font-size: 1.35rem; }
.summary span { color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: .35rem; }
table { width: 100%; border-collapse: collapse; min-width: 46rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-size: .8rem; color: var(--muted); }
td:last-child { max-width: 20rem; }

@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── OIDC sign-in (Microsoft etc.) ─────────────────────────────────────────── */
.oidc-row { margin-top: .9rem; }
.oidc-divider { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; margin-bottom: .7rem; }
.oidc-divider::before, .oidc-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.oidc-btn { display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%;
  padding: .6rem .9rem; border: 1px solid var(--line); border-radius: .35rem; background: #fff;
  color: #2b2b2b; font-size: .95rem; font-weight: 600; cursor: pointer; }
.oidc-btn:hover { background: #f4f4f4; }
