:root {
  --auth-ink: #10151f;
  --auth-blue: #2563eb;
  --auth-blue-dark: #1a49b8;
  --auth-page: #eef1f6;
  --auth-panel: #ffffff;
  --auth-border: #dce3ee;
  --auth-muted: #69768e;
  --auth-danger: #b42318;
  --auth-success: #067647;
  --auth-warning: #9a6700;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--auth-ink);
  background: var(--auth-page);
}

button,
input {
  font: inherit;
}

.auth-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.16), transparent 30%),
    var(--auth-page);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.75fr);
  width: min(1120px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  align-items: center;
  gap: 70px;
  padding: 56px 0;
}

.auth-brand-panel {
  max-width: 620px;
}

.auth-brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin-bottom: 30px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--auth-blue), #5f8fff);
  color: #fff;
  font-size: 30px;
  box-shadow: 0 20px 38px -20px rgba(37, 99, 235, 0.8);
}

.auth-eyebrow,
.auth-card-kicker {
  margin: 0;
  color: var(--auth-blue);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-brand-panel h1,
.account-header h1 {
  margin: 13px 0 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: clamp(38px, 5vw, 62px);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.auth-brand-copy {
  max-width: 570px;
  margin: 20px 0 0;
  color: #53617a;
  font-size: 17px;
  line-height: 1.75;
}

.auth-card {
  padding: 34px;
  border: 1px solid var(--auth-border);
  border-radius: 24px;
  background: var(--auth-panel);
  box-shadow: 0 30px 70px -36px rgba(20, 38, 74, 0.42);
}

.auth-card-header h2 {
  margin: 8px 0 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.auth-card-header p:last-child {
  margin: 9px 0 0;
  color: var(--auth-muted);
  line-height: 1.55;
}

.auth-messages {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.auth-message {
  padding: 12px 14px;
  border: 1px solid var(--auth-border);
  border-radius: 11px;
  background: #f6f8fb;
  font-size: 13px;
  line-height: 1.5;
}

.auth-message.error {
  border-color: #f3c7c2;
  background: #fff2f0;
  color: var(--auth-danger);
}

.auth-message.success {
  border-color: #a7e2c8;
  background: #ecfdf3;
  color: var(--auth-success);
}

.auth-message.warning {
  border-color: #f5d892;
  background: #fffaeb;
  color: var(--auth-warning);
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

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

.auth-form label > span {
  color: #35425a;
  font-size: 13px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0 14px;
  outline: none;
  transition: 150ms ease;
}

.auth-form input:focus {
  border-color: var(--auth-blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-form button,
.secondary-button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.auth-form button {
  margin-top: 2px;
  background: var(--auth-blue);
  color: #fff;
  box-shadow: 0 12px 24px -14px rgba(37, 99, 235, 0.85);
}

.auth-form button:hover {
  background: var(--auth-blue-dark);
}

.auth-help {
  margin: 22px 0 0;
  color: var(--auth-muted);
  font-size: 12px;
  line-height: 1.55;
}

.account-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 70px;
}

.account-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--auth-border);
}

.account-header h1 {
  font-size: clamp(34px, 5vw, 52px);
}

.account-header p:last-child {
  color: var(--auth-muted);
}

.account-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-header-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--auth-blue);
  font-weight: 700;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease;
}

.account-header-actions a:hover {
  background: #e9f0ff;
  border-color: #c6daff;
}

.account-header-actions form {
  margin: 0;
}

.secondary-button {
  border: 1px solid var(--auth-border);
  background: #fff;
  color: #35425a;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.secondary-button:hover {
  border-color: #f0b4ae;
  background: #fff5f4;
  color: var(--auth-danger);
}

/* Identity row: avatar disc + name, matching the portal sidebar. */
.account-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.account-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--auth-blue), #5f8fff);
  color: #fff;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 10px 20px -10px rgba(37, 99, 235, 0.8);
}

.account-identity-copy strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.account-identity-copy > span {
  display: block;
  margin-top: 1px;
  color: var(--auth-muted);
  font-size: 13px;
}

/* Two columns: the form carries the work, the aside gives context. */
.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: start;
  gap: 24px;
}

.account-card {
  max-width: none;
}

.account-aside {
  display: grid;
  gap: 16px;
}

.account-panel {
  padding: 24px;
  border: 1px solid var(--auth-border);
  border-radius: 20px;
  background: var(--auth-panel);
  box-shadow: 0 20px 46px -32px rgba(20, 38, 74, 0.4);
}

.account-panel h3 {
  margin: 8px 0 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.account-detail-list {
  display: grid;
  gap: 14px;
  margin: 16px 0 0;
  padding: 0;
}

.account-detail-list div {
  display: grid;
  gap: 3px;
}

.account-detail-list dt {
  color: var(--auth-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-detail-list dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-tips {
  margin: 14px 0 0;
  padding-left: 18px;
  color: #53617a;
  font-size: 13px;
  line-height: 1.7;
}

.account-tips li + li {
  margin-top: 7px;
}

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

@media (max-width: 800px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 34px 0 50px;
  }

  .auth-brand-panel h1 {
    font-size: 42px;
  }

  .account-header {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* ==========================================================================
   MASTER ACCOUNT AND ACCOUNT MANAGEMENT
   ========================================================================== */

.master-badge,
.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.master-badge {
  border: 1px solid #d8b4fe;
  background: #f5f3ff;
  color: #6d28d9;
}

.role-badge {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  text-transform: capitalize;
}

.status-badge.active {
  border: 1px solid #a7e2c8;
  background: #ecfdf3;
  color: var(--auth-success);
}

.status-badge.disabled {
  border: 1px solid #f3c7c2;
  background: #fff2f0;
  color: var(--auth-danger);
}

.admin-account-shell {
  width: min(1220px, calc(100% - 40px));
}

.admin-auth-messages {
  margin: 0 0 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
  gap: 24px;
  align-items: start;
}

.admin-user-list-card {
  min-width: 0;
}

.admin-user-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.admin-user-row {
  display: grid;
  gap: 15px;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  padding: 18px;
  background: #fbfcfe;
}

.admin-user-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-user-summary > div:first-child {
  display: grid;
  gap: 4px;
}

.admin-user-summary strong {
  font-size: 15px;
}

.admin-user-summary span:not(.master-badge):not(.role-badge):not(.status-badge) {
  color: var(--auth-muted);
  font-size: 12px;
}

.admin-user-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.admin-user-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.admin-user-meta div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.admin-user-meta dt {
  color: var(--auth-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-user-meta dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: #35425a;
  font-size: 12px;
}

.admin-delete-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--auth-border);
  padding-top: 14px;
}

.admin-delete-form label {
  display: grid;
  gap: 6px;
}

.admin-delete-form label > span {
  color: #35425a;
  font-size: 11px;
  font-weight: 700;
}

.admin-delete-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--auth-border);
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
}

.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--auth-danger);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.danger-button:hover {
  background: #8f1b13;
}

.master-protection-note {
  margin: 0;
  border-top: 1px solid var(--auth-border);
  padding-top: 12px;
  color: var(--auth-muted);
  font-size: 12px;
}

.auth-checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.auth-checkbox-row input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

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

@media (max-width: 620px) {
  .admin-user-summary,
  .admin-delete-form {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .admin-user-badges {
    justify-content: flex-start;
  }

  .admin-user-meta {
    grid-template-columns: 1fr;
  }

  .danger-button {
    width: 100%;
  }
}


/* ==========================================================================
   IDLE SESSION WARNING
   ========================================================================== */

.portal-idle-warning {
  position: fixed;
  z-index: 999;
  right: 20px;
  bottom: 20px;
  max-width: 340px;
  padding: 14px 18px;
  border: 1px solid #f5d892;
  border-left: 4px solid var(--auth-warning);
  border-radius: 14px;
  background: #fff;
  color: var(--auth-warning);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: 0 22px 48px -20px rgba(20, 38, 74, 0.45);
}

@media (max-width: 620px) {
  .portal-idle-warning {
    right: 14px;
    left: 14px;
    max-width: none;
  }
}
