/* ============================================================
   Golem Admin Portal — Command Center Stylesheet
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #16213e;
  --sidebar-active: #0f3460;
  --accent: #4361ee;
  --accent-hover: #3a56d4;
  --accent-glow: rgba(67, 97, 238, 0.15);
  --danger: #e63946;
  --success: #2ec4b6;
  --warning: #f4a261;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --border: #e2e6ea;
  --font-ui: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 6px 10px rgba(0, 0, 0, 0.08);
  --transition: 150ms ease;
}


/* ============================================================
   1. Reset & Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

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

table {
  border-collapse: collapse;
  width: 100%;
}


/* ============================================================
   2. Layout — CSS Grid
   ============================================================ */
body {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  grid-column: 1;
  grid-row: 1;
}

.main {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ============================================================
   3. Sidebar
   ============================================================ */
.sidebar {
  background: var(--sidebar-bg);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  font-size: 24px;
  line-height: 1;
}

.sidebar-logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.sidebar-logo-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
}

/* Nav section labels */
.sidebar-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.35);
  padding: 20px 20px 8px;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav li {
  margin: 1px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.6);
  border-left: 3px solid transparent;
  transition: all var(--transition);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  color: rgba(255, 255, 255, 0.95);
  background: var(--sidebar-hover);
  border-left-color: rgba(255, 255, 255, 0.15);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-active);
  border-left-color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}

/* Sidebar bottom section */
.sidebar-bottom {
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-tenant {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tenant:empty {
  display: none;
}

.sidebar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  transition: color var(--transition);
  padding: 4px 0;
}

.sidebar-back:hover {
  color: var(--accent);
}

.sidebar-back::before {
  content: '\2190';
}

.sidebar-version {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 8px;
  font-family: var(--font-mono);
}

.sidebar-version:empty {
  display: none;
}


/* ============================================================
   4. Header
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
  z-index: 50;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a,
.breadcrumb span {
  padding: 2px 0;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb-separator {
  margin: 0 8px;
  color: var(--border);
  font-size: 0.7rem;
}

.breadcrumb-separator::after {
  content: '\203A';
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
}

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-search {
  height: 36px;
  width: 220px;
  padding: 0 14px 0 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition);
  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='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 14px;
}

.header-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  width: 280px;
  background-color: var(--card);
}

.header-search::placeholder {
  color: var(--text-muted);
}

/* Notifications */
.header-notifications {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--transition);
  color: var(--text-muted);
}

.header-notifications:hover {
  background: var(--bg);
  color: var(--text);
}

.header-notifications svg {
  width: 20px;
  height: 20px;
}

.header-notifications .notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* Avatar */
.header-avatar {
  position: relative;
}

.avatar-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  transition: box-shadow var(--transition);
}

.avatar-button:hover,
.avatar-button:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.avatar-initials {
  line-height: 1;
}


/* ============================================================
   5. System Pulse Dot
   ============================================================ */
.pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-breathing 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-breathing {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(46, 196, 182, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(46, 196, 182, 0);
  }
}

.pulse-dot[data-status="error"] {
  background: var(--danger);
  animation-name: pulse-breathing-error;
}

@keyframes pulse-breathing-error {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(230, 57, 70, 0);
  }
}


/* ============================================================
   6. Avatar Dropdown
   ============================================================ */
.avatar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 200;
  transform-origin: top right;
  animation: dropdown-in var(--transition) forwards;
}

.avatar-dropdown[hidden] {
  display: none;
}

.avatar-dropdown a {
  display: block;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text);
  transition: background var(--transition);
}

.avatar-dropdown a:hover {
  background: var(--bg);
  color: var(--accent);
}


/* ============================================================
   7. Content Area
   ============================================================ */
#content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  overflow-x: hidden;
}

#content > * {
  max-width: 1400px;
}

/* Content scrollbar */
#content::-webkit-scrollbar {
  width: 6px;
}

#content::-webkit-scrollbar-track {
  background: transparent;
}

#content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ============================================================
   8. Stat Cards
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border-left: 4px solid var(--accent);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: var(--accent-glow);
  border-radius: 50%;
  transform: translate(30%, -30%);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.stat-card.stat-danger {
  border-left-color: var(--danger);
}

.stat-card.stat-danger .stat-value {
  color: var(--danger);
}

.stat-card.stat-success {
  border-left-color: var(--success);
}

.stat-card.stat-success .stat-value {
  color: var(--success);
}

.stat-card.stat-warning {
  border-left-color: var(--warning);
}

.stat-card.stat-warning .stat-value {
  color: var(--warning);
}


/* ============================================================
   9. Page Title & Section Headers
   ============================================================ */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}


/* ============================================================
   10. Search / Filter Bar
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar .filter-search {
  flex: 1;
  min-width: 200px;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition);
  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='%236c757d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px;
}

.filter-bar .filter-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-bar select {
  height: 36px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  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='%236c757d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition);
}

.filter-bar select:focus {
  border-color: var(--accent);
}


/* ============================================================
   11. Data Tables
   ============================================================ */
.table-wrapper {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: #f8f9fa;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
  transition: color var(--transition);
}

.data-table th.sortable:hover {
  color: var(--text);
}

.data-table th.sortable::after {
  content: '\2195';
  margin-left: 6px;
  opacity: 0.3;
  font-size: 0.7rem;
}

.data-table th.sort-asc::after {
  content: '\2191';
  opacity: 1;
  color: var(--accent);
}

.data-table th.sort-desc::after {
  content: '\2193';
  opacity: 1;
  color: var(--accent);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  animation: fadeSlideUp 300ms ease forwards;
  opacity: 0;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.data-table tbody tr:hover {
  background: var(--accent-glow);
}

/* Staggered row animations */
.data-table tbody tr:nth-child(1)  { animation-delay: 0ms; }
.data-table tbody tr:nth-child(2)  { animation-delay: 30ms; }
.data-table tbody tr:nth-child(3)  { animation-delay: 60ms; }
.data-table tbody tr:nth-child(4)  { animation-delay: 90ms; }
.data-table tbody tr:nth-child(5)  { animation-delay: 120ms; }
.data-table tbody tr:nth-child(6)  { animation-delay: 150ms; }
.data-table tbody tr:nth-child(7)  { animation-delay: 180ms; }
.data-table tbody tr:nth-child(8)  { animation-delay: 210ms; }
.data-table tbody tr:nth-child(9)  { animation-delay: 240ms; }
.data-table tbody tr:nth-child(10) { animation-delay: 270ms; }
.data-table tbody tr:nth-child(11) { animation-delay: 300ms; }
.data-table tbody tr:nth-child(12) { animation-delay: 330ms; }
.data-table tbody tr:nth-child(13) { animation-delay: 360ms; }
.data-table tbody tr:nth-child(14) { animation-delay: 390ms; }
.data-table tbody tr:nth-child(15) { animation-delay: 420ms; }

/* Monospace cells */
.cell-mono,
.cell-id,
.cell-key,
.cell-timestamp {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.cell-id {
  color: var(--text-muted);
  font-size: 0.75rem;
}


/* ============================================================
   12. Table Actions
   ============================================================ */
.table-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.table-actions .btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.table-actions .btn-action svg {
  width: 16px;
  height: 16px;
}

.table-actions .btn-action.action-edit {
  color: var(--accent);
}

.table-actions .btn-action.action-edit:hover {
  background: var(--accent-glow);
}

.table-actions .btn-action.action-delete {
  color: var(--danger);
}

.table-actions .btn-action.action-delete:hover {
  background: rgba(230, 57, 70, 0.1);
}

.table-actions .btn-action.action-view {
  color: var(--text-muted);
}

.table-actions .btn-action.action-view:hover {
  background: var(--bg);
  color: var(--text);
}

/* Tooltip for action buttons */
.table-actions .btn-action[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 4px 8px;
  font-size: 0.7rem;
  background: var(--text);
  color: #fff;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition);
}

.table-actions .btn-action[title]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}


/* ============================================================
   13. Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
}

.pagination button,
.pagination .page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination button:hover,
.pagination .page-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination button.active,
.pagination .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-prev::before {
  content: '\2190';
}

.pagination .page-next::after {
  content: '\2192';
}

.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 12px;
}


/* ============================================================
   14. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

/* Secondary */
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #d62b39;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 8px 12px;
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

/* Sizes */
.btn-sm {
  padding: 4px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 1rem;
  border-radius: 10px;
}

/* Button loading state */
.btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 500ms linear infinite;
}

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


/* ============================================================
   15. Forms
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: all var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-select {
  appearance: none;
  padding-right: 32px;
  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='%236c757d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.form-textarea {
  height: auto;
  min-height: 100px;
  padding: 10px 12px;
  resize: vertical;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-input.error,
.form-select.error {
  border-color: var(--danger);
}

.form-input.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}


/* ============================================================
   16. Modal
   ============================================================ */
#modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 200ms ease forwards;
}

#modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-slide-up 250ms ease forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.25rem;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-close::after {
  content: '\00D7';
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

@keyframes modal-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* ============================================================
   17. Toasts
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 20px;
  min-width: 300px;
  max-width: 420px;
  border-left: 4px solid var(--accent);
  pointer-events: auto;
  animation: toast-slide-in 300ms ease forwards;
  position: relative;
  overflow: hidden;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info    { border-left-color: var(--accent); }

.toast-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 1rem;
  transition: all var(--transition);
}

.toast-close:hover {
  background: var(--bg);
  color: var(--text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  animation: toast-progress-shrink 5s linear forwards;
}

.toast.toast-success .toast-progress { background: var(--success); }
.toast.toast-error .toast-progress   { background: var(--danger); }
.toast.toast-warning .toast-progress { background: var(--warning); }

.toast.toast-exiting {
  animation: toast-slide-out 200ms ease forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes toast-progress-shrink {
  from { width: 100%; }
  to { width: 0; }
}


/* ============================================================
   18. Badges / Pills
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-accent,
.badge-admin {
  background: var(--accent-glow);
  color: var(--accent);
}

.badge-success,
.badge-active,
.badge-member {
  background: rgba(46, 196, 182, 0.12);
  color: #1a9e8f;
}

.badge-danger,
.badge-disabled,
.badge-revoked {
  background: rgba(230, 57, 70, 0.1);
  color: var(--danger);
}

.badge-warning,
.badge-pending {
  background: rgba(244, 162, 97, 0.15);
  color: #c47d3a;
}

.badge-muted,
.badge-guest {
  background: var(--bg);
  color: var(--text-muted);
}


/* ============================================================
   19. Skeleton Loading
   ============================================================ */
.skeleton {
  background: #e9ecef;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }

.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
}

.skeleton-row {
  height: 48px;
  margin-bottom: 1px;
}

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}


/* ============================================================
   20. Dropdown Menus
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  z-index: 200;
  transform-origin: top left;
  animation: dropdown-in 150ms ease forwards;
}

.dropdown-menu.align-right {
  left: auto;
  right: 0;
  transform-origin: top right;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-item {
  display: block;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--text);
  transition: background var(--transition);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  background: none;
}

.dropdown-item:hover {
  background: var(--bg);
  color: var(--accent);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: rgba(230, 57, 70, 0.06);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}


/* ============================================================
   21. Tabs
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeSlideUp 200ms ease forwards;
}

/* Settings page uses .settings-tabs/.settings-tab — alias to .tabs/.tab */
.settings-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.settings-tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Policies tab */
.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.policy-item {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

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

.policy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.policy-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

.policy-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.4;
}

.policy-number {
  width: 120px;
  margin-top: 6px;
}

.policy-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.policy-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.policy-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}


/* ============================================================
   22. Empty States
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--border);
  margin-bottom: 16px;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.2;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 360px;
  margin-bottom: 20px;
  line-height: 1.6;
}


/* ============================================================
   23. Toggle Switches
   ============================================================ */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toggle-label {
  margin-left: 10px;
  font-size: 0.85rem;
  color: var(--text);
}


/* ============================================================
   24. Invite Link Box
   ============================================================ */
.invite-link-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.invite-link-url {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  word-break: break-all;
  user-select: all;
}

.invite-link-box .btn-copy {
  flex-shrink: 0;
}


/* ============================================================
   25. Staggered Animations
   ============================================================ */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stat card staggered entrance */
.stats-grid .stat-card {
  animation: fadeSlideUp 350ms ease forwards;
  opacity: 0;
}

.stats-grid .stat-card:nth-child(1) { animation-delay: 0ms; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 60ms; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 120ms; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 180ms; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 240ms; }
.stats-grid .stat-card:nth-child(6) { animation-delay: 300ms; }


/* ============================================================
   26. Custom Scrollbar (webkit)
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}


/* ============================================================
   27. Card Component (generic)
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
}


/* ============================================================
   28. Responsive
   ============================================================ */

/* Tablet: sidebar collapses to icon-only */
@media (max-width: 768px) {
  body {
    grid-template-columns: 60px 1fr;
  }

  .sidebar {
    width: 60px;
  }

  .sidebar-logo-text,
  .sidebar-logo-badge,
  .sidebar-bottom .sidebar-tenant,
  .sidebar-bottom .sidebar-version,
  .sidebar-bottom .sidebar-back,
  .sidebar-nav-label {
    display: none;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 16px 0;
  }

  .nav-item {
    justify-content: center;
    padding: 12px 0;
    border-left-width: 0;
  }

  .nav-item span {
    display: none;
  }

  .nav-item.active {
    border-left-width: 0;
    background: var(--sidebar-active);
    border-radius: 0;
  }

  .nav-item.active::before {
    width: 100%;
    height: 3px;
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    border-radius: 2px 2px 0 0;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
  }

  .sidebar-bottom {
    padding: 12px 0;
    text-align: center;
  }

  .header {
    padding: 0 16px;
  }

  .header-search {
    width: 160px;
  }

  .header-search:focus {
    width: 200px;
  }

  #content {
    padding: 20px;
  }
}

/* Mobile: sidebar becomes overlay */
@media (max-width: 480px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }

  .sidebar-logo-text,
  .sidebar-logo-badge {
    display: initial;
  }

  .nav-item {
    justify-content: flex-start;
    padding: 10px 20px;
    border-left-width: 3px;
  }

  .nav-item span {
    display: initial;
  }

  .sidebar-bottom .sidebar-back {
    display: inline-flex;
  }

  .main {
    grid-column: 1;
  }

  .header {
    padding: 0 12px;
  }

  .header-search {
    display: none;
  }

  #content {
    padding: 16px;
  }

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

  .modal {
    margin: 12px;
    max-width: calc(100vw - 24px);
  }

  #toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

/* Hamburger menu button (shown on mobile) */
.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text);
  transition: background var(--transition);
}

.hamburger:hover {
  background: var(--bg);
}

.hamburger svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 480px) {
  .hamburger {
    display: flex;
  }
}


/* ============================================================
   29. Utility Classes
   ============================================================ */
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   30. SVG Icon Sizing & Dashboard Layout
   ============================================================ */

/* -- General safety net: constrain SVGs inside content area -- */
#content svg {
  max-width: 100%;
  max-height: 100%;
}

/* -- Page header (title + action button row) -- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header .page-title {
  margin-bottom: 0;
}

/* -- Dashboard layout -- */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.dashboard-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* -- Stat card icon (`.stat-icon svg`) — 40px -- */
.stat-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 40px;
  height: 40px;
}

.stat-card-success .stat-icon {
  color: var(--success);
}

/* -- Stat trend arrows -- */
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.stat-trend-up {
  color: var(--success);
}

.stat-trend-down {
  color: var(--danger);
}

.stat-trend-neutral {
  color: var(--text-muted);
}

.stat-trend svg,
.trend-arrow {
  width: 14px;
  height: 14px;
}

.stat-trend-wrap {
  margin-top: 8px;
}

/* -- Empty state icon — 64px, centered, muted -- */
.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--border);
}

/* -- Table action buttons (`.btn-icon svg`) — 16px -- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}

.btn-icon[title] {
  text-decoration: none;
  border-bottom: none;
}

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

.btn-icon-muted {
  color: var(--text-muted);
}

.btn-icon-muted:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-icon-danger {
  color: var(--danger);
}

.btn-icon-danger:hover {
  background: rgba(230, 57, 70, 0.1);
}

/* Tooltips use native title attribute — no CSS pseudo-element needed
   to avoid clipping issues inside table cells. */

/* -- Info banner icon — 20px -- */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent-glow);
  border: 1px solid rgba(67, 97, 238, 0.2);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
}

.info-banner svg,
.info-banner-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}

/* -- Sidebar collapse button — 20px -- */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.5);
  transition: all var(--transition);
  margin: 8px auto;
}

.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

.sidebar-collapse-btn svg {
  width: 20px;
  height: 20px;
}

/* -- Activity feed items -- */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.activity-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.activity-icon svg {
  width: 28px;
  height: 28px;
}

.activity-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-desc {
  font-size: 0.85rem;
  color: var(--text);
}

.activity-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.activity-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
  font-size: 0.85rem;
}

/* -- Health rows -- */
.health-banner {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.health-banner-ok {
  background: rgba(46, 196, 182, 0.1);
  color: #1a9e8f;
}

.health-banner-err {
  background: rgba(230, 57, 70, 0.1);
  color: var(--danger);
}

.health-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.health-row:last-child {
  border-bottom: none;
}

.health-name {
  font-weight: 500;
}

.health-status {
  color: var(--text-muted);
  margin-left: auto;
}

.health-latency {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* -- Status dot -- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot-green {
  background: var(--success);
}

.status-dot-red {
  background: var(--danger);
}

/* -- API key success icon — 48px -- */
.apikey-success {
  text-align: center;
}

.apikey-success-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--success);
}

.apikey-success-icon svg {
  width: 48px;
  height: 48px;
}

.apikey-success-message {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* -- Checkbox group -- */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* -- Code tag -- */
.code-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* -- Channel badge -- */
.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.channel-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* -- User cell in table -- */
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.user-email {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* -- Tabs (modal-level tab-btn variant) -- */
.tab-btn {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* -- Group detail modal -- */
.group-detail-stats {
  display: flex;
  gap: 24px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.group-detail-stats .stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.group-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.group-detail-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 120px;
  flex-shrink: 0;
}

.group-detail-json {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg);
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre;
  flex: 1;
}

/* -- Card error state -- */
.card-error {
  padding: 24px;
  text-align: center;
  color: var(--danger);
  font-size: 0.85rem;
}

.card-error .btn {
  margin-top: 12px;
}

/* -- Key display (created key reveal) -- */
.key-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  word-break: break-all;
  user-select: all;
  margin-top: 12px;
}

/* -- Animate-in utility (used by dashboard stat cards) -- */
.animate-in {
  animation: fadeSlideUp 350ms ease forwards;
  opacity: 0;
}

/* -- Badge sizes -- */
.badge-sm {
  font-size: 0.7rem;
  padding: 1px 6px;
}

.badge-blue {
  background: var(--accent-glow);
  color: var(--accent);
}

.badge-gray {
  background: var(--bg);
  color: var(--text-muted);
}

.badge-red {
  background: rgba(230, 57, 70, 0.1);
  color: var(--danger);
}

/* -- Responsive: dashboard grid stacks on smaller screens -- */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-stats {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}


/* ============================================================
   31. Print Styles
   ============================================================ */
@media print {
  .sidebar,
  .header,
  #toast-container,
  #modal-overlay,
  .pagination,
  .filter-bar,
  .table-actions {
    display: none !important;
  }

  body {
    display: block;
    background: #fff;
    color: #000;
  }

  #content {
    padding: 0;
    overflow: visible;
  }

  .data-table tbody tr {
    animation: none;
    opacity: 1;
  }

  .stat-card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}


/* ============================================================
   Skills Marketplace
   ============================================================ */

/* -- Tabs ------------------------------------------------------------- */
.sm-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 24px;
  width: fit-content;
}

.sm-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.sm-tab:hover {
  color: var(--text);
  background: var(--bg);
}

.sm-tab-active {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.sm-tab-active:hover {
  color: #fff;
  background: var(--accent-hover);
}

.sm-tab-icon {
  font-size: 1rem;
}

.sm-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
}

.sm-tab:not(.sm-tab-active) .sm-tab-count {
  background: var(--bg);
  color: var(--text-muted);
}

/* -- Card grid -------------------------------------------------------- */
.sm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* -- Card ------------------------------------------------------------- */
.sm-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
  animation: sm-card-enter 300ms ease both;
  position: relative;
}

.sm-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Source-specific left accent */
.sm-card-catalog {
  border-left: 3px solid var(--accent);
}

.sm-card-clawhub {
  border-left: 3px solid var(--success);
}

.sm-card.sm-card-disabled {
  opacity: 0.55;
}

.sm-card.sm-card-disabled:hover {
  opacity: 0.75;
}

@keyframes sm-card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -- Card header ------------------------------------------------------ */
.sm-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sm-card-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius);
}

.sm-card-title-group {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sm-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -- Source badges ----------------------------------------------------- */
.sm-source-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sm-badge-golem {
  background: rgba(67, 97, 238, 0.1);
  color: var(--accent);
}

.sm-badge-clawhub {
  background: rgba(46, 196, 182, 0.1);
  color: var(--success);
}

.sm-badge-community {
  background: rgba(128, 90, 213, 0.1);
  color: #805ad5;
}

.sm-badge-url {
  background: rgba(108, 117, 125, 0.1);
  color: var(--text-muted);
}

/* -- Card description ------------------------------------------------- */
.sm-card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* -- Tags ------------------------------------------------------------- */
.sm-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sm-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
}

/* -- Score indicator (ClawHub) ---------------------------------------- */
.sm-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sm-score-bar {
  width: 60px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.sm-score-fill {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 400ms ease;
}

.sm-score-label {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* -- Card footer ------------------------------------------------------ */
.sm-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* -- Installed check button ------------------------------------------- */
.sm-installed-check {
  background: rgba(46, 196, 182, 0.1);
  color: var(--success);
  border: 1px solid rgba(46, 196, 182, 0.2);
  font-weight: 600;
  cursor: default;
}

/* -- ClawHub search --------------------------------------------------- */
.sm-clawhub-search {
  margin-bottom: 24px;
}

.sm-search-wrapper {
  position: relative;
  max-width: 640px;
}

.sm-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.sm-search-input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  font-size: 1rem;
  font-family: var(--font-ui);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.sm-search-input::placeholder {
  color: var(--text-muted);
}

.sm-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.sm-search-input:focus ~ .sm-search-icon,
.sm-search-wrapper:focus-within .sm-search-icon {
  color: var(--accent);
}

/* -- Browse heading --------------------------------------------------- */
.sm-browse-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

/* -- Empty states ----------------------------------------------------- */
.sm-empty {
  text-align: center;
  padding: 60px 20px;
  max-width: 400px;
  margin: 0 auto;
}

.sm-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.8;
}

.sm-empty h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.sm-empty p {
  font-size: 0.88rem;
  line-height: 1.6;
}

/* -- Loading ---------------------------------------------------------- */
.sm-loading {
  text-align: center;
  padding: 60px 20px;
}

/* -- Responsive ------------------------------------------------------- */
@media (max-width: 768px) {
  .sm-grid {
    grid-template-columns: 1fr;
  }

  .sm-tabs {
    width: 100%;
  }

  .sm-tab {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}

/* -- WASM Status Badges (Phase 5) -------------------------------------- */

.wasm-badge-pulse {
  animation: wasm-pulse 1.5s ease-in-out infinite;
}

@keyframes wasm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.wasm-status-badge {
  display: inline-block;
  vertical-align: middle;
  line-height: 1.4;
}

.wasm-feedback-timeline {
  max-height: 300px;
  overflow-y: auto;
}

.wasm-history-table tbody tr:hover {
  background: #f9fafb;
}
