:root {
  --bg: #edf4f7;
  --card: #ffffff;
  --ink: #10233b;
  --muted: #61758f;
  --accent: #0d8b8b;
  --accent-strong: #0a5f73;
  --accent-soft: #dff4f2;
  --warning-soft: #fff0d6;
  --success-soft: #e7f8ef;
  --danger-soft: #fde8e8;
  --border: #d4e2ee;
  --shadow: 0 18px 38px rgba(16, 35, 59, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: Montserrat, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(13, 139, 139, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 196, 75, 0.18), transparent 24%),
    linear-gradient(165deg, #edf4f7 0%, #ffffff 62%);
}

.page { max-width: 980px; margin: 0 auto; padding: 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.login-card { width: min(100%, 420px); }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

h1, h2 { margin: 0 0 10px; }
.muted { color: var(--muted); margin-top: 0; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
input, textarea, button {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
select {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 10px 18px rgba(10, 95, 115, 0.18);
}
.btn-secondary {
  background: #eef5fa;
  color: var(--ink);
  box-shadow: none;
}
button:hover { filter: brightness(0.98); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }
.grid-4 .full { grid-column: 1 / -1; }
.checkbox-label { flex-direction: row; align-items: center; margin-top: 22px; }

.pill { background: #e7f2fc; padding: 6px 10px; border-radius: 999px; }
.row { display: flex; align-items: center; }
.gap-sm { gap: 8px; }
.message { min-height: 1.2rem; color: #0a5; font-size: 0.92rem; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; border-bottom: 1px solid var(--border); padding: 8px; font-size: 0.9rem; }

.hidden { display: none !important; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.admin-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px;
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(16, 35, 59, 0.96), rgba(10, 95, 115, 0.9)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
  color: #fff;
  box-shadow: 0 28px 48px rgba(16, 35, 59, 0.22);
}

.admin-hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(2rem, 3vw, 3rem);
}

.admin-hero p {
  margin: 0;
  max-width: 700px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.6;
}

.admin-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill,
.health-pill,
.subtle-pill {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.subtle-pill {
  color: var(--ink);
  background: #eef5fa;
  border-color: #d4e2ee;
}

.pill-success {
  background: rgba(25, 135, 84, 0.18);
  color: #d7ffee;
}

.pill-danger {
  background: rgba(180, 35, 24, 0.16);
  color: #ffd8d8;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}

.kpi-card {
  padding: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(212, 226, 238, 0.9);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  font-size: clamp(1.8rem, 2.6vw, 2.8rem);
  line-height: 1;
}

.kpi-detail {
  color: var(--muted);
  font-size: 0.94rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.dashboard-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.dashboard-sidebar,
.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-card {
  border-radius: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-bottom: 0;
}

.section-meta,
.selection-banner {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.user-list,
.directory-results,
.access-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-row,
.directory-card {
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
  border: 1px solid #dbe6ee;
  color: var(--ink);
  box-shadow: none;
}

.user-row.is-selected {
  border-color: rgba(13, 139, 139, 0.55);
  background: linear-gradient(180deg, #f4fffe, #ecf9f8);
}

.user-row-top,
.user-row-foot,
.directory-actions,
.access-card-head,
.access-card-body,
.access-card-actions,
.profile-hero,
.profile-badges,
.form-actions,
.overview-grid,
.top-app-row {
  display: flex;
  gap: 12px;
}

.user-row-top,
.user-row-foot,
.access-card-head,
.access-card-body,
.top-app-row {
  justify-content: space-between;
  align-items: center;
}

.user-row-meta,
.directory-meta,
.profile-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.tiny-status,
.tiny-chip,
.app-chip,
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.tiny-status.active {
  background: var(--success-soft);
  color: #157347;
}

.tiny-status.inactive {
  background: var(--danger-soft);
  color: #b42318;
}

.tiny-chip,
.app-chip {
  background: #eef5fa;
  color: var(--ink);
}

.tiny-chip-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.app-chip {
  flex-direction: column;
  align-items: flex-start;
  border-radius: 16px;
  padding: 10px 14px;
}

.app-chip small {
  color: var(--muted);
  font-size: 0.74rem;
}

.profile-card {
  background:
    radial-gradient(circle at top right, rgba(13, 139, 139, 0.11), transparent 30%),
    #fff;
}

.compact-profile-card {
  gap: 18px;
}

.selected-user-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.user-controls-summary {
  margin-bottom: 20px;
}

.profile-name {
  font-size: 1.7rem;
  font-weight: 700;
}

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

.launchpad-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid #d7e3eb;
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(1, 25, 62, 0.06);
}

.launchpad-card strong {
  font-size: 1.08rem;
}

.launchpad-card p {
  margin: 0;
  color: var(--muted);
}

.launchpad-kicker {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
}

.launchpad-button {
  text-align: left;
  cursor: pointer;
}

.user-controls-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.user-controls-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stacked-heading {
  margin-bottom: 4px;
}

.directory-existing {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef5fa;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.access-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid #d8e5ec;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 249, 251, 0.98));
}

.muted-card {
  opacity: 0.72;
}

.access-app {
  font-size: 1.05rem;
  font-weight: 700;
}

.access-role {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.level-badge {
  color: #fff;
  background: linear-gradient(135deg, #5573a7, #20395c);
}

.level-1 { background: linear-gradient(135deg, #7287a8, #4b5d7a); }
.level-2 { background: linear-gradient(135deg, #1f8f95, #0c677b); }
.level-3 { background: linear-gradient(135deg, #17946a, #0d6f55); }
.level-4 { background: linear-gradient(135deg, #c0851c, #8c5d14); }
.level-5 { background: linear-gradient(135deg, #b35028, #7b3117); }

.access-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.access-stat span,
.subheading {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dashboard-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  flex-wrap: wrap;
}

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

.status-list {
  display: grid;
  gap: 10px;
  color: var(--ink);
}

.top-apps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-app-label {
  min-width: 170px;
  font-weight: 600;
}

.top-app-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #edf3f7;
  overflow: hidden;
}

.top-app-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #4ea3cf);
}

.top-app-count {
  width: 42px;
  text-align: right;
  color: var(--muted);
}

.empty-state {
  border: 1px dashed #cbd9e4;
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
  background: #f8fbfd;
}

.inline-empty {
  display: inline-flex;
}

.matrix-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.matrix-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px 28px;
  border-radius: 20px;
  background: linear-gradient(135deg, #10233b, #0d8b8b);
  color: #fff;
  box-shadow: 0 22px 42px rgba(16, 35, 59, 0.2);
}

.matrix-hero h1 {
  margin: 10px 0 8px;
}

.matrix-hero p {
  margin: 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.82);
}

.matrix-hero-actions,
.matrix-kpis {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.matrix-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  margin-top: 18px;
}

.matrix-mini-kpi {
  min-width: 92px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f3f9fb;
  border: 1px solid var(--border);
}

.matrix-mini-kpi span,
.matrix-table small,
.matrix-user-cell small,
.matrix-foot-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.matrix-mini-kpi strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
}

.matrix-card {
  margin-top: 18px;
}

.matrix-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.matrix-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid #e1ebf2;
  border-right: 1px solid #e1ebf2;
  padding: 10px;
  vertical-align: top;
  background: #fff;
}

.matrix-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f6fbfd;
  min-width: 128px;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.matrix-table thead .sticky-col,
.matrix-table tfoot .sticky-col {
  z-index: 4;
  background: #f6fbfd;
}

.matrix-user-col,
.matrix-user-cell {
  min-width: 250px;
  max-width: 250px;
  text-align: left;
}

.matrix-level-select {
  min-width: 112px;
  border-radius: 12px;
  font-weight: 700;
}

.matrix-level-select.level-0 { background: #f6f8fa; }
.matrix-level-select.level-1 { background: #edf2f7; }
.matrix-level-select.level-2 { background: #e6f6f5; }
.matrix-level-select.level-3 { background: #e7f8ef; }
.matrix-level-select.level-4 { background: #fff3dd; }
.matrix-level-select.level-5 { background: #fde8e8; }

.matrix-add-row th,
.matrix-add-row td {
  background: #fbfcfd;
}

.matrix-add-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 860px) {
  .matrix-shell {
    padding: 16px;
  }
  .matrix-hero,
  .matrix-toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }
  .matrix-table-wrap {
    max-height: none;
  }
}

.login-shell {
  width: min(100%, 1180px);
  margin: 80px auto 0;
  padding: 24px;
}

.login-paper {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 10px 24px rgba(1, 25, 62, 0.12);
}

.login-title {
  font-size: 1.45rem;
  margin: 0;
}

.login-stack {
  margin-top: 12px;
  max-width: 420px;
}

.field {
  gap: 6px;
  font-size: 0.92rem;
}

.login-shell input {
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 10px 12px;
}

.login-shell input:focus {
  border-color: #32a3fc;
  box-shadow: 0 0 0 2px rgba(50, 163, 252, 0.15);
  outline: none;
}

.login-btn {
  background: #01193e;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
}

.login-btn:hover {
  background: #032356;
}

.login-launcher {
  margin-top: 18px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid #d7e5ee;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 250, 252, 0.98));
}

.login-launcher-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.login-launcher-head h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.login-launcher-head .muted {
  margin: 0;
  font-size: 0.92rem;
}

/* Three apps per row, in the catalog's order (one column on narrow windows). */
.login-launcher-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .login-launcher-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.launcher-app-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #d7e3eb;
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  color: var(--ink);
  box-shadow: none;
  min-height: 168px;
}

.launcher-app-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.launcher-app-icon {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 12px;
  background: #e6f4f3;
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.launcher-app-name {
  color: var(--accent-strong);
  font-size: 1.05rem;
  font-weight: 700;
}

.launcher-app-description {
  color: var(--muted);
  line-height: 1.45;
  text-align: left;
}

.launcher-app-card:hover {
  filter: none;
  border-color: rgba(13, 139, 139, 0.5);
}

.launcher-app-card.is-selected {
  border-color: rgba(13, 139, 139, 0.72);
  background: linear-gradient(180deg, #f3fffd, #eaf8f7);
  box-shadow: 0 10px 20px rgba(10, 95, 115, 0.08);
}

.launcher-app-card.is-live-link {
  cursor: pointer;
}

.login-session {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: #f4fbfb;
  border: 1px solid #cfe6e2;
}

.session-summary {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.5;
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.login-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.login-link-btn.is-disabled {
  pointer-events: none;
  opacity: 0.55;
}

@media (max-width: 860px) {
  .grid-4 { grid-template-columns: 1fr; }
  .checkbox-label { margin-top: 0; }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .login-launcher-head {
    flex-direction: column;
  }
  .login-shell {
    width: min(100%, 760px);
    margin-top: 40px;
    padding: 16px;
  }
  .login-paper {
    padding: 20px;
  }
  .login-launcher-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid,
  .dashboard-grid,
  .split-grid,
  .overview-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .admin-shell {
    padding: 18px;
  }
  .admin-hero,
  .panel-heading,
  .profile-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .launchpad-grid {
    grid-template-columns: 1fr;
  }
  .user-controls-layout {
    grid-template-columns: 1fr;
  }
  .admin-hero-actions {
    width: 100%;
    align-items: flex-start;
  }
  .status-cluster {
    justify-content: flex-start;
  }
  .top-app-row {
    flex-direction: column;
    align-items: stretch;
  }
  .top-app-label,
  .top-app-count {
    width: auto;
    text-align: left;
  }
}
