:root {
  --bg: #0a0a0b;
  --bg-elevated: #111113;
  --surface: #18181b;
  --surface-hover: #1f1f23;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.2);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.light-mode {
  --bg: #f4f4f5;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f4f4f5;
  --border: #e4e4e7;
  --border-hover: #d4d4d8;
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --primary-glow: rgba(99, 102, 241, 0.1);
}

/* Mode-specific visibility */
.light-mode .mode-dark-only {
  display: none !important;
}

html:not(.light-mode) .mode-light-only {
  display: none !important;
}


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* =====================================================
   FOUC Prevention & App Loader
   ===================================================== */

/* Hide app content until ready */
.auth-screen,
.app {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease-out, visibility 0.25s ease-out;
}

/* Show when ready */
body.app-ready .auth-screen,
body.app-ready .app {
  opacity: 1;
  visibility: visible;
}

/* App Loader - shown while initializing */
.app-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.app-loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.app-loader-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  animation: loader-pulse 1.5s ease-in-out infinite;
}

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

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

@keyframes loader-pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(0.95);
  }
}

/* View/Module transition loader */
.view-loader {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-out, visibility 0.15s ease-out;
}

.view-loader.active {
  opacity: 1;
  visibility: visible;
}

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

/* Content container needs position for loader overlay */
.content {
  position: relative;
}

/* Image optimization - only apply to content images, not UI elements */
.content img,
.module-frame img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Avatar images should not have background */
.user-avatar img,
.avatar img,
.avatar-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 20px;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1), transparent 50%);
}

.auth-container {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: var(--gradient);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 16px;
}

.logo-icon.small {
  width: 36px;
  height: 36px;
  font-size: 16px;
  border-radius: 10px;
}

.auth-logo h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.auth-logo p {
  color: var(--text-secondary);
}

.auth-form {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.auth-form h2 {
  font-size: 22px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.5;
}

.auth-links {
  text-align: center;
  margin-top: 16px;
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.auth-links a:hover {
  text-decoration: underline;
}

.invite-email {
  text-align: center;
  color: var(--primary);
  margin-bottom: 24px;
  font-weight: 500;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

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

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

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group input[type="file"] {
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Avatar Upload */
.avatar-upload {
  text-align: center;
}

.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px dashed var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
}

.avatar-preview:hover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.avatar-preview span {
  font-size: 32px;
  color: var(--text-muted);
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--gradient);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-full {
  width: 100%;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--danger);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

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

.btn-success {
  border-color: var(--success);
  color: var(--success);
}

.auth-error {
  margin-top: 16px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--danger);
}

/* App Layout */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  /* Allow internal flex children (like .nav) to shrink and become scrollable */
  min-height: 0;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
}

.logo-img {
  height: 22px;
  width: auto;
  display: block;
}

.auth-logo-img {
  height: 56px;
  width: auto;
  display: block;
  margin: 0 auto 10px auto;
}

.env-badge {
  padding: 4px 8px;
  background: var(--warning);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
}

.nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  /* Critical for scroll inside a flex column */
  min-height: 0;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-label {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
}

.nav-item .module-icon {
  font-size: 16px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: var(--gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.user-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* SVG Icons (replace emojis) */
.l-icon {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  vertical-align: -0.15em;
}

.module-icon .l-icon {
  width: 18px;
  height: 18px;
}

.module-card .icon .l-icon {
  width: 28px;
  height: 28px;
}

.stat-icon .l-icon {
  width: 18px;
  height: 18px;
}

.timeline-icon .l-icon {
  width: 18px;
  height: 18px;
}

.toast .l-icon {
  width: 16px;
  height: 16px;
}

/* Main */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
}

.token-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--primary-glow);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
}

.token-badge svg {
  color: var(--primary);
}

.token-badge span {
  font-size: 16px;
  font-weight: 700;
}

.token-badge .label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

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

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(17, 17, 19, 0.88);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 999;
  gap: 6px;
}

.mbn-item {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 12px;
  padding: 8px 6px;
  cursor: pointer;
  position: relative;
}

.mbn-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.25);
}

.mbn-icon {
  font-size: 18px;
  line-height: 1;
}

.mbn-label {
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mbn-badge {
  position: absolute;
  top: 8px;
  right: 16px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

@media (max-width: 1024px) {
  .mobile-bottom-nav {
    display: flex;
  }

  .content {
    padding-bottom: 96px;
  }
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Dashboard */
.dashboard-welcome {
  margin-bottom: 32px;
}

.dashboard-welcome h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.dashboard-welcome p {
  color: var(--text-secondary);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.module-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.module-card .icon {
  width: 56px;
  height: 56px;
  background: var(--primary-glow);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
}

.module-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.module-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.module-card .meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.module-card .meta .tag {
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 6px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}

.stat-card.primary {
  background: var(--primary-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.section {
  margin-bottom: 32px;
}

.section h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

/* Transactions */
.transactions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.transaction .icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.transaction .icon.grant {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.transaction .icon.usage {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.transaction .icon.adjust {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

.transaction .info {
  flex: 1;
}

.transaction .desc {
  font-size: 14px;
}

.transaction .date {
  font-size: 12px;
  color: var(--text-muted);
}

.transaction .amount {
  font-size: 15px;
  font-weight: 600;
}

.transaction .amount.positive {
  color: var(--success);
}

.transaction .amount.negative {
  color: var(--danger);
}

/* Tables */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

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

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

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

.data-table .user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.data-table .user-cell .avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.data-table .user-cell .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.data-table .user-cell .name {
  font-weight: 500;
}

.data-table .user-cell .email {
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.admin {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
}

.badge.superadmin {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
}

.badge.user {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.badge.active {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge.inactive {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* Gemini-only badge voor AI model settings */
.badge-gemini {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(66, 133, 244, 0.15);
  color: #4285f4;
  border: 1px solid rgba(66, 133, 244, 0.25);
  margin-left: 8px;
  vertical-align: middle;
}

/* Notificatie badge in sidebar */
#navNotifications .badge {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
  text-transform: none;
}

.actions {
  display: flex;
  gap: 8px;
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.checkbox-item:hover {
  border-color: var(--border-hover);
}

.checkbox-item input {
  display: none;
}

.checkbox-item .check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.checkbox-item input:checked+.check {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-item input:checked+.check::after {
  content: '✓';
  color: #fff;
  font-size: 14px;
}

.checkbox-item .label {
  flex: 1;
}

.checkbox-item .label .name {
  font-weight: 500;
}

.checkbox-item .label .desc {
  font-size: 12px;
  color: var(--text-muted);
}

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

.settings-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-section h4 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.settings-section h3 .icon {
  font-size: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.setting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.setting-card.full {
  grid-column: 1 / -1;
}

.setting-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.setting-card .help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Token Costs Grid */
.token-costs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.token-cost-module {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.token-cost-module h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text);
}

.token-cost-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.token-cost-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-cost-item label {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.token-cost-item input {
  width: 100px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  text-align: right;
}

.token-cost-item input:focus {
  outline: none;
  border-color: var(--primary);
}

.token-cost-item .unit {
  font-size: 12px;
  color: var(--text-muted);
  width: 50px;
}

.token-cost-module h4 svg {
  vertical-align: -2px;
  margin-right: 6px;
  opacity: 0.7;
}

/* Input with icon (password toggle etc) */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input {
  width: 100%;
  padding-right: 44px;
}

.input-icon-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.input-icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Improved setting card inputs */
.setting-card input,
.setting-card select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.setting-card input:focus,
.setting-card select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.setting-card input::placeholder {
  color: var(--text-muted);
}

/* Reset Cards */
.reset-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.reset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reset-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.reset-card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 12px;
  color: var(--text-secondary);
}

.reset-card-info h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.reset-card-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.reset-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}

.reset-card-stats .stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.reset-card-stats .stat-item svg {
  opacity: 0.6;
}

.reset-card-stats .loading-small {
  font-size: 12px;
  color: var(--text-muted);
}

.reset-card-stats .stat-error {
  font-size: 12px;
  color: var(--danger);
}

.reset-card-actions {
  margin-top: auto;
}

.btn-danger-outline {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: white;
}

.btn-danger-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Reset All Section */
.reset-all-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 14px;
}

.reset-all-warning {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.reset-all-warning .icon {
  color: var(--danger);
  flex-shrink: 0;
  margin-top: 2px;
}

.reset-all-warning strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.reset-all-warning p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

/* Reset Confirm Modal */
.reset-confirm-modal {
  max-width: 440px;
}

.reset-warning {
  padding: 14px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}

.reset-confirm-input label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.reset-confirm-input code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: var(--danger);
}

.reset-confirm-input input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.reset-confirm-input input:focus {
  outline: none;
  border-color: var(--danger);
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.settings-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.settings-tab.active {
  color: var(--text);
  background: var(--primary);
}

.settings-tab svg {
  opacity: 0.7;
}

.settings-tab.active svg {
  opacity: 1;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-footer {
  position: sticky;
  bottom: 0;
  padding: 16px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  margin-top: 24px;
}

/* API Key Cards */
.api-key-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.api-key-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.api-key-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 10px;
}

.api-key-info {
  flex: 1;
}

.api-key-info strong {
  display: block;
  font-size: 14px;
}

.api-key-status {
  font-size: 12px;
  color: var(--text-muted);
}

.api-key-status.configured {
  color: var(--success);
}

.api-key-input {
  display: flex;
  gap: 8px;
}

.api-key-input input {
  flex: 1;
}

.api-key-card .help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

.api-key-card .help a {
  color: var(--primary);
}

/* Provider Toggle */
.provider-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.provider-toggle span {
  font-size: 13px;
  color: var(--text-muted);
}

.toggle-buttons {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

.provider-models.hidden {
  display: none;
}

/* Button Icon */
.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Active Provider Select */
.active-provider-select {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.provider-option {
  cursor: pointer;
}

.provider-option input {
  display: none;
}

.provider-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.provider-card:hover {
  border-color: var(--primary-muted);
}

.provider-option input:checked+.provider-card {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.provider-card img,
.provider-card .x-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.provider-card .x-logo {
  font-size: 24px;
  font-weight: bold;
}

.provider-info {
  flex: 1;
}

.provider-info strong {
  display: block;
  font-size: 14px;
}

.provider-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.provider-check {
  opacity: 0;
  color: var(--primary);
  transition: opacity 0.2s;
}

.provider-option input:checked+.provider-card .provider-check {
  opacity: 1;
}

.provider-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 12px;
  flex-shrink: 0;
}

.provider-icon svg {
  color: var(--primary);
}

.provider-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.provider-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.provider-status {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.provider-status.not-configured {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Models Config */
.models-config-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-config-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.model-config-row>label {
  width: 120px;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

.model-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.model-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  min-width: 200px;
}

.model-select optgroup {
  font-weight: 600;
  color: var(--text-muted);
}

.model-custom-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
}

.model-custom-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Pricing Container */
.pricing-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.pricing-container textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px;
  resize: vertical;
}

.pricing-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.section-help {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--primary-hover);
}

/* Module Frame */
.module-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: calc(100vh - 200px);
  overflow: hidden;
}

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

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-size: 18px;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
}

.modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.modal-content.modal-danger {
  border-color: var(--danger);
}

.modal-content.modal-danger .modal-header {
  background: rgba(239, 68, 68, 0.1);
  border-bottom-color: var(--danger);
}

.modal-content.modal-danger .modal-header h3 {
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-content .modal-body p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.modal-content .modal-body .warning-text {
  color: var(--danger);
  font-size: 14px;
}

.modal-content .modal-body .reset-list {
  margin: 12px 0;
  padding-left: 24px;
  color: var(--text-secondary);
}

.modal-content .modal-body .reset-list li {
  margin-bottom: 6px;
}

.modal-content .modal-body code {
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: monospace;
  color: var(--danger);
}

.modal-content .modal-body input {
  margin-top: 8px;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1001;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: var(--danger);
}

.toast.success {
  border-color: var(--success);
}

/* Token Input */
.token-input-group {
  display: flex;
  gap: 8px;
}

.token-input-group input {
  flex: 1;
}

.token-input-group button {
  white-space: nowrap;
}

/* Invite List */
.invite-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invite-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.invite-item .info {
  flex: 1;
}

.invite-item .email {
  font-weight: 500;
}

.invite-item .meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Scrollbar */
::-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(--border-hover);
}

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}

/* Deploy */
.deploy-container {
  max-width: 800px;
}

.deploy-status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 32px;
}

.deploy-info h3 {
  margin-bottom: 8px;
}

.deploy-info p {
  color: var(--text-secondary);
}

.deploy-warning {
  padding: 16px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--warning);
}

.btn-large {
  padding: 16px 32px;
  font-size: 16px;
}

.btn-icon {
  margin-right: 8px;
}

.deploy-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  font-family: monospace;
  font-size: 12px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
}

.help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Deploy */
.deploy-container {
  max-width: 900px;
}

.deploy-loading,
.deploy-error {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.deploy-error {
  color: var(--danger);
}

.deploy-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 20px;
}

.deploy-env {
  flex: 1;
}

.deploy-env .env-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.deploy-env .env-path {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

.deploy-arrow {
  font-size: 24px;
  color: var(--primary);
}

.deploy-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.deploy-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
}

.deploy-check.ok {
  border-color: rgba(34, 197, 94, 0.3);
}

.deploy-check.ok .check-icon {
  color: var(--success);
}

.deploy-check.fail {
  border-color: rgba(239, 68, 68, 0.3);
}

.deploy-check.fail .check-icon {
  color: var(--danger);
}

.deploy-changes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
}

.deploy-changes h3 {
  font-size: 14px;
  margin-bottom: 16px;
}

.changes-list {
  max-height: 300px;
  overflow-y: auto;
}

.no-changes {
  padding: 20px;
  text-align: center;
  color: var(--success);
}

.change-group {
  margin-bottom: 16px;
}

.change-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.change-item {
  font-family: monospace;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 4px;
}

.change-item.new {
  color: var(--success);
}

.change-item.modified {
  color: var(--warning);
}

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

.deploy-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.deploy-actions button span {
  margin-right: 6px;
}

.deploy-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.deploy-log h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.deploy-log pre {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

.deploy-disabled {
  text-align: center;
  padding: 60px 20px;
}

.deploy-disabled-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.deploy-disabled h3 {
  margin-bottom: 8px;
}

.deploy-disabled p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.deploy-config-help {
  text-align: left;
  max-width: 500px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.deploy-config-help code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.deploy-config-help pre {
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  margin-top: 12px;
}

/* Activity Dashboard */
.activity-dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
  overflow-y: auto;
  padding: 4px;
}

.activity-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-glow);
  border-radius: 14px;
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.activity-chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.chart-header {
  margin-bottom: 20px;
}

.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.activity-chart {
  height: 160px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 100%;
  gap: 8px;
  padding: 0 8px;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-bar {
  width: 100%;
  max-width: 60px;
  background: var(--gradient);
  border-radius: 8px 8px 0 0;
  min-height: 4px;
  position: relative;
  transition: all 0.3s ease;
}

.chart-bar:hover {
  filter: brightness(1.2);
}

.chart-value {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.chart-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  text-transform: capitalize;
}

.chart-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.activity-filters {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select {
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.activity-timeline {
  flex: 1;
  min-height: 300px;
  overflow-y: auto;
}

.timeline-loading,
.timeline-error,
.timeline-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  text-align: center;
}

.timeline-empty .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.timeline-group {
  margin-bottom: 24px;
}

.timeline-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-left: 68px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-top: 8px;
  padding-bottom: 8px;
  z-index: 1;
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.15s ease;
}

.timeline-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.timeline-item.action-success {
  border-left: 3px solid var(--success);
}

.timeline-item.action-info {
  border-left: 3px solid #3b82f6;
}

.timeline-item.action-danger {
  border-left: 3px solid var(--danger);
}

.timeline-item.action-warning {
  border-left: 3px solid var(--warning);
}

.timeline-item.action-primary {
  border-left: 3px solid var(--primary);
}

.timeline-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 12px;
  font-size: 18px;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.timeline-user {
  font-weight: 600;
  font-size: 14px;
}

.timeline-action-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.timeline-module {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 2px 10px;
  border-radius: 20px;
}

.timeline-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.detail-tag {
  font-size: 11px;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 6px;
  font-family: monospace;
}

.chat-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.chat-detail-prompt,
.chat-detail-output {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.chat-detail-prompt {
  border-left: 3px solid var(--primary, #7c5cfc);
}

.chat-detail-output {
  border-left: 3px solid #10b981;
}

.chat-detail-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chat-detail-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-ip {
  font-family: monospace;
}

/* Activity Tabs */
.activity-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.activity-tab {
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.activity-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.activity-tab-content {
  min-height: 400px;
}

/* Usage Tab */
.module-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.module-name-cell .l-icon {
  color: var(--text-muted);
}

.data-table .totals-row td {
  background: var(--bg);
  border-top: 2px solid var(--border);
}

.data-table .empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

.usage-summary {
  display: flex;
  gap: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.usage-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.usage-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Prompt Gallery */
.prompt-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.prompt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.15s ease;
}

.prompt-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.prompt-image {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
}

.prompt-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prompt-type {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.prompt-type .prompt-deleted {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fca5a5;
}

.prompt-info {
  padding: 16px;
}

.prompt-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-refs {
  margin-bottom: 12px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.prompt-refs-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.prompt-refs-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-refs-grid img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.prompt-refs-grid img:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

.prompt-ref-missing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  word-break: break-all;
  padding: 4px;
  line-height: 1.2;
}

.prompt-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.prompt-user {
  font-size: 13px;
  color: var(--text-secondary);
}

.prompt-cost {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.prompt-details {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .activity-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .activity-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    min-width: 100%;
  }
}

@media (max-width: 600px) {
  .activity-stats {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .stat-value {
    font-size: 22px;
  }

  .timeline-date {
    padding-left: 20px;
  }

  .timeline-item {
    flex-direction: column;
    gap: 12px;
  }

  .timeline-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

/* Mail Settings */
.mail-settings {
  display: grid;
  gap: 20px;
}

.mail-driver-select {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.mail-driver-option {
  flex: 1;
  padding: 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.mail-driver-option:hover {
  border-color: var(--border-hover);
}

.mail-driver-option.active {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.mail-driver-option .icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.mail-driver-option .label {
  font-weight: 600;
  font-size: 14px;
}

.mail-driver-option .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.smtp-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.smtp-fields.hidden {
  display: none;
}

.smtp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smtp-field.full {
  grid-column: 1 / -1;
}

.smtp-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.mail-test {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-top: 16px;
}

.mail-test input {
  flex: 1;
}

.mail-test-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
}

.mail-test-result.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.mail-test-result.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

/* Mail diagnose */
.mail-diagnose {
  margin: 12px 0;
}

.diagnose-ok {
  padding: 12px 16px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 10px;
  color: var(--success);
  font-size: 13px;
}

.diagnose-error {
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--danger);
  font-size: 13px;
}

.diagnose-error ul {
  margin: 8px 0 0 20px;
  padding: 0;
}

.diagnose-error li {
  margin: 4px 0;
}

.required {
  color: var(--danger);
}

/* Module Admin Cards */
.module-admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.2s ease;
}

.module-admin-card:hover {
  border-color: var(--border-hover);
}

.module-admin-card.inactive {
  opacity: 0.6;
}

.module-admin-card.inactive:hover {
  opacity: 0.8;
}

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

.module-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-glow);
  border-radius: 14px;
}

.module-admin-card h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.module-admin-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  min-height: 40px;
}

.module-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.module-status {
  font-size: 12px;
  font-weight: 600;
}

.module-status.status-active {
  color: var(--success);
}

.module-status.status-inactive {
  color: var(--text-muted);
}

.module-version {
  font-size: 12px;
  color: var(--text-muted);
}

.module-slug {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 6px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 26px;
  transition: all 0.3s ease;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

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

.toggle-switch input:checked+.toggle-slider:before {
  transform: translateX(22px);
  background: #fff;
}

.toggle-switch input:focus+.toggle-slider {
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}


/* Module Models Configuration */
.models-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.models-header .help {
  margin: 0;
  flex: 1;
}

.module-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.module-model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.module-model-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.module-model-header .module-name {
  font-weight: 600;
  font-size: 14px;
}

.module-model-purposes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.purpose-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.purpose-row label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.purpose-row select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.purpose-row select:focus {
  outline: none;
  border-color: var(--primary);
}

.purpose-row select optgroup {
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
}

.purpose-row select option {
  font-weight: normal;
}

.badge-image {
  background: var(--primary-glow);
  color: var(--primary);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

/* =====================================================
   NEW ACTIVITY DASHBOARD - Redesign
   ===================================================== */

/* Hero Stats Section */
.activity-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
}

.hero-stats {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

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

.hero-stat.main .hero-stat-value {
  font-size: 36px;
}

.hero-stat-value {
  font-size: 28px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.hero-stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.hero-period {
  flex-shrink: 0;
}

.hero-period-select {
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hero-period-select:hover {
  border-color: var(--border-hover);
}

.hero-period-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Provider Cost Breakdown */
.provider-cost-breakdown {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.provider-cost-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.provider-cost-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.provider-cost-card.gemini::before {
  background: linear-gradient(90deg, #4285f4, #34a853);
}

.provider-cost-card.grok::before {
  background: linear-gradient(90deg, #1a1a2e, #4a4a6a);
}

.provider-cost-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.provider-cost-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.provider-cost-card.gemini .provider-cost-icon {
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.15) 0%, rgba(52, 168, 83, 0.15) 100%);
  color: #4285f4;
}

.provider-cost-card.grok .provider-cost-icon {
  background: linear-gradient(135deg, rgba(26, 26, 46, 0.15) 0%, rgba(74, 74, 106, 0.15) 100%);
  color: #4a4a6a;
}

.provider-cost-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
}

.provider-cost-value {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.provider-cost-card.gemini .provider-cost-value {
  background: linear-gradient(90deg, #4285f4, #34a853);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.provider-cost-card.grok .provider-cost-value {
  background: linear-gradient(90deg, #1a1a2e, #4a4a6a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.provider-cost-tokens {
  font-size: 13px;
  color: var(--text-muted);
}

.provider-cost-tokens span {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Module Usage Cards */
.activity-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.module-card-loading,
.module-cards-empty {
  grid-column: 1 / -1;
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.module-usage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.module-usage-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.module-usage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.module-usage-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-glow);
  border-radius: 10px;
  flex-shrink: 0;
}

.module-usage-icon .l-icon {
  width: 20px;
  height: 20px;
}

.module-usage-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-usage-stats {
  margin-bottom: 12px;
}

.module-usage-cost {
  font-size: 24px;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.module-usage-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.module-usage-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}

.module-usage-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Filter Bar */
.activity-filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
}

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 200px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.filter-chip .l-icon {
  width: 14px;
  height: 14px;
}

.filter-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-search {
  position: relative;
  min-width: 180px;
}

.filter-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

.filter-search input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
}

.filter-search input:focus {
  outline: none;
  border-color: var(--primary);
}

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

.filter-select {
  padding: 9px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  min-width: 120px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-icon.btn-danger {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.btn-icon.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
  min-height: 300px;
}

.feed-loading,
.feed-empty,
.feed-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.feed-empty .icon,
.feed-error .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.feed-error {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Feed Groups */
.feed-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-top: 8px;
  padding-bottom: 8px;
  z-index: 1;
}

.feed-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Individual Feed Item */
.feed-item {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.15s ease;
}

.feed-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.feed-item.feed-item-error {
  border-left: 3px solid var(--danger);
}

.feed-item-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-glow);
  border-radius: 12px;
  font-size: 18px;
  flex-shrink: 0;
  color: var(--primary);
}

.feed-item-icon.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.feed-item-icon .l-icon {
  width: 20px;
  height: 20px;
}

.feed-item-content {
  flex: 1;
  min-width: 0;
}

.feed-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.feed-item-user {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.feed-item-action {
  font-size: 13px;
  color: var(--text-secondary);
}

.feed-item-module {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 3px 10px;
  border-radius: 20px;
}

.feed-item-module .l-icon {
  width: 12px;
  height: 12px;
}

.feed-item-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: auto;
}

.feed-item-prompt {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  word-break: break-word;
}

.feed-item-error-msg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 8px;
}

.feed-item-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.feed-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
}

.feed-meta-item .l-icon {
  width: 12px;
  height: 12px;
}

.feed-meta-model {
  font-family: monospace;
  font-size: 11px;
}

/* Provider badges */
.feed-meta-provider {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feed-meta-provider-gemini {
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.15) 0%, rgba(52, 168, 83, 0.15) 100%);
  color: #4285f4;
  border: 1px solid rgba(66, 133, 244, 0.3);
}

.feed-meta-provider-grok {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0%, rgba(100, 100, 100, 0.08) 100%);
  color: #1a1a2e;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .feed-meta-provider-gemini {
  background: linear-gradient(135deg, rgba(66, 133, 244, 0.2) 0%, rgba(52, 168, 83, 0.2) 100%);
  color: #8ab4f8;
}

[data-theme="dark"] .feed-meta-provider-grok {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(200, 200, 200, 0.1) 100%);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Load More */
.activity-load-more {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

/* Responsive */
@media (max-width: 900px) {
  .activity-hero {
    flex-direction: column;
    gap: 20px;
  }

  .hero-stats {
    gap: 24px;
  }

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

  .filter-chips {
    min-width: 100%;
  }

  .filter-controls {
    width: 100%;
  }

  .filter-search {
    flex: 1;
  }

  .filter-actions {
    margin-left: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 600px) {
  .activity-hero {
    padding: 20px;
  }

  .hero-stats {
    flex-direction: column;
    gap: 16px;
  }

  .hero-stat.main .hero-stat-value {
    font-size: 28px;
  }

  .hero-stat-value {
    font-size: 22px;
  }

  .activity-modules {
    grid-template-columns: 1fr;
  }

  .feed-item {
    flex-direction: column;
    gap: 12px;
  }

  .feed-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .feed-item-time {
    margin-left: 0;
  }
}

/* =====================================================
   PRICING EDITOR
   ===================================================== */

.pricing-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.pricing-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.pricing-textarea {
  width: 100%;
  min-height: 400px;
  padding: 16px;
  background: var(--bg-elevated);
  border: none;
  color: var(--text);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.pricing-textarea:focus {
  background: var(--bg);
}

.pricing-textarea::placeholder {
  color: var(--text-muted);
}

.pricing-validation {
  padding: 12px 16px;
  font-size: 13px;
  display: none;
}

.pricing-validation.show {
  display: block;
}

.pricing-validation.valid {
  background: rgba(34, 197, 94, 0.1);
  border-top: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.pricing-validation.invalid {
  background: rgba(239, 68, 68, 0.1);
  border-top: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.pricing-validation .validation-icon {
  margin-right: 8px;
}

.pricing-validation .model-count {
  margin-left: 16px;
  color: var(--text-secondary);
}

/* =====================================================
   IMAGE PREVIEW MODAL
   ===================================================== */

.modal-image-preview {
  max-width: 900px;
  max-height: 90vh;
}

.modal-image-preview .modal-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(90vh - 60px);
  overflow: hidden;
}

.image-preview-container {
  flex: 1;
  min-height: 300px;
  max-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

.image-preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}

.image-preview-loading .l-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

#imagePreviewImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-preview-details {
  padding: 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  max-height: 200px;
}

.image-preview-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-prompt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  word-break: break-word;
}

.preview-prompt strong {
  color: var(--text);
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.preview-meta-item {
  font-size: 13px;
  color: var(--text-secondary);
}

.preview-meta-item strong {
  color: var(--text);
  margin-right: 4px;
}

/* Clickable Feed Items */
.feed-item-clickable {
  cursor: pointer;
}

.feed-item-clickable:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.feed-item-preview-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 2px 8px;
  border-radius: 10px;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.feed-item-clickable:hover .feed-item-preview-hint {
  opacity: 1;
}

.feed-item-preview-hint .l-icon {
  width: 12px;
  height: 12px;
}

@media (max-width: 600px) {
  .modal-image-preview {
    max-width: 100%;
    margin: 10px;
  }

  .image-preview-container {
    min-height: 200px;
    max-height: 400px;
  }

  .preview-meta {
    flex-direction: column;
    gap: 8px;
  }
}

/* ============ NOTIFICATIONS DASHBOARD ============ */

.notification-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.notification-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.notification-item.unread {
  background: rgba(99, 102, 241, 0.05);
  border-left: 3px solid var(--primary);
}

.notification-item.read {
  opacity: 0.8;
}

.notification-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.notification-icon.unread {
  background: var(--primary-glow);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.notification-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.notification-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.notification-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.notification-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.notification-delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.notification-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  opacity: 1;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  width: 64px;
  height: 64px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
  color: var(--text-secondary);
}

/* =====================================================
   Backups Page
   ===================================================== */

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

.backups-stats {
  display: flex;
  gap: 24px;
}

.backup-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.backup-stat .stat-number {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.backup-stat .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.backups-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

/* Backup Group (per date) */
.backup-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.backup-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.backup-group-date {
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.backup-group-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.backup-group-items {
  display: flex;
  flex-direction: column;
}

/* Individual backup item within group */
.backup-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

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

.backup-item:hover {
  background: var(--surface-hover);
}

.backup-item-type {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.backup-item-type.database {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}

.backup-item-type.files {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.backup-item-type.unknown {
  background: rgba(161, 161, 170, 0.15);
  color: var(--text-secondary);
}

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

.backup-item-name {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backup-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.backup-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.backup-item:hover .backup-item-actions {
  opacity: 1;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

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

.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Cron Setup */
.cron-setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.cron-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.cron-status.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.cron-status.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.cron-status.inactive {
  background: rgba(161, 161, 170, 0.15);
  color: var(--text-muted);
}

.cron-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.cron-status.active .cron-indicator {
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.cron-details {
  margin-bottom: 16px;
}

.cron-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

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

.cron-value {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}

.cron-url-section {
  margin-top: 16px;
}

.cron-url-section label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cron-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.cron-url-box code {
  flex: 1;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: nowrap;
}

.cron-help {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* Empty state improvements */
.empty-state .empty-icon {
  width: 80px;
  height: 80px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
  color: var(--text-muted);
}

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

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
}

/* =====================================================
   Placement Tracking Visualization
   ===================================================== */

.placement-header {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.placement-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

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

.placement-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

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

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

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

.placement-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.placement-filters {
  display: flex;
  gap: 12px;
  align-items: center;
}

.placement-filters select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  min-width: 140px;
}

.placement-filters select:hover {
  border-color: var(--border-hover);
}

.placement-filters select:focus {
  outline: none;
  border-color: var(--primary);
}

.placement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
}

.placement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.placement-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.placement-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.placement-card-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.placement-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.placement-canvas-preview {
  position: relative;
  background: var(--bg-elevated);
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.placement-svg {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  background: #1a1a1d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.placement-legend {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.placement-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.placement-legend-color {
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

.placement-legend-color.gemini {
  background: #ef4444;
  border: 1px dashed #ef4444;
}

.placement-legend-color.user {
  background: #22c55e;
}

.placement-legend-color.delta {
  background: #f97316;
}

.placement-details {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.placement-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
}

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

.placement-detail-value {
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
}

.placement-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.placement-item-card {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.placement-item-index {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.placement-item-delta {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.placement-item-delta.small {
  color: var(--success);
}

.placement-item-delta.medium {
  color: var(--warning);
}

.placement-item-delta.large {
  color: var(--danger);
}

.placement-item-details {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.placement-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.placement-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.placement-empty h3 {
  color: var(--text);
  margin-bottom: 8px;
}

/* Delta visualization colors in SVG */
.placement-svg .gemini-rect {
  fill: none;
  stroke: #ef4444;
  stroke-width: 2;
  stroke-dasharray: 4 2;
  opacity: 0.8;
}

.placement-svg .user-rect {
  fill: rgba(34, 197, 94, 0.15);
  stroke: #22c55e;
  stroke-width: 2;
}

.placement-svg .delta-arrow {
  stroke: #f97316;
  stroke-width: 2;
  fill: none;
  marker-end: url(#arrowhead);
}

.placement-svg .item-label {
  fill: white;
  font-size: 10px;
  font-weight: bold;
  text-anchor: middle;
}

/* Loading state for placement */
.placement-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 16px;
}

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

/* Placement card header elements */
.placement-card-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.placement-week {
  font-weight: 600;
  color: var(--text);
}

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

.placement-accuracy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.placement-accuracy.high {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.placement-accuracy.medium {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.placement-accuracy.low {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Placement legend in canvas preview */
.placement-canvas-preview .placement-legend {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  gap: 12px;
  font-size: 0.7rem;
  border: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.legend-box {
  width: 12px;
  height: 8px;
  border-radius: 2px;
}

.legend-box.gemini {
  background: rgba(239, 68, 68, 0.3);
  border: 1px dashed rgba(239, 68, 68, 0.6);
}

.legend-box.user {
  background: rgba(34, 197, 94, 0.4);
  border: 1px solid rgba(34, 197, 94, 0.8);
}

.legend-arrow {
  color: var(--warning);
  font-weight: bold;
}

/* Placement card details */
.placement-card-details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
}

.placement-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: var(--bg);
}

.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* Placement item list */
.placement-item-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  max-height: 200px;
  overflow-y: auto;
}

.placement-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.85rem;
}

.item-num {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}

.item-delta {
  color: var(--text);
  font-weight: 500;
}

.item-scale {
  padding: 2px 6px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border-radius: 4px;
  font-size: 0.75rem;
}

.item-rotation {
  padding: 2px 6px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border-radius: 4px;
  font-size: 0.75rem;
}

/* Stats header values */
#placementStats {
  display: flex;
  gap: 24px;
}

#placementStats .placement-stat-value {
  font-variant-numeric: tabular-nums;
}

/* Responsive */
@media (max-width: 640px) {
  .backups-header {
    flex-direction: column;
    align-items: stretch;
  }

  .backups-stats {
    justify-content: space-around;
  }

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

  .placement-header {
    flex-direction: column;
  }

  .placement-stats {
    width: 100%;
    justify-content: space-between;
  }

  .placement-filters {
    width: 100%;
    flex-wrap: wrap;
  }

  .placement-filters select {
    flex: 1;
    min-width: 0;
  }

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

  .placement-legend {
    flex-wrap: wrap;
    gap: 12px;
  }
}

/* =====================================================
   Vision Styles Admin
   ===================================================== */
.vision-styles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.vision-style-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vision-style-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.vision-style-card.inactive {
  opacity: 0.6;
}

.vision-style-image {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg);
  overflow: hidden;
}

.vision-style-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vision-style-image .inactive-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
}

.vision-style-info {
  padding: 14px;
}

.vision-style-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.vision-style-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.vision-style-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
}

.vision-style-actions .btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.vision-style-actions .btn-icon:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.vision-style-actions .btn-icon.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
}

/* Style Form Modal */
.style-form .form-group {
  margin-bottom: 20px;
}

.style-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.style-form .required {
  color: var(--danger);
}

.style-form input[type="text"],
.style-form textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
}

.style-form input[type="text"]:focus,
.style-form textarea:focus {
  border-color: var(--primary);
  outline: none;
}

.style-form .help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.style-image-upload {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
}

.style-image-upload:hover,
.style-image-upload.dragover {
  border-color: var(--primary);
}

.style-image-upload span {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.style-image-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.style-form .checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.style-form .checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.style-form .form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.empty-state,
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.error-state {
  color: var(--danger);
}

/* ============ PRANK MODE ============ */

.pranks-container {
  max-width: 1200px;
}

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

.pranks-header .section-help {
  margin: 0;
  flex: 1;
}

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

.prank-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.prank-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.prank-card.disabled {
  opacity: 0.6;
}

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

.prank-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prank-target {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.prank-images-preview {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.prank-images-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.prank-prompt-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 8px;
  font-style: italic;
  line-height: 1.4;
}

.prank-popup-preview small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.prank-meta {
  margin-bottom: 8px;
}

.prank-meta small {
  font-size: 12px;
  color: var(--text-muted);
}

.prank-dates {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.prank-dates small {
  font-size: 11px;
  color: var(--text-muted);
}

.prank-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.prank-actions .btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary, #a1a1aa);
  cursor: pointer;
  transition: all 0.15s ease;
}

.prank-actions .btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.prank-actions .btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}

/* Prank Modal Form */

.prank-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.prank-image-upload {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted);
}

.prank-image-upload:hover,
.prank-image-upload.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.prank-image-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.prank-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.prank-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prank-thumb.existing {
  border-color: var(--primary);
}

/* Prank Reveal Popup (fullscreen overlay) */

.prank-reveal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  transition: all 0.4s ease;
  pointer-events: none;
}

.prank-reveal-overlay.visible {
  background: rgba(0, 0, 0, 0.85);
  opacity: 1;
  pointer-events: all;
}

.prank-reveal-modal {
  text-align: center;
  padding: 48px 40px;
  transform: scale(0.5) translateY(40px);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.prank-reveal-overlay.visible .prank-reveal-modal {
  transform: scale(1) translateY(0);
}

.prank-reveal-icon {
  margin-bottom: 24px;
  animation: prankBounce 0.6s ease 0.5s both;
}

.prank-reveal-icon svg {
  stroke: #fbbf24;
  filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.5));
}

.prank-reveal-title {
  font-size: 48px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 16px;
  letter-spacing: -1px;
  animation: prankSlideIn 0.5s ease 0.3s both;
}

.prank-reveal-text {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 32px;
  max-width: 500px;
  line-height: 1.5;
  animation: prankSlideIn 0.5s ease 0.5s both;
}

.prank-reveal-close {
  padding: 12px 32px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: prankSlideIn 0.5s ease 0.7s both;
}

.prank-reveal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

@keyframes prankBounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes prankSlideIn {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  .pranks-grid {
    grid-template-columns: 1fr;
  }

  .prank-form .form-row {
    grid-template-columns: 1fr;
  }

  .prank-reveal-title {
    font-size: 36px;
  }

  .prank-reveal-text {
    font-size: 16px;
  }
}