:root {
  --blue-primary: #1877F2;
  --blue-hover: #166FE5;
  --blue-light: #E7F3FF;
  --blue-dark: #1565C0;
  --bg-primary: #F0F2F5;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F5F6F7;
  --bg-sidebar: #242526;
  --bg-sidebar-hover: #3A3B3C;
  --bg-sidebar-active: #1877F2;
  --text-primary: #1C1E21;
  --text-secondary: #65676B;
  --text-tertiary: #8A8D91;
  --text-sidebar: #B0B3B8;
  --text-sidebar-active: #FFFFFF;
  --border-color: #CED0D4;
  --border-light: #E4E6EB;
  --green: #31A24C;
  --green-light: #E8F5E9;
  --red: #FA383E;
  --red-light: #FFEBEE;
  --orange: #F5A623;
  --orange-light: #FFF3E0;
  --purple: #8B5CF6;
  --purple-light: #F3E8FF;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.15);
  --shadow-xl: 0 12px 40px rgba(0,0,0,0.2);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  --header-height: 56px;
}

/*
 * When the admin layout is rendered it fills the viewport as a fixed shell.
 * We need html/body to give up their default overflow so the inner flex
 * layout can own scrolling.  The selectors target `body:has(.admin-portal)`
 * to avoid affecting non-admin pages.
 */
html:has(.admin-portal),
html:has(.admin-auth) {
  height: 100%;
  overflow: hidden;
}

body:has(.admin-portal),
body:has(.admin-auth) {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.admin-portal,
.admin-auth {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.admin-portal *,
.admin-portal *::before,
.admin-portal *::after,
.admin-auth *,
.admin-auth *::before,
.admin-auth *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.admin-portal button,
.admin-portal input,
.admin-portal select,
.admin-portal textarea,
.admin-auth button,
.admin-auth input,
.admin-auth select,
.admin-auth textarea {
  font-family: inherit;
  font-size: inherit;
}

.admin-portal button {
  cursor: pointer;
}

.admin-portal a,
.admin-auth a {
  text-decoration: none;
  color: var(--blue-primary);
}

.admin-portal {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.admin-portal .app {
  display: flex;
  height: 100%;
  background: var(--bg-primary);
}

.admin-portal .sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
}

.admin-portal .main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.admin-portal .header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.admin-portal .content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}

.admin-portal .sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.admin-portal .sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--blue-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  margin-right: 12px;
}

.admin-portal .sidebar-brand-text {
  color: #fff;
  font-weight: 600;
  font-size: 16px;
}

.admin-portal .sidebar-brand-badge {
  background: rgba(255,255,255,0.1);
  color: var(--text-sidebar);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 500;
}

.admin-portal .sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.admin-portal .sidebar-section {
  padding: 0 12px;
  margin-bottom: 4px;
}

.admin-portal .sidebar-section-label {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 8px 6px;
}

.admin-portal .sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  user-select: none;
}

.admin-portal .sidebar-item:hover {
  background: var(--bg-sidebar-hover);
  color: #E4E6EB;
}

.admin-portal .sidebar-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.admin-portal .sidebar-item-icon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.admin-portal .sidebar-item.active .sidebar-item-icon {
  opacity: 1;
}

.admin-portal .sidebar-item-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
}

.admin-portal .sidebar-item-badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.admin-portal .sidebar-item-badge--orange {
  background: var(--orange);
}

.admin-portal .sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.admin-portal .sidebar-user {
  display: flex;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.admin-portal .sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  margin-right: 10px;
}

.admin-portal .sidebar-user-name {
  color: #E4E6EB;
  font-size: 13px;
  font-weight: 500;
}

.admin-portal .sidebar-user-role {
  color: var(--text-tertiary);
  font-size: 11px;
}

.admin-portal .header-left,
.admin-portal .header-right,
.admin-portal .header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-portal .header-breadcrumb-item {
  color: var(--text-secondary);
  font-size: 13px;
}

.admin-portal .header-breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 12px;
}

.admin-portal .header-breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
}

.admin-portal .header-search {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 20px;
  padding: 6px 14px;
  width: 240px;
  border: 1px solid transparent;
  transition: all var(--transition);
  cursor: text;
}

.admin-portal .header-search:focus-within {
  background: #fff;
  border-color: var(--blue-primary);
  box-shadow: 0 0 0 2px rgba(24,119,242,0.2);
}

.admin-portal .header-search svg {
  color: var(--text-tertiary);
  margin-right: 8px;
  flex-shrink: 0;
}

.admin-portal .header-search input {
  border: none;
  background: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

.admin-portal .header-search input::placeholder {
  color: var(--text-tertiary);
}

.admin-portal .header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.admin-portal .header-btn:hover {
  background: var(--border-light);
}

.admin-portal .header-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.admin-portal .page-shell {
  display: grid;
  gap: 24px;
}

.admin-portal .page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-portal .page-title {
  font-size: 22px;
  font-weight: 700;
}

.admin-portal .page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.admin-portal .page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue-primary);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.admin-portal .card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.admin-portal .card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-portal .card-title {
  font-size: 15px;
  font-weight: 600;
}

.admin-portal .card-body {
  padding: 20px;
}

.admin-portal .stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.admin-portal .stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.admin-portal .stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.admin-portal .stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-portal .stat-card-icon.blue { background: var(--blue-light); color: var(--blue-primary); }
.admin-portal .stat-card-icon.green { background: var(--green-light); color: var(--green); }
.admin-portal .stat-card-icon.orange { background: var(--orange-light); color: var(--orange); }
.admin-portal .stat-card-icon.purple { background: var(--purple-light); color: var(--purple); }

.admin-portal .stat-card-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.admin-portal .stat-card-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.admin-portal .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.admin-portal .table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-sm);
}

.admin-portal .table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  flex-wrap: wrap;
}

.admin-portal .table-toolbar-left,
.admin-portal .table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-portal .table-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.admin-portal .table-filter:hover {
  background: var(--border-light);
}

.admin-portal .table-filter.active {
  background: var(--blue-light);
  border-color: var(--blue-primary);
  color: var(--blue-primary);
}

.admin-portal .table-search {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  border: 1px solid var(--border-color);
}

.admin-portal .table-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 12px;
  width: 160px;
  color: var(--text-primary);
}

.admin-portal table {
  width: 100%;
  border-collapse: collapse;
}

.admin-portal th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.admin-portal td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  white-space: nowrap;
}

.admin-portal tr:last-child td {
  border-bottom: none;
}

.admin-portal tr:hover td {
  background: var(--bg-tertiary);
}

.admin-portal .table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-portal .table-pagination-pages {
  display: flex;
  gap: 4px;
}

.admin-portal .table-pagination-pages button {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 12px;
}

.admin-portal .table-pagination-pages button.active {
  background: var(--blue-primary);
  color: #fff;
  border-color: var(--blue-primary);
}

.admin-portal .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.admin-portal .badge-green { background: var(--green-light); color: #1B7A31; }
.admin-portal .badge-red { background: var(--red-light); color: #D32F2F; }
.admin-portal .badge-blue { background: var(--blue-light); color: var(--blue-dark); }
.admin-portal .badge-gray { background: var(--bg-tertiary); color: var(--text-secondary); }

.admin-portal .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.admin-portal .badge-dot-green { background: var(--green); }
.admin-portal .badge-dot-red { background: var(--red); }

.admin-portal .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: #fff;
  background: var(--blue-primary);
  flex-shrink: 0;
}

.admin-portal .avatar-xl {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.admin-portal .user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-portal .user-cell-name {
  font-weight: 600;
  font-size: 13px;
}

.admin-portal .user-cell-email {
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-portal .detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  height: 100vh;
  background: var(--bg-secondary);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.admin-portal .detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-portal .detail-title {
  font-size: 15px;
  font-weight: 600;
}

.admin-portal .detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.admin-portal .detail-user-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.admin-portal .detail-user-name {
  font-size: 20px;
  font-weight: 700;
}

.admin-portal .detail-user-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-portal .detail-section {
  margin-bottom: 24px;
}

.admin-portal .detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.admin-portal .detail-field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.admin-portal .detail-field-label {
  color: var(--text-secondary);
}

.admin-portal .detail-field-value {
  font-weight: 500;
  text-align: right;
}

.admin-portal .detail-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-portal .modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-portal .modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  overflow: hidden;
}

.admin-portal .modal-sm { max-width: 440px; }

.admin-portal .modal-header,
.admin-portal .modal-footer {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-portal .modal-footer {
  border-top: 1px solid var(--border-light);
  border-bottom: none;
  justify-content: flex-end;
  gap: 8px;
}

.admin-portal .modal-body {
  padding: 20px;
}

.admin-portal .modal-title {
  font-size: 17px;
  font-weight: 700;
}

.admin-portal .modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.admin-portal .empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}

.admin-portal .empty-state--compact {
  padding: 24px 12px;
}

.admin-portal .empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.admin-portal .empty-state-desc {
  font-size: 13px;
  margin-bottom: 20px;
}

.admin-portal .activity-list {
  display: grid;
}

.admin-portal .activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.admin-portal .activity-item:last-child {
  border-bottom: none;
}

.admin-portal .activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-portal .activity-icon--blue {
  background: var(--blue-light);
  color: var(--blue-primary);
}

.admin-portal .activity-icon--orange {
  background: var(--orange-light);
  color: var(--orange);
}

.admin-portal .activity-text {
  font-size: 13px;
}

.admin-portal .activity-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.admin-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: linear-gradient(180deg, #f7fbff 0%, #eef4fb 100%);
}

.admin-auth--state {
  background: linear-gradient(180deg, #f5f6f7 0%, #eef1f4 100%);
}

.admin-auth__card {
  width: min(420px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.admin-auth__eyebrow {
  margin: 0 0 12px;
  color: var(--blue-primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-auth__title {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 700;
}

.admin-auth__message {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.admin-auth__button {
  width: 100%;
}

.admin-auth__alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--red-light);
  color: #B42318;
  font-size: 13px;
  font-weight: 500;
}

/* SVG icon sizing — sidebar, header, and buttons all use inline SVGs */
.admin-portal .sidebar-item-icon svg {
  width: 18px;
  height: 18px;
}

.admin-portal .header-btn svg {
  width: 18px;
  height: 18px;
}

.admin-portal .stat-card-icon svg {
  width: 20px;
  height: 20px;
}

.admin-portal .activity-icon svg {
  width: 16px;
  height: 16px;
}

.admin-portal .btn svg {
  width: 14px;
  height: 14px;
}

.admin-portal .table-search svg {
  color: var(--text-tertiary);
  margin-right: 6px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* Progress bars */
.admin-portal .progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.admin-portal .progress-bar {
  height: 100%;
  border-radius: 3px;
}

.admin-portal .progress-bar-blue { background: var(--blue-primary); }
.admin-portal .progress-bar-green { background: var(--green); }
.admin-portal .progress-bar-orange { background: var(--orange); }

/* Scrollbars */
.admin-portal ::-webkit-scrollbar {
  width: 6px;
}

.admin-portal ::-webkit-scrollbar-track {
  background: transparent;
}

.admin-portal ::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.admin-portal ::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Row cursor for clickable table rows */
.admin-portal tbody tr[onclick],
.admin-portal tbody tr[data-testid] {
  cursor: pointer;
}

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

@media (max-width: 900px) {
  .admin-portal .sidebar {
    width: 220px;
  }

  .admin-portal .header-search {
    width: 180px;
  }

  .admin-portal .detail-panel {
    width: min(100vw, 420px);
  }
}
