:root {
  --bg: #f6f8f4;
  --bg-alt: #e9f2ea;
  --ink: #1f2a2a;
  --muted: #4e6363;
  --brand: #0c7a6a;
  --brand-strong: #045f52;
  --accent: #ff9a3d;
  --error: #b42318;
  --error-bg: #ffe5e2;
  --success: #05593e;
  --success-bg: #e3f8ed;
  --surface: rgba(255, 255, 255, 0.88);
  --border: rgba(12, 122, 106, 0.22);
  --shadow: 0 24px 60px rgba(13, 50, 47, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 0%, var(--bg-alt), transparent 55%), var(--bg);
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(36px);
}

.bg-shape-a {
  width: 260px;
  height: 260px;
  right: -60px;
  top: -40px;
  background: rgba(255, 154, 61, 0.33);
}

.bg-shape-b {
  width: 300px;
  height: 300px;
  left: -90px;
  bottom: -120px;
  background: rgba(12, 122, 106, 0.22);
}

.card {
  position: relative;
  z-index: 1;
  width: min(900px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.6rem;
}

.card-header h1 {
  margin: 0.15rem 0 0.45rem;
  font-size: clamp(1.6rem, 2.1vw, 2.3rem);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--brand-strong);
}

.intro {
  margin: 0 0 1.2rem;
  color: var(--muted);
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}

label span {
  font-size: 0.93rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid #bdd6cf;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(12, 122, 106, 0.16);
}

textarea {
  resize: vertical;
  min-height: 7rem;
}

input[readonly] {
  background: #edf1f0;
  color: #526262;
  border-color: #c8d3d0;
  cursor: not-allowed;
}

input[readonly]:focus {
  box-shadow: none;
}

fieldset {
  margin: 1.1rem 0 0;
  padding: 0;
  border: none;
}

legend {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.helper {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.full-width {
  margin-top: 1.1rem;
}

.lookup-field {
  position: relative;
}

.lookup-status {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.lookup-status.selected {
  color: var(--success);
}

.lookup-status.invalid {
  color: var(--error);
}

.lookup-status.pending {
  color: #6f5a22;
}

#targetUserPrincipalName[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.12);
}

.lookup-results {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  max-height: 15rem;
  overflow: auto;
  background: #fff;
  border: 1px solid #bdd6cf;
  border-radius: 12px;
  box-shadow: 0 18px 38px rgba(13, 50, 47, 0.16);
  padding: 0.35rem;
}

.lookup-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  margin: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  padding: 0.55rem 0.6rem;
  text-align: left;
}

.lookup-option:hover,
.lookup-option:focus {
  background: #eaf4f1;
}

.lookup-option small {
  color: var(--muted);
  font-size: 0.8rem;
}

.lookup-empty {
  padding: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.readonly-display {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}

.readonly-display > span {
  font-size: 0.93rem;
}

.readonly-display p {
  min-height: 2.78rem;
  margin: 0;
  border: 1px solid #c8d3d0;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #edf1f0;
  color: #526262;
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.readonly-display p.pending {
  color: #6f5a22;
  background: #fff7df;
  border-color: #e3ca7a;
}

.systems-accordion {
  display: grid;
  gap: 0.75rem;
}

.system-panel {
  border: 1px solid #c6ded8;
  border-radius: 8px;
  background: #fff;
  overflow: clip;
}

.message.info {
  background: #eaf4ff;
  border-color: #a8c7e8;
  color: #17436b;
}

.approval-card {
  width: min(1024px, 100%);
}

.approval-layout {
  display: grid;
  gap: 1.1rem;
}

.approval-banner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid #c6ded8;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
}

.detail-label {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-value {
  margin: 0;
}

.mono {
  font-family: "SFMono-Regular", "Consolas", monospace;
}

.status-pill {
  display: inline-flex;
  margin: 0;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: #e7faf5;
  color: #045f52;
  font-weight: 700;
}

.status-pill[data-status="approved"] {
  background: #e3f8ed;
  color: #05593e;
}

.status-pill[data-status="rejected"],
.status-pill[data-status="timedout"] {
  background: #ffe5e2;
  color: #b42318;
}

.approval-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1rem;
}

.approval-section {
  border: 1px solid #c6ded8;
  border-radius: 16px;
  background: #fff;
  padding: 1rem;
}

.approval-section h2,
.access-card h3 {
  margin: 0 0 0.85rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin: 0;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 0.2rem;
}

.detail-grid dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-grid > div {
  min-width: 0;
}

.approval-note {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #dde9e5;
}

.access-list {
  display: grid;
  gap: 0.9rem;
}

.access-card {
  padding: 0.9rem;
  border-radius: 12px;
  background: #f8fbfa;
  border: 1px solid #dde9e5;
}

.access-permissions {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
}

.access-permissions li + li {
  margin-top: 0.45rem;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.secondary-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid #bdd6cf;
  box-shadow: none;
}

@media (max-width: 800px) {
  .approval-banner,
  .approval-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.system-panel.selected {
  border-color: var(--brand);
}

.system-heading {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 3.6rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  list-style: none;
}

.system-heading::-webkit-details-marker {
  display: none;
}

.system-heading::after {
  content: "+";
  margin-left: auto;
  color: var(--brand-strong);
  font-weight: 800;
  font-size: 1.1rem;
}

.system-panel[open] .system-heading::after {
  content: "-";
}

.system-toggle,
.permission-row input {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.system-toggle:indeterminate {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: inset 0 0 0 2px #fff;
}

.system-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.system-title {
  font-weight: 700;
}

.system-summary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.system-body {
  border-top: 1px solid #d6e8e3;
  padding: 0.8rem;
}

.permission-search {
  width: 100%;
  margin-bottom: 0.7rem;
}

.permission-list {
  display: grid;
  gap: 0.35rem;
  max-height: 18rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.permission-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  border: 1px solid #d7e8e4;
  border-radius: 8px;
  padding: 0.52rem 0.6rem;
  background: #fbfdfc;
  font-size: 0.9rem;
  font-weight: 500;
}

.permission-row:has(input:checked) {
  border-color: var(--brand);
  background: #eef8f4;
}

.permission-text {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.permission-name,
.permission-meta {
  overflow-wrap: anywhere;
}

.permission-name {
  color: var(--ink);
  font-weight: 700;
}

.permission-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

button {
  margin-top: 1.25rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 700;
  padding: 0.78rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(4, 95, 82, 0.25);
}

button[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.message {
  margin-top: 1rem;
  border-radius: 12px;
  padding: 0.72rem 0.85rem;
  font-size: 0.93rem;
}

.message.error {
  background: var(--error-bg);
  color: var(--error);
}

.message.success {
  background: var(--success-bg);
  color: var(--success);
}

.hidden {
  display: none;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: enter 320ms ease forwards;
}

@keyframes enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .card {
    padding: 1.1rem;
    border-radius: 16px;
  }

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