/* ==========================================================================
   Hey Hoolo — Admin console
   Security-oriented but on-brand: dark navy rail, calm light work area, and
   status colours that never hide a real security event.
   Shared tokens come from ../tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Legacy variable aliases — admin.js writes some of these into inline styles
   (renderReview and the security-event level badges). Keep them defined.
   -------------------------------------------------------------------------- */
:root {
  --accent-primary: var(--hh-blue);
  --accent-2: var(--hh-purple);
  --accent-grad: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  --success: var(--hh-mint);
  --warning: var(--hh-amber-bright);
  --danger: var(--hh-red);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--hh-font-ui);
}

body {
  background-color: var(--hh-canvas);
  background-image:
    radial-gradient(1000px 560px at 88% -12%, rgba(108, 75, 244, 0.12), transparent 62%),
    radial-gradient(760px 480px at 4% 106%, rgba(29, 95, 208, 0.09), transparent 60%);
  color: var(--hh-ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--hh-purple);
  text-underline-offset: 2px;
}

.hh-owl-glyph {
  width: 100%;
  height: 100%;
  display: block;
  color: inherit;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

.pad {
  padding: 1.4rem;
}

.full-height {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.subtitle {
  color: var(--hh-ink-muted);
  font-size: 0.86rem;
  margin-bottom: 1rem;
}

.hint {
  color: var(--hh-ink-muted);
  font-size: 0.75rem;
}

.glass-card {
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius-md);
  box-shadow: var(--hh-shadow-sm);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--hh-font-ui);
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: var(--hh-radius);
  transition: transform var(--hh-t-fast) var(--hh-ease), background var(--hh-t) var(--hh-ease),
    border-color var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease),
    filter var(--hh-t) var(--hh-ease);
  padding: 0.65rem 1.15rem;
  min-height: var(--hh-tap);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: none;
}

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

.btn-primary {
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  color: var(--hh-ink-on-accent);
  position: relative;
  box-shadow: var(--hh-shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: var(--hh-shadow);
}

.btn-outline {
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-purple);
}

.btn-outline:hover:not(:disabled) {
  background: var(--hh-purple-soft);
  border-color: var(--hh-purple);
}

.btn-text {
  background: transparent;
  color: var(--hh-ink-muted);
  padding: 0;
  min-height: auto;
  text-align: left;
}

.btn-text:hover:not(:disabled) {
  color: var(--hh-purple);
  transform: none;
}

.btn-danger {
  background: var(--hh-red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-success {
  background: var(--hh-mint);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-warning {
  background: var(--hh-amber-bright);
  color: #2a1a00;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  min-height: 34px;
  font-size: 0.78rem;
  border-radius: var(--hh-radius-sm);
}

/* --------------------------------------------------------------------------
   Views
   -------------------------------------------------------------------------- */
.view-container {
  min-height: 100vh;
  display: flex;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
#login-view {
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.login-wrap {
  width: 100%;
  max-width: 430px;
}

.login-box {
  width: 100%;
  padding: 2.2rem;
  text-align: center;
  box-shadow: var(--hh-shadow-md);
}

.login-box h3 {
  margin-bottom: 0.45rem;
  font-family: var(--hh-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-box p {
  color: var(--hh-ink-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.subtitle-center {
  max-width: 34ch;
  margin-left: auto;
  margin-right: auto;
}

.console-label {
  margin: 0.6rem 0 1rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hh-purple);
}

.console-label-sm {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hh-navy-ink-muted);
}

.step-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--hh-ink) !important;
}

.step-badge {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--hh-purple-soft);
  color: var(--hh-purple);
  font-size: 0.72rem;
  font-weight: 800;
}

.mfa-hint {
  margin-bottom: 1rem !important;
}

.login-box__foot {
  margin: 1.6rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--hh-line);
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.login-box__foot a {
  color: var(--hh-ink-muted);
  text-decoration: none;
}

.login-box__foot a:hover {
  color: var(--hh-purple);
  text-decoration: underline;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.logo-container.sm {
  justify-content: flex-start;
}

.logo-icon {
  width: 42px;
  height: 42px;
  padding: 7px;
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-deep) 100%);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.logo-text h2 {
  font-family: var(--hh-font-display);
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #fff;
}

.form-group {
  text-align: left;
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--hh-ink-soft);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  min-height: var(--hh-tap);
  border-radius: var(--hh-radius);
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink);
  font-size: 0.9rem;
  font-family: var(--hh-font-ui);
  transition: border-color var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease);
}

#new-roles {
  min-height: auto;
  padding: 0.4rem;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--hh-purple);
  box-shadow: 0 0 0 4px var(--hh-purple-ring);
  outline: none;
}

#login-btn,
#mfa-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#mfa-cancel {
  width: 100%;
  margin-top: 0.6rem;
  text-align: center;
  display: flex;
  justify-content: center;
}

.error-msg {
  color: var(--hh-red);
  font-size: 0.86rem;
  font-weight: 600;
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--hh-red-soft);
  border-radius: var(--hh-radius);
  text-align: left;
}

.inline-msg {
  font-size: 0.86rem;
  font-weight: 600;
  margin-top: 0.8rem;
  color: var(--hh-ink-soft);
  padding: 0.6rem 0.75rem;
  background: var(--hh-surface-sunk);
  border-radius: var(--hh-radius);
}

.inline-msg.ok {
  color: var(--hh-mint-strong);
  background: var(--hh-mint-soft);
}

.inline-msg.bad {
  color: var(--hh-red);
  background: var(--hh-red-soft);
}

.loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hh-spin 900ms linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes hh-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.secret-box {
  display: block;
  background: var(--hh-surface-sunk);
  border: 1px dashed var(--hh-purple);
  padding: 0.75rem 0.9rem;
  border-radius: var(--hh-radius);
  font-family: var(--hh-font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
  user-select: all;
  text-align: left;
}

/* ==========================================================================
   RAIL
   ========================================================================== */
.sidebar {
  width: 274px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--hh-navy-900) 0%, var(--hh-navy-800) 100%);
  color: var(--hh-navy-ink);
  padding: 1.35rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 70;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.9rem;
}

.sidebar__close {
  display: none;
  margin-left: auto;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hh-navy-line);
  color: var(--hh-navy-ink-muted);
}

.sidebar__close svg {
  width: 20px;
  height: 20px;
}

.sidebar__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-menu {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.nav-item {
  padding: 0.7rem 0.85rem;
  min-height: var(--hh-tap);
  border-radius: var(--hh-radius);
  color: var(--hh-navy-ink-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--hh-t) var(--hh-ease), color var(--hh-t) var(--hh-ease);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--hh-navy-ink);
  background: rgba(15, 157, 118, 0.16);
  border: 1px solid rgba(15, 157, 118, 0.4);
  padding: 0.5rem 0.75rem;
  border-radius: var(--hh-radius);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hh-navy-line);
}

.avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-deep) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.05rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.user-roles {
  color: var(--hh-navy-ink-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.user-info button {
  font-size: 0.78rem;
  color: var(--hh-navy-ink-muted);
  padding: 0;
  min-height: auto;
  margin-top: 0.1rem;
}

.user-info button:hover {
  color: #fff;
  transform: none;
}

.sidebar-scrim {
  display: none;
}

/* ==========================================================================
   MAIN
   ========================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.7rem 2.5rem;
  overflow-y: auto;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.top-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-header__menu {
  display: none;
  min-width: var(--hh-tap);
  min-height: var(--hh-tap);
  padding: 0;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink-soft);
}

.top-header__menu svg {
  width: 22px;
  height: 22px;
}

.top-header__menu:hover {
  background: var(--hh-purple-soft);
  color: var(--hh-purple);
}

.top-header h1 {
  font-family: var(--hh-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--hh-ink);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--hh-ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  padding: 0.5rem 0.9rem;
  border-radius: var(--hh-radius-pill);
  box-shadow: var(--hh-shadow-xs);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--hh-ink-muted);
  flex-shrink: 0;
}

.dot.healthy {
  background: var(--hh-mint);
  box-shadow: 0 0 8px var(--hh-mint);
}

/* admin.js toggles the literal `hidden` class to switch panels. */
.content-panel {
  display: block;
}

.content-panel.hidden {
  display: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.grid-2 h3,
.mfa-card h3,
.mfa-recovery h3 {
  font-family: var(--hh-font-display);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.panel-header__titles {
  display: flex;
  flex-direction: column;
}

.panel-header__titles .subtitle {
  margin-bottom: 0;
}

.panel-header h3 {
  font-family: var(--hh-font-display);
  font-size: 1.05rem;
  font-weight: 800;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-container {
  overflow-x: auto;
  flex: 1;
  border-radius: 0 0 var(--hh-radius-md) var(--hh-radius-md);
}

.data-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--hh-line);
  vertical-align: middle;
}

.data-table th {
  color: var(--hh-ink-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  white-space: nowrap;
}

.data-table tbody tr:hover td {
  background: var(--hh-surface-sunk);
}

.data-table td .btn-sm {
  margin-right: 0.35rem;
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   BADGES — status is never conveyed by colour alone; each carries a label
   ========================================================================== */
.badge {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  border-radius: var(--hh-radius-pill);
  font-size: 0.71rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  background: var(--hh-mint-soft);
  color: var(--hh-mint-strong);
}

.badge.warning {
  background: var(--hh-amber-soft);
  color: var(--hh-amber);
}

.badge.danger {
  background: var(--hh-red-soft);
  color: var(--hh-red);
}

.badge.neutral {
  background: var(--hh-line);
  color: var(--hh-ink-soft);
}

.badge.info {
  background: var(--hh-blue-soft);
  color: var(--hh-blue);
}

/* ==========================================================================
   ACCESS REVIEW SUMMARY PILLS
   ========================================================================== */
.metrics-row {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.metric-pill {
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius);
  padding: 0.85rem 1.05rem;
  min-width: 150px;
  flex: 1;
}

.metric-pill .v {
  font-family: var(--hh-font-display);
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: -0.025em;
  color: var(--hh-ink);
}

.metric-pill .l {
  color: var(--hh-ink-muted);
  font-size: 0.76rem;
  font-weight: 600;
}

/* ==========================================================================
   MFA
   ========================================================================== */
.mfa-layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.mfa-card__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
}

.mfa-card__head .subtitle {
  margin-bottom: 0;
}

.mfa-shield {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px;
  background: var(--hh-purple-soft);
  border-radius: var(--hh-radius);
  color: var(--hh-purple);
}

.mfa-shield svg {
  width: 100%;
  height: 100%;
}

.mfa-why {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--hh-ink-soft);
  padding: 0.85rem 0.95rem;
  background: var(--hh-surface-sunk);
  border-left: 3px solid var(--hh-purple);
  border-radius: var(--hh-radius);
  margin-bottom: 1rem;
}

.mfa-step {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--hh-ink-soft);
}

.mfa-recovery {
  background: linear-gradient(160deg, var(--hh-amber-soft) 0%, var(--hh-surface) 60%);
}

.mfa-recovery p {
  margin-top: 0.7rem;
  font-size: 0.87rem;
  line-height: 1.65;
  color: var(--hh-ink-soft);
}

/* ==========================================================================
   RESPONSIVE — 1280 / 768 / 390
   ========================================================================== */
@media (max-width: 1180px) {
  .grid-2,
  .mfa-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: min(84vw, 290px);
    transform: translateX(-100%);
    transition: transform var(--hh-t-slow) var(--hh-ease);
    box-shadow: var(--hh-shadow-lg);
  }

  .sidebar.is-open {
    transform: none;
  }

  .sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(22, 19, 56, 0.45);
    backdrop-filter: blur(2px);
  }

  .sidebar-scrim[hidden] {
    display: none;
  }

  .top-header__menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.hh-drawer-open {
    overflow: hidden;
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 1rem 0.9rem 2rem;
  }

  .top-header {
    align-items: center;
  }

  .login-box {
    padding: 1.7rem 1.3rem;
  }

  .metrics-row {
    flex-direction: column;
  }

  .metric-pill {
    min-width: 0;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-header button {
    width: 100%;
  }

  .pad {
    padding: 1.1rem;
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }

  button:hover:not(:disabled) {
    transform: none !important;
  }

  .loader {
    animation: none !important;
  }
}
