/* PubHub Base Styles */

/* Typography - refined serif/sans pairing */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=DM+Sans:wght@400;500;600&display=swap');

/* Global typography and polish (both themes) */
:root {
  --pubhub-font-heading: 'Source Serif 4', Georgia, serif;
  --pubhub-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --pubhub-shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.1);
  --pubhub-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
  --pubhub-accent: #6366f1;
}

body {
  font-family: var(--pubhub-font-body);
  font-size: 0.9rem;
}

/* Standard text sizing for content (not headers) */
p, td, th, li, label, span, .text-content {
  font-size: 0.85rem;
}

table {
  font-size: 0.85rem;
}

/* Override Pico container to ensure consistent centering */
main.container {
  max-width: 1400px;
  padding-left: 1rem;
  padding-right: 1rem;
  min-height: 100vh;
  background: transparent;
}

h1, h2, h3, h4 {
  font-family: var(--pubhub-font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Dark theme refinements */
[data-theme="dark"] {
  --pubhub-accent: #818cf8;
}

[data-theme="dark"] body {
  /* Subtle gradient - no fixed attachment (causes scroll jitter) */
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
}

[data-theme="dark"] .service-card {
  
}

[data-theme="dark"] .team-card:hover,
[data-theme="dark"] .machine-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .login-card {
  
}

[data-theme="dark"] input:focus,
[data-theme="dark"] button:focus {
  border-color: var(--pubhub-accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

[data-theme="dark"] .modal-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Light theme specific overrides */
[data-theme="light"] {
  --pubhub-font-heading: 'Source Serif 4', Georgia, serif;
  --pubhub-font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --pubhub-bg-warm: #faf9f7;
  --pubhub-bg-card: #ffffff;
  --pubhub-border-soft: rgba(0, 0, 0, 0.06);
  --pubhub-shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --pubhub-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --pubhub-text-primary: #1a1a1a;
  --pubhub-text-secondary: #525252;
  --pubhub-accent-warm: #4f46e5;
}

[data-theme="light"] body {
  font-family: var(--pubhub-font-body);
  background: #ffffff;
}

[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4 {
  font-family: var(--pubhub-font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--pubhub-text-primary);
}

/* Page loading overlay */
#page-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--pico-muted-border-color);
  border-top-color: var(--pico-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Login Container */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--pico-card-background-color);
  border-radius: 1rem;
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header .logo {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  color: var(--pico-primary);
}

.login-header h1 {
  margin: 0;
  font-size: 2rem;
}

.login-header .tagline {
  color: var(--pico-muted-color);
  margin: 0.5rem 0 0;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card input {
  text-align: center;
  font-size: 1rem;
  padding: 0.875rem;
}

.login-card button {
  width: 100%;
}

.error-msg {
  color: var(--pico-del-color);
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.login-toggle {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8rem;
}

.login-toggle a {
  color: var(--pico-muted-color);
  text-decoration: none;
}

.login-toggle a:hover {
  color: var(--pico-primary);
  text-decoration: underline;
}

/* Main View Container - inherits centering from Pico .container */
#main-view {
  width: 100%;
}

/* Portal Header */
.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.header-left h1 {
  margin: 0;
  font-size: 1.5rem;
}

.version-badge {
  font-size: 0.7rem;
  color: #8b9bb4;
  font-weight: 500;
}

.logo-small {
  width: 32px;
  height: 32px;
  color: var(--pico-primary);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--pico-muted-color);
  text-decoration: none;
  font-size: 0.9rem;
  
}

.nav-link:hover,
.nav-link.active {
  color: var(--pico-primary);
}

.nav-link.logout {
  color: var(--pico-del-color);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--pico-muted-color);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
}

/* Services Filter */
.services-filter {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.services-filter .env-toggle-detail {
  margin-left: auto;
}

/* Environment Toggle */
.env-toggle {
  display: flex;
  gap: 0;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  padding: 0.2rem;
  border: 1px solid var(--pico-muted-border-color);
}

.env-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--pico-muted-color);
  cursor: pointer;
  border-radius: 0.35rem;
  
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.env-btn:hover {
  color: var(--pico-color);
}

.env-btn.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary);
}

.env-btn[data-env="production"].active {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.env-btn[data-env="development"].active {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

[data-theme="light"] .env-btn[data-env="production"].active {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

[data-theme="light"] .env-btn[data-env="development"].active {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

/* Environment select in detail page */
/* Environment select/label in detail info grid */
.env-select {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 1rem;
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2322c55e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
}

.env-select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.env-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.env-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.env-label.prod {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.env-label.dev {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

[data-theme="light"] .env-select {
  border-color: rgba(22, 163, 74, 0.4);
  background-color: rgba(22, 163, 74, 0.08);
  color: #16a34a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="light"] .env-label.prod {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.2);
}

[data-theme="light"] .env-label.dev {
  background: rgba(217, 119, 6, 0.1);
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.2);
}

.filter-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.services-filter input {
  width: 100%;
  padding: 0.6rem 2.5rem 0.6rem 1rem;
  font-size: 0.9rem;
  border-radius: 0.5rem;
  margin-bottom: 0;
}

.filter-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--pico-muted-color);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  
}

.filter-clear:hover {
  color: var(--pico-color);
}

.filter-wrapper.has-value .filter-clear {
  opacity: 1;
  visibility: visible;
}

.filter-count {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

/* Pending services filter toggle */
.pending-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 1rem;
  background: transparent;
  color: #f59e0b;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.pending-toggle:hover {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.5);
}

.pending-toggle.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.6);
}

.pending-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 0.6rem;
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.pending-toggle.active .pending-count {
  background: rgba(245, 158, 11, 0.35);
}

[data-theme="light"] .pending-toggle {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.35);
}

[data-theme="light"] .pending-toggle:hover {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.5);
}

[data-theme="light"] .pending-toggle.active {
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.5);
}

[data-theme="light"] .pending-count {
  background: rgba(217, 119, 6, 0.15);
  color: #d97706;
}

[data-theme="light"] .pending-toggle.active .pending-count {
  background: rgba(217, 119, 6, 0.25);
}

/* Services Section */
.services-section {
  margin-bottom: 2.5rem;
}

.services-section:last-child {
  margin-bottom: 0;
}

.services-section h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  color: var(--pico-color);
}

/* Services Grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.service-card {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 1.25rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  
  border: 2px solid rgba(255, 255, 255, 0.08);
  height: 280px; /* fixed height */
  overflow: hidden;
}

.service-card:hover {
  border: 2px solid #5b9bd5; /* blueish */
}

/* No-access service cards - greyed out but Details button interactive */
.service-card.disabled {
  position: relative;
}

/* Grey out the card content except footer */
.service-card.disabled h3,
.service-card.disabled p,
.service-card.disabled .status-dot,
.service-card.disabled .version-badge,
.service-card.disabled .heartbeat-ts,
.service-card.disabled .service-url,
.service-card.disabled .access-badge {
  opacity: 0.4;
}

/* Details button on disabled cards - full opacity and natural hover */
.service-card.disabled .btn-details {
  opacity: 1;
  
}

.service-card.disabled .btn-details:hover {
  background: #388bfd;
  border-color: #388bfd;
  transform: translateY(-1px);
}

/* Service Status Indicators */
.service-card {
  position: relative;
}

/* Heartbeat timestamp (bottom right) */
.heartbeat-ts {
  position: absolute;
  bottom: 0.2rem;
  right: 0.75rem;
  font-size: 0.55rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.6);
}

/* Service URL (bottom left of card) */
.service-url {
  position: absolute;
  bottom: 0.2rem;
  left: 1.75rem; /* flush with content */
  right: 5rem; /* leave room for timestamp on right */
  font-size: 0.55rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  position: absolute;
  top: 0.4rem;
  left: 0.6rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pico-muted-color);
  cursor: help;
}

.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.status-dot.idle {
  background: #f59e0b;
}

.status-dot.offline {
  background: #ef4444;
}

/* Custom tooltip for status dot - abundantly clear */
.status-dot::after {
  content: attr(data-status);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Tooltip arrow */
.status-dot::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 3px;
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  visibility: hidden;
  
  z-index: 100;
}

.status-dot:hover::after,
.status-dot:hover::before {
  opacity: 1;
  visibility: visible;
}

.service-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  padding-bottom: 0;
  margin-left: 0.75rem;
  margin-right: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
}

.service-footer button {
  position: relative;
  z-index: 11;
  pointer-events: auto;
}

.service-status {
  font-size: 0.6rem;
  color: var(--pico-muted-color);
}

.service-card h3 {
  margin: 0.25rem 0 0.4rem;
  font-size: 1.1rem;
  padding-left: 0.75rem;
}

.service-card p {
  color: var(--pico-muted-color);
  margin: 0;
  font-size: 0.8rem;
  flex: 1;
  line-height: 1.4;
  padding-left: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Light mode: ensure description text has good contrast */
[data-theme="light"] .service-card p {
  color: #4b5563;
}

.service-card .service-access {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.6rem;
  color: var(--pico-muted-color);
}

.access-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.access-badge.admin { background: rgba(31, 111, 235, 0.15); color: #1f6feb; }
.access-badge.write { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.access-badge.read { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.access-badge.none { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

/* API/Service type cards (not clickable for SSO) */
.service-card.service-type-api {
  cursor: default;
}

/* Web service card clickable area (title + description) */
.service-card-clickable {
  flex: 1;
}

/* Card header with title and badges */
.service-card .card-header {
  margin-bottom: 0.5rem;
}

.service-card .card-header h3 {
  margin-bottom: 0.4rem;
}

.service-card .card-description {
  flex: 1;
  margin-bottom: 0.5rem;
}

/* Type badges container - spread across width */
.type-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Type badge - refined ghost chip style */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--pubhub-font-body);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.3rem 0.6rem;
  border-radius: 2px;
  text-decoration: none;
  cursor: pointer;
  /* Ghost style - border only, no fill */
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  
}

.type-badge::before {
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Icons for each type */
.type-badge.type-web::before,
.type-badge.type-website::before { content: "◎"; }
.type-badge.type-service::before { content: "⬡"; }
.type-badge.type-api::before { content: "⬢"; }
.type-badge.type-mcp::before { content: "◈"; }
.type-badge.type-docs::before { content: "▤"; }

/* Hover states - add color accent */
.type-badge:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.type-badge.type-web:hover,
.type-badge.type-website:hover {
  border-color: #22c55e;
  color: #4ade80;
}

.type-badge.type-service:hover,
.type-badge.type-api:hover {
  border-color: #3b82f6;
  color: #60a5fa;
}

.type-badge.type-mcp:hover {
  border-color: #8b5cf6;
  color: #a78bfa;
}

.type-badge.type-docs:hover {
  border-color: #f59e0b;
  color: #fbbf24;
}

/* Inactive/non-clickable badges */
.type-badge.inactive {
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}


/* Light theme - invert ghost style */
[data-theme="light"] .type-badge {
  border-color: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .type-badge:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.25);
  color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .type-badge.type-web:hover,
[data-theme="light"] .type-badge.type-website:hover {
  border-color: #16a34a;
  color: #16a34a;
}

[data-theme="light"] .type-badge.type-service:hover,
[data-theme="light"] .type-badge.type-api:hover {
  border-color: #2563eb;
  color: #2563eb;
}

[data-theme="light"] .type-badge.type-mcp:hover {
  border-color: #7c3aed;
  color: #7c3aed;
}

[data-theme="light"] .type-badge.type-docs:hover {
  border-color: #d97706;
  color: #d97706;
}

/* Card top-right actions container (version + delete side by side) */
.service-card .card-top-actions {
  position: absolute;
  top: 0.4rem;
  right: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.service-card .version-badge {
  font-size: 0.6rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  padding: 0;
}

/* Inline delete button for service cards (admin only) */
.service-card .btn-delete-inline {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  
  display: flex;
  align-items: center;
}
.service-card .btn-delete-inline svg {
  width: 14px;
  height: 14px;
  stroke: #ef4444;
}
.service-card .btn-delete-inline:hover {
  opacity: 0.7;
}

.api-url {
  font-size: 0.75rem;
  color: var(--pico-primary);
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--pico-primary-background);
}

.api-url:hover {
  text-decoration: underline;
}

/* Admin Controls */
.admin-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.btn-admin {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid;
  cursor: pointer;
  margin: 0 0.25rem;
  font-weight: 500;
  
}

.btn-admin.btn-approve {
  background: #238636;
  border-color: #238636;
  color: #fff;
}
.btn-admin.btn-approve:hover {
  background: #2ea043;
}

.btn-admin.btn-enable {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}
.btn-admin.btn-enable:hover {
  background: #388bfd;
}

.btn-admin.btn-disable {
  background: transparent;
  border-color: #f0883e;
  color: #f0883e;
}
.btn-admin.btn-disable:hover {
  background: rgba(240, 136, 62, 0.15);
}

.btn-admin.btn-delete {
  background: transparent;
  border-color: #f85149;
  color: #f85149;
}
.btn-admin.btn-delete:hover {
  background: rgba(248, 81, 73, 0.15);
}

/* Icon buttons for table actions */
.btn-icon, .btn-trash {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.7;
  
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg, .btn-trash svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}
.btn-icon {
  color: var(--pico-primary);
}
.btn-trash {
  color: #f85149;
}
.btn-icon:hover, .btn-trash:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* Actions cell - buttons always side by side */
td:has(.btn-icon, .btn-trash) {
  white-space: nowrap;
}
td .btn-icon + .btn-trash,
td .btn-trash + .btn-icon {
  margin-left: 0.5rem;
}

/* Status badges for pending/disabled */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.status-badge.pending {
  background: rgba(240, 136, 62, 0.2);
  color: #f0883e;
}

.status-badge.disabled {
  background: rgba(248, 81, 73, 0.2);
  color: #f85149;
}

/* Pending/Disabled service cards */
.pending-card, .disabled-card {
  border: 1px dashed var(--pico-muted-border-color);
  opacity: 0.9;
}

.pending-card {
  padding: 0 0 1rem 0;
}

.pending-card h3 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.pending-card p {
  padding-left: 1rem;
  padding-right: 1rem;
}

.pending-card .admin-controls {
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Pending header bar */
.pending-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(240, 136, 62, 0.15);
  border-radius: 0.65rem 0.65rem 0 0;
  margin-bottom: 0.75rem;
}

.pending-date {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--pico-muted-color);
}

.pending-header .status-badge {
  margin-bottom: 0;
}

.pending-section h2, .disabled-section h2 {
  color: var(--pico-muted-color);
}

.service-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin: 0.5rem 0;
}

/* Team Grid - now used for users table */
.team-grid {
  width: 100%;
}

.team-card {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: center;
  border: 1px solid var(--pico-muted-border-color);
  
}

.team-card.is-you {
  border-color: var(--pico-primary);
}

.team-card .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--pico-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 auto 1rem;
}

.team-card h4 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.team-card .you-tag {
  font-weight: 400;
  color: var(--pico-primary);
  font-size: 0.85rem;
}

.team-card .team-email {
  color: var(--pico-muted-color);
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  word-break: break-word;
}

.team-card .team-joined {
  color: var(--pico-muted-color);
  margin: 0;
  font-size: 0.7rem;
}

.team-card .team-username {
  color: var(--pico-muted-color);
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.team-card .team-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.5rem 0;
  font-size: 0.75rem;
}

.team-card .user-detail {
  color: var(--pico-muted-color);
  word-break: break-all;
}

.team-card .user-detail strong {
  color: var(--pico-color);
  font-weight: 500;
}

.team-badges {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.team-card .badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

.team-card .badge-totp {
  background: var(--pico-ins-color);
  color: #fff;
}

/* Profile */
.profile-card {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--pico-muted-border-color);
}

.profile-card .profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Avatar Large - used in profile and user detail modal */
.avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--pico-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 600;
  flex-shrink: 0;
}

.profile-info h3 {
  margin: 0 0 0.25rem;
}

.profile-info p {
  color: var(--pico-muted-color);
  margin: 0;
  font-size: 0.875rem;
}

.profile-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.profile-detail {
  padding: 1rem;
  background: var(--pico-background-color);
  border-radius: 0.5rem;
}

.profile-detail label {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  display: block;
  margin-bottom: 0.25rem;
}

.profile-detail span {
  font-weight: 500;
}

/* My API Keys (profile page) */
.my-apikeys {
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.my-apikeys .apikeys-list {
  margin-bottom: 0;
}

/* User Link in table */
.user-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--pico-muted-color);
}

.user-link:hover {
  color: var(--pico-primary);
  border-bottom-color: var(--pico-primary);
}

/* User Detail Modal */
.user-detail-modal h5 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-detail-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.user-detail-info h4 {
  margin: 0;
  font-size: 1.1rem;
}

.user-detail-info p {
  margin: 0.25rem 0;
  color: var(--pico-muted-color);
}

.user-detail-section {
  background: var(--pico-background-color);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--pico-muted-color);
  font-size: 0.85rem;
}

.detail-value {
  font-weight: 500;
}

.detail-value code {
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
  background: var(--pico-card-background-color);
  border-radius: 0.25rem;
}

/* Machines List */
.machines-list {
  display: grid;
  gap: 1rem;
}

.machine-card {
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--pico-muted-border-color);
}

.machine-card h4 {
  margin: 0 0 0.25rem;
}

.machine-card .machine-id {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

.machine-card .last-seen {
  text-align: right;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

/* Access Summary */
.access-summary {
  margin-bottom: 2rem;
}

.access-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
}

.access-table th,
.access-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.access-table th {
  background: var(--pico-background-color);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.access-table tbody tr:last-child td {
  border-bottom: none;
}

.access-table tbody tr:hover {
  background: var(--pico-background-color);
}

.access-table tbody tr.no-access {
  opacity: 0.5;
}

.type-badge.small {
  font-size: 0.65rem;
  padding: 0.2rem 0.45rem;
  border-radius: 0.75rem;
}

/* Type badge colors - high contrast */
.type-badge.web { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.type-badge.service { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
.type-badge.api { background: rgba(251, 146, 60, 0.2); color: #fb923c; }
.type-badge.mcp { background: rgba(168, 85, 247, 0.2); color: #a855f7; }
.type-badge.cli { background: rgba(236, 72, 153, 0.2); color: #ec4899; }
.type-badge.library { background: rgba(20, 184, 166, 0.2); color: #14b8a6; }

[data-theme="light"] .type-badge.web { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
[data-theme="light"] .type-badge.service { background: rgba(37, 99, 235, 0.12); color: #2563eb; }
[data-theme="light"] .type-badge.api { background: rgba(234, 88, 12, 0.12); color: #ea580c; }
[data-theme="light"] .type-badge.mcp { background: rgba(147, 51, 234, 0.12); color: #9333ea; }
[data-theme="light"] .type-badge.cli { background: rgba(219, 39, 119, 0.12); color: #db2777; }
[data-theme="light"] .type-badge.library { background: rgba(13, 148, 136, 0.12); color: #0d9488; }

/* Tool Access Levels Table */
.tool-access-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
  margin-bottom: 1.5rem;
}

.tool-access-table th,
.tool-access-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--pico-muted-border-color);
  vertical-align: middle;
}

.tool-access-table th {
  background: var(--pico-background-color);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.tool-access-table tbody tr:last-child td {
  border-bottom: none;
}

.tool-list code {
  display: inline-block;
  background: var(--pico-background-color);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  margin: 0.1rem;
  border: 1px solid var(--pico-muted-border-color);
}

/* Editable Tool Access Table (for admins) */
.tool-access-table-editable {
  width: 100%;
  border-collapse: collapse;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
  margin-bottom: 0.5rem;
}

.tool-access-table-editable th,
.tool-access-table-editable td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--pico-muted-border-color);
  vertical-align: middle;
}

.tool-access-table-editable th {
  background: var(--pico-background-color);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.tool-access-table-editable tbody tr:last-child td {
  border-bottom: none;
}

.tool-access-table-editable tbody tr:hover {
  background: var(--pico-background-color);
}

.tool-access-table-editable code {
  font-size: 0.75rem;
  background: transparent;
  padding: 0;
  vertical-align: middle;
}

/* Ensure all content in tool table cells is vertically centered */
.tool-access-table td,
.tool-access-table-editable td {
  vertical-align: middle !important;
}

.tool-access-table td > *,
.tool-access-table-editable td > * {
  vertical-align: middle;
}

/* Tool description column */
.tool-description {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  line-height: 1.4;
  max-width: 400px;
}

.tool-access-table .tool-description,
.tool-access-table-editable .tool-description {
  font-size: 0.75rem;
}

/* Level group header row */
.level-group-header td {
  background: var(--pico-card-background-color);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 1rem 0.75rem 0.75rem !important;
  border-bottom: none !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-group-header:first-child td {
  padding-top: 0.5rem !important;
}

.level-group-header:hover td {
  background: var(--pico-card-background-color) !important;
}

.level-group-header .access-badge {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

/* Tool level dropdown */
.tool-level-select {
  padding: 0.35rem 1.75rem 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  border: 2px solid var(--pico-muted-border-color);
  border-radius: 0.3rem;
  background: var(--pico-background-color);
  color: var(--pico-color);
  cursor: pointer;
  width: 100px;
  vertical-align: middle;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  background-size: 0.75rem;
  
}

.tool-level-select:hover {
  border-color: var(--pico-primary);
  background-color: rgba(31, 111, 235, 0.05);
}

.tool-level-select:focus {
  outline: none;
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25);
}

/* Reset button per tool */
.btn-reset-tool {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.25rem;
  background: transparent;
  color: var(--pico-muted-color);
  cursor: pointer;
  
  vertical-align: middle;
  margin: 0;
}

.btn-reset-tool:hover:not(:disabled) {
  border-color: var(--pico-primary);
  color: var(--pico-primary);
  background: rgba(31, 111, 235, 0.1);
}

.btn-reset-tool:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Default level display */
.tool-default {
  font-size: 0.7rem;
  color: var(--pico-muted-color);
}

.tool-default.customized {
  color: #f59e0b;
  font-weight: 500;
}

/* Reset all button */
.btn-reset-all {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.25rem;
  background: transparent;
  color: var(--pico-muted-color);
  cursor: pointer;
  
}

.btn-reset-all:hover {
  border-color: #f59e0b;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

/* Light mode: Editable Tool Access Table */
[data-theme="light"] .tool-access-table-editable {
  border-color: #e5e7eb;
}

[data-theme="light"] .tool-access-table-editable th {
  background: #f9fafb;
}

[data-theme="light"] .tool-access-table-editable th,
[data-theme="light"] .tool-access-table-editable td {
  border-color: #e5e7eb;
}

[data-theme="light"] .tool-level-select {
  background: #fff;
  border-color: #d1d5db;
}

[data-theme="light"] .btn-reset-tool,
[data-theme="light"] .btn-reset-all {
  border-color: #d1d5db;
}

/* Pages */
.page {
  animation: fadeIn 0.2s ease;
}

.page h2 {
  margin-bottom: 1.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .portal-header {
    flex-direction: column;
    gap: 1rem;
  }

  .header-nav {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* Service Detail Page */
.service-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.back-link {
  color: var(--pico-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

.service-detail-card {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--pico-muted-border-color);
}

.service-detail-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.service-detail-header-info {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.service-status-indicator {
  padding-top: 0.5rem;
}

.service-status-indicator .status-dot {
  position: relative;
  top: auto;
  left: auto;
}

.service-title-section {
  flex: 1;
}

.service-title-section h2 {
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.service-id {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin: 0;
}

.service-version {
  font-family: monospace;
  font-size: 1rem;
  color: var(--pico-muted-color);
}

/* Status indicator in top right corner */
.service-status-corner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.25rem 0.5rem;
}

.status-dot-corner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.status-text-corner {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.service-status-corner.online { color: #22c55e; }
.service-status-corner.idle { color: #f59e0b; }
.service-status-corner.offline { color: #ef4444; }

.service-description {
  color: var(--pico-muted-color);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

/* Service Detail - Environment + Types Row */
.service-env-types-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.types-section-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.types-label {
  color: var(--pico-muted-color);
  font-size: 0.85rem;
}

.lastseen-section {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.lastseen-section .heartbeat-label {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  white-space: nowrap;
}

.env-section {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex: 1;
}

.types-section {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 1;
}

/* Medium-sized environment dropdown */
.env-select-medium {
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0.375rem;
  border: 1px solid rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2322c55e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.env-select-medium:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.env-label-medium {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0.375rem;
}

.env-label-medium.prod {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.env-label-medium.dev {
  background: rgba(251, 146, 60, 0.15);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.3);
}

/* Current environment label */
.env-current {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.env-current.prod {
  color: #22c55e;
}

.env-current.dev {
  color: #f59e0b;
}

/* Environment toggle in detail page */
.env-toggle-detail {
  display: inline-flex;
  background: rgba(0,0,0,0.2);
  border-radius: 0.375rem;
  padding: 2px;
}

.env-toggle-detail .env-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--pico-muted-color);
  cursor: pointer;
  border-radius: 0.25rem;
  
}

.env-toggle-detail .env-btn:hover {
  color: var(--pico-color);
}

.env-toggle-detail .env-btn.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

/* Production = muted sage-teal (stable), Development = warm ochre (active) */
.env-toggle-detail .env-btn[data-env="production"].active,
.env-toggle-detail .env-btn:first-child.active {
  background: #3d7c6c;
  color: rgba(255,255,255,0.95);
}

.env-toggle-detail .env-btn[data-env="development"].active,
.env-toggle-detail .env-btn:last-child.active {
  background: #b8860b;
  color: rgba(255,255,255,0.95);
}

[data-theme="light"] .env-toggle-detail {
  background: rgba(0,0,0,0.06);
}

/* Inline status indicator */
.status-indicator-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

.status-indicator-inline.online { color: #22c55e; }
.status-indicator-inline.idle { color: #f59e0b; }
.status-indicator-inline.offline { color: #ef4444; }

.status-dot-small {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.heartbeat-inline {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  white-space: nowrap;
}

[data-theme="light"] .env-select-medium {
  border-color: rgba(22, 163, 74, 0.5);
  background-color: rgba(22, 163, 74, 0.08);
  color: #16a34a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="light"] .env-label-medium.prod {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.3);
}

[data-theme="light"] .env-label-medium.dev {
  background: rgba(234, 88, 12, 0.1);
  color: #ea580c;
  border-color: rgba(234, 88, 12, 0.3);
}

.service-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.meta-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.meta-value {
  color: var(--pico-color);
}

.meta-value.mono {
  font-family: monospace;
  font-size: 0.75rem;
}

/* Legacy status-text classes */
.status-text.online { color: #22c55e; }
.status-text.idle { color: #f59e0b; }
.status-text.offline { color: #ef4444; }

.service-urls {
  margin-bottom: 1.5rem;
}

.url-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.url-item:last-child {
  border-bottom: none;
}

.url-type {
  font-size: 0.7rem;
  text-transform: uppercase;
  background: var(--pico-muted-color);
  color: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 0.2rem;
  min-width: 50px;
  text-align: center;
}

.url-item a {
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.service-admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.service-admin-actions .btn-admin {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 0.375rem;
}

/* Access sections wrapper with flex gap */
.service-access-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.service-users-section,
.service-services-section,
.service-clients-section {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  border: 1px solid var(--pico-muted-border-color);
}

.service-users-section h3,
.service-services-section h3,
.service-clients-section h3 {
  margin: 0 0 1rem;
}

/* Section hint text */
.section-hint {
  color: var(--pico-muted-color);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* Details button style */
.btn-admin.btn-details {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.btn-admin.btn-details:hover {
  background: #388bfd;
}

/* Small button variant */
.btn-admin.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
}

/* Light mode adjustments */
[data-theme="light"] .login-card {
  background: var(--pubhub-bg-card);
  box-shadow: var(--pubhub-shadow-subtle), 0 0 0 1px var(--pubhub-border-soft);
  border: none;
  
}

[data-theme="light"] .login-header h1 {
  font-family: var(--pubhub-font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

[data-theme="light"] .service-card {
  background: var(--pubhub-bg-card);
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
  
}

[data-theme="light"] .service-card:hover {
  border: 1px solid rgba(79, 70, 229, 0.3);
}

[data-theme="light"] .service-card h3 {
  font-family: var(--pubhub-font-heading);
  font-weight: 600;
}

[data-theme="light"] .team-card,
[data-theme="light"] .profile-card,
[data-theme="light"] .machine-card {
  background: var(--pubhub-bg-card);
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
  
}

[data-theme="light"] .team-card:hover,
[data-theme="light"] .machine-card:hover {
  box-shadow: var(--pubhub-shadow-hover);
  transform: translateY(-1px);
}

[data-theme="light"] .team-card.is-you {
  border-color: var(--pubhub-accent-warm);
  box-shadow: var(--pubhub-shadow-subtle), 0 0 0 1px rgba(79, 70, 229, 0.15);
}

/* Light mode: Header refinements */
[data-theme="light"] .portal-header {
  border-bottom: 1px solid var(--pubhub-border-soft);
  background: linear-gradient(to bottom, #ffffff, #fafafa);
  margin-left: -1rem;
  margin-right: -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

[data-theme="light"] .header-left h1 {
  font-family: var(--pubhub-font-heading);
  font-weight: 700;
}

[data-theme="light"] .nav-link {
  color: var(--pubhub-text-secondary);
  font-weight: 500;
  
  position: relative;
}

[data-theme="light"] .nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--pubhub-accent-warm);
  transform: scaleX(0);
  
  border-radius: 1px;
}

[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active {
  color: var(--pubhub-accent-warm);
}

[data-theme="light"] .nav-link.active::after {
  transform: scaleX(1);
}

[data-theme="light"] .version-badge {
  color: var(--pubhub-text-secondary);
  opacity: 0.7;
}

[data-theme="light"] .service-footer,
[data-theme="light"] .service-card .service-access {
  border-color: #e5e7eb;
}

[data-theme="light"] .heartbeat-ts {
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .service-card .version-badge {
  color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .service-url {
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .filter-clear {
  color: #6b7280;
}

[data-theme="light"] .filter-clear:hover {
  color: #374151;
}

[data-theme="light"] .access-table {
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
  background: var(--pubhub-bg-card);
}

[data-theme="light"] .access-table th {
  background: var(--pubhub-bg-warm);
  font-family: var(--pubhub-font-body);
  font-weight: 600;
}

[data-theme="light"] .access-table th,
[data-theme="light"] .access-table td {
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .access-table tbody tr:hover {
  background: rgba(79, 70, 229, 0.02);
}

[data-theme="light"] .profile-detail {
  background: var(--pubhub-bg-warm);
  border: 1px solid var(--pubhub-border-soft);
}

[data-theme="light"] .status-dot::after {
  background: rgba(0, 0, 0, 0.85);
}

[data-theme="light"] .status-dot::before {
  border-top-color: rgba(0, 0, 0, 0.85);
}

/* WCAG AA compliant contrast (4.5:1 minimum) for secondary text */
[data-theme="light"] .team-card .team-email {
  color: #4b5563;
}

[data-theme="light"] .team-card .team-joined {
  color: #6b7280;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-container {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow: hidden;
  border: 2px solid var(--pico-primary);
  box-shadow: 0 0 0 1px rgba(31, 111, 235, 0.3), 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--pico-muted-color);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--pico-color);
}

.modal-body {
  padding: 1.25rem;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--pico-muted-border-color);
}

.btn-modal {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid;
  
}

.btn-modal.btn-cancel {
  background: transparent;
  border-color: var(--pico-muted-border-color);
  color: var(--pico-muted-color);
}

.btn-modal.btn-cancel:hover {
  background: var(--pico-muted-border-color);
  color: var(--pico-color);
}

.btn-modal.btn-confirm {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.btn-modal.btn-confirm:hover {
  background: #2ea043;
}

.btn-modal.btn-danger {
  background: #f85149;
  border-color: #f85149;
  color: #fff;
}

.btn-modal.btn-danger:hover {
  background: #ff6b61;
}

/* Modal form elements */
.modal-field {
  margin-bottom: 1rem;
}

.modal-field:last-child {
  margin-bottom: 0;
}

.modal-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: #7eb8da;
}

.modal-field select,
.modal-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  border: 2px solid var(--pico-muted-border-color);
  border-radius: 0.375rem;
  background-color: var(--pico-background-color);
  color: var(--pico-color);
  -webkit-text-fill-color: var(--pico-color);
  opacity: 1;
  
}

.modal-field input::placeholder {
  color: var(--pico-muted-color);
  -webkit-text-fill-color: var(--pico-muted-color);
  opacity: 0.7;
}

.modal-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  cursor: pointer;
  color: #e6edf3 !important;
  -webkit-text-fill-color: #e6edf3 !important;
  min-width: 120px;
  text-overflow: ellipsis;
}

.modal-field select option {
  background: var(--pico-background-color);
  color: var(--pico-color);
  padding: 0.5rem;
}

.modal-field select:hover {
  border-color: var(--pico-primary);
}

.modal-field select:focus,
.modal-field input:focus {
  outline: none;
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.2);
}

.modal-field .field-hint {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin-top: 0.25rem;
}

.modal-message {
  padding: 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-message.success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.modal-message.error {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
}

/* Light mode: Modal */
[data-theme="light"] .modal-overlay {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

[data-theme="light"] .modal-container {
  background: #fff;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.2), 0 24px 48px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.1);
  border: 2px solid var(--pico-primary);
}

[data-theme="light"] .modal-header {
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .modal-header h3 {
  font-family: var(--pubhub-font-heading);
}

[data-theme="light"] .modal-footer {
  border-color: var(--pubhub-border-soft);
  background: var(--pubhub-bg-warm);
}

[data-theme="light"] .modal-field select,
[data-theme="light"] .modal-field input {
  background-color: #fff;
  border-color: #d1d5db;
  color: #1f2937;
  -webkit-text-fill-color: #1f2937;
}

[data-theme="light"] .modal-field input::placeholder {
  color: #9ca3af;
  -webkit-text-fill-color: #9ca3af;
  opacity: 1;
}

[data-theme="light"] .modal-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  color: #1f2937 !important;
  -webkit-text-fill-color: #1f2937 !important;
}

[data-theme="light"] .modal-field select option {
  background: #fff;
  color: #1f2937;
}

/* Light mode: Service detail page */
[data-theme="light"] .service-detail-card,
[data-theme="light"] .service-users-section,
[data-theme="light"] .service-services-section,
[data-theme="light"] .service-clients-section {
  border-color: #d1d5db;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .section-hint {
  color: #6b7280;
}

[data-theme="light"] .service-info-grid {
  background: linear-gradient(135deg, rgba(0,0,0,0.02) 0%, rgba(0,0,0,0.04) 100%);
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .info-item {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .info-item:hover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(0,0,0,0.12);
}

[data-theme="light"] .info-item code {
  background: rgba(0,0,0,0.06);
}

[data-theme="light"] .service-description {
  color: #4b5563;
}

[data-theme="light"] .url-item {
  border-color: #e5e7eb;
}

/* Users Table */
.users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
  table-layout: fixed;
}

.users-table th,
.users-table td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--pico-muted-border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.users-table th {
  background: var(--pico-background-color);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.users-table tbody tr:last-child td {
  border-bottom: none;
}

.users-table tbody tr.user-row {
  cursor: pointer;
}

.users-table tbody tr.user-row:hover {
  background: rgba(31, 111, 235, 0.06);
}

.users-table .row-highlight {
  background: rgba(31, 111, 235, 0.08);
}

.users-table .row-highlight:hover {
  background: rgba(31, 111, 235, 0.12);
}

.users-table .col-avatar {
  width: 56px;
  padding-right: 0;
}

.users-table .col-user {
  width: 20%;
}

.users-table .col-email {
  width: 25%;
  font-size: 0.75em;
}

.users-table .col-status {
  width: 15%;
}

.users-table .col-joined {
  width: 10%;
  font-size: 0.75em;
}

.users-table .col-updated {
  width: 10%;
  font-size: 0.75em;
}

.users-table .col-actions {
  width: 240px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

.users-table .col-delete {
  width: 50px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

/* Avatar Small */
.avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  /* background set via inline style from user.color or getUserColor() */
}

/* User Name and Handle */
.user-name {
  font-weight: 500;
  color: var(--pico-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-handle {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

/* You Badge */
.you-badge {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--pico-primary);
  background: rgba(31, 111, 235, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  text-transform: uppercase;
}

/* Status Pills */
.status-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-pill.status-admin {
  background: rgba(31, 111, 235, 0.15);
  color: #1f6feb;
}

.status-pill.status-2fa {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

/* Action Buttons */
.btn-link {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--pico-primary);
  background: transparent;
  border: 1px solid var(--pico-primary);
  border-radius: 0.375rem;
  cursor: pointer;
  text-decoration: none;
  
  margin-left: 0.4rem;
}

.btn-link:first-child {
  margin-left: 0;
}

.btn-link:hover {
  background: var(--pico-primary);
  color: #fff;
}

.btn-link.btn-link-danger {
  color: #f85149;
  border-color: #f85149;
}

.btn-link.btn-link-danger:hover {
  background: #f85149;
  color: #fff;
}

/* Icon Buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  
  color: var(--pico-muted-color);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
}

.btn-icon:hover {
  background: var(--pico-background-color);
  color: var(--pico-color);
  border-color: var(--pico-color);
}

.btn-icon.btn-icon-danger {
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.4);
}

.btn-icon.btn-icon-danger:hover {
  background: rgba(248, 81, 73, 0.1);
  border-color: #f85149;
}

/* Text Utilities */
.text-muted {
  color: var(--pico-muted-color);
}

.error-text {
  color: #f85149;
}

/* Modal Form */
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.modal-hint {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--pico-muted-border-color);
}

/* Color Input Row */
.color-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-picker {
  width: 48px;
  height: 38px;
  padding: 0.25rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.375rem;
  cursor: pointer;
  background: var(--pico-background-color);
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-picker::-webkit-color-swatch {
  border-radius: 0.25rem;
  border: none;
}

.color-text {
  flex: 1;
  font-family: monospace;
}

/* Access Modal Table */
.access-table {
  width: 100%;
}

.access-table .access-service {
  font-weight: 500;
  white-space: nowrap;
}

.access-table .access-level {
  width: 1%;
  white-space: nowrap;
}

.access-select {
  width: auto;
  min-width: 110px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 2px solid var(--pico-muted-border-color);
  border-radius: 0.375rem;
  background: var(--pico-background-color);
  color: var(--pico-color);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 0.9rem;
  
}

.access-select:hover {
  border-color: var(--pico-primary);
  background-color: rgba(31, 111, 235, 0.05);
}

.access-select:focus {
  outline: none;
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.25);
}

/* Light mode: Users Table */
[data-theme="light"] .users-table {
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
  background: var(--pubhub-bg-card);
}

[data-theme="light"] .users-table th {
  background: var(--pubhub-bg-warm);
  font-family: var(--pubhub-font-body);
  font-weight: 600;
}

[data-theme="light"] .users-table th,
[data-theme="light"] .users-table td {
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .users-table tbody tr.user-row:hover {
  background: rgba(79, 70, 229, 0.03);
}

[data-theme="light"] .users-table .row-highlight {
  background: rgba(79, 70, 229, 0.04);
}

[data-theme="light"] .users-table .row-highlight:hover {
  background: rgba(79, 70, 229, 0.07);
}

[data-theme="light"] .status-pill.status-admin {
  background: rgba(31, 111, 235, 0.12);
}

[data-theme="light"] .status-pill.status-2fa {
  background: rgba(34, 197, 94, 0.12);
}

[data-theme="light"] .color-picker {
  background: #fff;
  border-color: #d1d5db;
}

[data-theme="light"] .access-select {
  background: #fff;
  border-color: #d1d5db;
}

/* Page Header (title + action button) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  margin: 0;
}

/* Checkbox Field */
.checkbox-field {
  display: flex;
  align-items: center;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--pico-color);
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

/* API Keys Container */
.apikeys-container {
  min-height: 150px;
}

.apikeys-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.apikey-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--pico-background-color);
  border-radius: 0.5rem;
  border: 1px solid var(--pico-muted-border-color);
}

.apikey-info {
  flex: 1;
  min-width: 0;
}

.apikey-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.apikey-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.apikey-meta code {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  background: transparent;
}

.apikey-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  background: var(--pico-muted-border-color);
  color: var(--pico-color);
  padding: 0.1rem 0.4rem;
  border-radius: 0.2rem;
}

.apikey-date {
  font-size: 0.7rem;
  color: var(--pico-muted-color);
}

/* API Key Display (for new key) */
.apikey-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--pico-background-color);
  border-radius: 0.5rem;
  border: 1px solid var(--pico-muted-border-color);
}

.apikey-display code {
  flex: 1;
  font-size: 0.8rem;
  word-break: break-all;
  background: transparent;
  color: var(--pico-color);
}

.btn-copy {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--pico-primary);
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  
  white-space: nowrap;
}

.btn-copy:hover {
  background: #388bfd;
}

/* Light mode: API Keys */
[data-theme="light"] .apikey-item {
  background: #f9fafb;
  border-color: #e5e7eb;
}

[data-theme="light"] .apikey-display {
  background: #f9fafb;
  border-color: #e5e7eb;
}

[data-theme="light"] .apikey-type {
  background: #e5e7eb;
}

/* Client API Keys Page */
.clients-grid {
  width: 100%;
}

.clients-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--pico-card-background-color);
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--pico-muted-border-color);
}

.clients-table th,
.clients-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.clients-table th {
  background: var(--pico-background-color);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  font-weight: 600;
}

.clients-table tbody tr:last-child td {
  border-bottom: none;
}

.clients-table tbody tr.client-row {
  cursor: pointer;
}

.clients-table tbody tr.client-row:hover {
  background: rgba(31, 111, 235, 0.06);
}

.clients-table .col-client {
  width: 25%;
}

.clients-table .col-email {
  width: 20%;
  font-size: 0.85rem;
}

.clients-table .col-status {
  width: 10%;
}

.clients-table .col-created,
.clients-table .col-used {
  width: 10%;
  font-size: 0.8rem;
}

.clients-table .col-actions {
  width: 260px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

.clients-table .col-delete {
  width: 50px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  text-overflow: unset;
}

/* Client Link (matches user-link) */
.client-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--pico-muted-color);
}

.client-link:hover {
  color: var(--pico-primary);
  border-bottom-color: var(--pico-primary);
}

.client-name {
  font-weight: 600;
}

.client-prefix {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
}

.client-prefix code {
  background: transparent;
}

/* Status pills for enabled/disabled */
.status-pill.status-enabled {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.status-pill.status-disabled {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
}

/* Client Detail Card */
.client-detail-card {
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--pico-muted-border-color);
}

.client-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.client-title-section h2 {
  margin: 0 0 0.25rem;
}

.client-id {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin: 0;
}

.client-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.client-notes {
  background: var(--pico-background-color);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.client-notes label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  margin-bottom: 0.5rem;
}

.client-notes p {
  margin: 0;
  white-space: pre-wrap;
}

.client-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
}

/* Client access section */
.client-access-section {
  background: var(--pico-background-color);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.client-access-section .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.client-access-section .section-header label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  margin: 0;
}

.client-access-section .access-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Access button style */
.btn-admin.btn-access {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #fff;
}

.btn-admin.btn-access:hover {
  background: #a78bfa;
}

/* Rotate button style */
.btn-admin.btn-rotate {
  background: transparent;
  border-color: #f59e0b;
  color: #f59e0b;
}

.btn-admin.btn-rotate:hover {
  background: rgba(245, 158, 11, 0.15);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--pico-card-background-color);
  border-radius: 0.75rem;
  border: 1px dashed var(--pico-muted-border-color);
}

.empty-state p {
  margin: 0.5rem 0;
}

/* Modal textarea */
.modal-field textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.375rem;
  background-color: var(--pico-background-color);
  color: var(--pico-color);
  resize: vertical;
  min-height: 80px;
}

.modal-field textarea:focus {
  outline: none;
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.2);
}

/* Light mode: Clients */
[data-theme="light"] .clients-table {
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
  background: var(--pubhub-bg-card);
}

[data-theme="light"] .clients-table th {
  background: var(--pubhub-bg-warm);
  font-family: var(--pubhub-font-body);
  font-weight: 600;
}

[data-theme="light"] .clients-table th,
[data-theme="light"] .clients-table td {
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .clients-table tbody tr.client-row:hover {
  background: rgba(79, 70, 229, 0.03);
}

[data-theme="light"] .client-detail-card {
  background: var(--pubhub-bg-card);
  border: 1px solid var(--pubhub-border-soft);
  box-shadow: var(--pubhub-shadow-subtle);
}

[data-theme="light"] .client-detail-card h2 {
  font-family: var(--pubhub-font-heading);
}

[data-theme="light"] .client-notes {
  background: var(--pubhub-bg-warm);
  border: 1px solid var(--pubhub-border-soft);
}

[data-theme="light"] .client-actions {
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .empty-state {
  background: var(--pubhub-bg-card);
  border: 1px dashed rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .modal-field textarea {
  background-color: var(--pubhub-bg-card);
  border: 1px solid var(--pubhub-border-soft);
  
}

[data-theme="light"] .modal-field textarea:focus {
  border-color: var(--pubhub-accent-warm);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Light mode: Form inputs */
[data-theme="light"] .services-filter input,
[data-theme="light"] .login-card input {
  background: var(--pubhub-bg-card);
  border: 1px solid var(--pubhub-border-soft);
  
}

[data-theme="light"] .services-filter input:focus,
[data-theme="light"] .login-card input:focus {
  border-color: var(--pubhub-accent-warm);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

/* Light mode: Buttons */
[data-theme="light"] .login-card button[type="submit"] {
  background: var(--pubhub-accent-warm);
  border-color: var(--pubhub-accent-warm);
  
}

[data-theme="light"] .login-card button[type="submit"]:hover {
  background: #4338ca;
  transform: translateY(-1px);
}

/* Light mode: Access badges with refined colors */
[data-theme="light"] .access-badge.admin {
  background: rgba(79, 70, 229, 0.1);
  color: #4f46e5;
}

[data-theme="light"] .access-badge.write {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

[data-theme="light"] .access-badge.read {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

/* Light mode: Section headers */
[data-theme="light"] .services-section h2,
[data-theme="light"] .page-header h2,
[data-theme="light"] #page-profile h2,
[data-theme="light"] #page-profile h3 {
  font-family: var(--pubhub-font-heading);
}

/* Autocomplete (Contact Search) */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--pico-card-background-color);
  border: 2px solid var(--pico-primary);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 0.25rem;
}

.autocomplete-results::before {
  content: 'Select a contact';
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.autocomplete-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--pico-muted-border-color);
  border-left: 3px solid transparent;
  
}

.autocomplete-item::before {
  content: '';
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--pico-primary) 0%, var(--pico-primary-hover) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: rgba(31, 111, 235, 0.15);
  border-left-color: var(--pico-primary);
}

.autocomplete-item.no-results {
  color: var(--pico-muted-color);
  cursor: default;
  font-style: italic;
  justify-content: center;
  padding: 1.25rem;
}

.autocomplete-item.no-results::before {
  display: none;
}

.autocomplete-item.no-results:hover {
  background: none;
  border-left-color: transparent;
}

.autocomplete-item .contact-info {
  flex: 1;
  min-width: 0;
}

.autocomplete-item .contact-name {
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--pico-color);
}

.autocomplete-item .contact-name .company {
  font-weight: 400;
  color: var(--pico-muted-color);
  font-size: 0.85em;
}

.autocomplete-item .contact-email {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

.autocomplete-item .contact-select-hint {
  font-size: 0.7rem;
  color: var(--pico-primary);
  opacity: 0;
  
  margin-top: 0.25rem;
}

.autocomplete-item:hover .contact-select-hint {
  opacity: 1;
}

[data-theme="light"] .autocomplete-results {
  background: var(--pubhub-bg-card);
  border-color: var(--pico-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .autocomplete-results::before {
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--pubhub-border-soft);
}

[data-theme="light"] .autocomplete-item:hover {
  background: rgba(79, 70, 229, 0.08);
}

[data-theme="light"] .autocomplete-item {
  border-color: var(--pubhub-border-soft);
}

/* Selected Contact Card */
.selected-contact-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--pico-background-color);
  border: 1px solid var(--pico-primary);
  border-radius: 0.375rem;
  margin-top: 0.5rem;
}

.selected-contact-info {
  flex: 1;
}

.selected-contact-name {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.selected-contact-name .company {
  font-weight: 400;
  color: var(--pico-muted-color);
}

.selected-contact-email {
  font-size: 0.85rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.15rem;
}

.selected-contact-id {
  font-size: 0.75rem;
}

.selected-contact-id code {
  background: transparent;
  color: var(--pico-muted-color);
}

.btn-change-contact {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--pico-primary);
  background: transparent;
  border: 1px solid var(--pico-primary);
  border-radius: 0.375rem;
  cursor: pointer;
  
}

.btn-change-contact:hover {
  background: var(--pico-primary);
  color: #fff;
}

[data-theme="light"] .selected-contact-card {
  background: var(--pubhub-bg-warm);
  border-color: var(--pubhub-accent-warm);
}

/* 404 Error Page */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}

.error-code {
  font-size: 6rem;
  font-weight: 700;
  line-height: 1;
  margin: 0 0 1rem;
  color: var(--pico-muted-color);
}

.error-title {
  font-size: 1.75rem;
  margin: 1rem 0 0.5rem;
  color: var(--pico-color);
}

.error-message {
  font-size: 1.1rem;
  color: var(--pico-muted-color);
  margin-bottom: 2rem;
  max-width: 400px;
}

.error-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.error-actions .btn-primary {
  padding: 0.75rem 1.5rem;
  background: var(--pico-primary);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-weight: 500;
  text-decoration: none;
  
}

.error-actions .btn-primary:hover {
  background: var(--pico-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.3);
}

.error-actions .btn-secondary {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--pico-muted-color);
  border: 2px solid var(--pico-muted-border-color);
  border-radius: 0.5rem;
  font-weight: 500;
  text-decoration: none;
  
}

.error-actions .btn-secondary:hover {
  border-color: var(--pico-primary);
  color: var(--pico-primary);
}

.error-hint {
  margin-top: 1rem;
}

.error-hint code {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0.25rem;
  color: var(--pico-muted-color);
}

[data-theme="light"] .error-hint code {
  background: rgba(0, 0, 0, 0.05);
}
