/* ==========================================================================
   VPR ENTERPRISE PORTAL — LUXURY BLACK, CARBON GRAY & GOLDEN YELLOW DESIGN
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #090a0f;
  --bg-card: rgba(19, 22, 31, 0.95);
  --bg-sidebar: #0c0e14;
  --border-color: rgba(255, 255, 255, 0.09);
  --border-gold: rgba(245, 158, 11, 0.35);
  --border-gold-focus: rgba(251, 191, 36, 0.8);

  --accent-gold: #f59e0b;
  --accent-gold-light: #fbbf24;
  --accent-gold-hover: #d97706;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  --accent-gold-subtle: rgba(245, 158, 11, 0.12);

  --accent-primary: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-lg: 0 20px 40px -15px rgba(0,0,0,0.8), 0 0 30px rgba(245,158,11,0.1);
}

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

img, video, canvas, svg { max-width: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb { background: rgba(245,158,11,0.35); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }

/* Utilities */
.hidden { display: none !important; }
.margin-top-xs  { margin-top: 8px; }
.margin-top-sm  { margin-top: 12px; }
.margin-top-md  { margin-top: 16px; }
.margin-bottom-md { margin-bottom: 16px; }
.text-success   { color: var(--accent-emerald) !important; }
.text-muted     { color: var(--text-muted) !important; }
.mobile-header  { display: none; }

/* ==========================================================================
   BASE — BUTTONS
   ========================================================================== */
button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
  color: #000000 !important;
  font-weight: 700 !important;
  padding: 10px 22px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 15px rgba(245,158,11,0.3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
  box-shadow: 0 6px 20px rgba(245,158,11,0.5);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 9px 18px;
  border-radius: 11px;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover {
  background: rgba(245,158,11,0.12);
  border-color: var(--border-gold);
  color: var(--accent-gold-light);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-danger:hover { background: rgba(239,68,68,0.25); border-color: rgba(239,68,68,0.5); }

.btn-sm { padding: 7px 14px !important; font-size: 12px !important; }
.btn-xs { padding: 5px 10px !important; font-size: 11px !important; }
.btn-full { width: 100%; justify-content: center; }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.badge-accent {
  background: rgba(245,158,11,0.15);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold-light);
}

/* Alert */
.alert {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: #fca5a5;
}

/* ==========================================================================
   LOGIN / AUTH WRAPPER
   ========================================================================== */
.auth-wrapper {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: radial-gradient(circle at 50% 30%, #171b26 0%, #090a0f 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(19,22,31,0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(245,158,11,0.22);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.9), 0 0 40px rgba(245,158,11,0.12);
  animation: cardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-header { text-align: center; margin-bottom: 28px; }

.auth-logo-img {
  width: 64px; height: 64px;
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 0 24px rgba(245,158,11,0.3);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: 20px;
  color: var(--accent-gold-light);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.auth-title { font-size: 24px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.auth-form { display: flex; flex-direction: column; gap: 20px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }

.form-group label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
.auth-input {
  width: 100%;
  background: rgba(9,10,15,0.8);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 11px 15px;
  font-size: 14px;
  color: #ffffff;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
.auth-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(245,158,11,0.2);
}

select, .select-input {
  width: 100%;
  background: rgba(9,10,15,0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #ffffff;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}
select:focus, .select-input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(245,158,11,0.2);
}

textarea {
  width: 100%;
  background: rgba(9,10,15,0.8);
  border: 1px solid var(--border-color);
  border-radius: 11px;
  padding: 11px 15px;
  font-size: 13px;
  color: #ffffff;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: all 0.2s ease;
  line-height: 1.5;
}
textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(245,158,11,0.15);
}

/* ==========================================================================
   APP LAYOUT & SIDEBAR
   ========================================================================== */
.app-layout,
.app-container {
  display: flex;
  min-height: 100vh;
  background: var(--bg-dark);
}

.sidebar {
  width: 258px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 18px;
}

.brand-logo-img {
  width: 38px; height: 38px;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(245,158,11,0.25);
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 15px; font-weight: 800; color: #fff; letter-spacing: -0.3px; }
.brand-tier {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-gold-light);
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: 4px;
  padding: 1px 6px;
  display: inline-block;
  margin-top: 2px;
  width: fit-content;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 14px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border-radius: 11px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  position: relative;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--accent-gold-light);
  background: var(--accent-gold-subtle);
  border-color: var(--border-gold);
  box-shadow: 0 2px 12px rgba(245,158,11,0.12);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px;
  background: var(--accent-gold);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-gold);
}
.nav-icon-svg { width: 16px; height: 16px; stroke-width: 2.2; color: inherit; flex-shrink: 0; }
.nav-icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  transition: transform 0.2s ease, filter 0.2s ease;
  flex-shrink: 0;
}
.pill-icon-img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.nav-item:hover .nav-icon-img {
  transform: scale(1.1);
}
.nav-item.active .nav-icon-img {
  transform: scale(1.12);
  filter: drop-shadow(0 0 8px rgba(245,158,11,0.6));
}
.nav-label { flex: 1; }

/* Sidebar footer */
.user-profile {
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  box-shadow: 0 0 10px rgba(245,158,11,0.3);
  flex-shrink: 0;
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--accent-gold-light); font-weight: 700; text-transform: uppercase; }

.btn-signout {
  width: 100%; padding: 8px;
  border-radius: 9px;
  background: rgba(239,68,68,0.08);
  color: #fca5a5;
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(239,68,68,0.18);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-signout:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.4); }

/* ==========================================================================
   MAIN CONTENT AREA — TAB SYSTEM (CRITICAL FIX)
   ========================================================================== */
.main-content {
  margin-left: 258px;
  flex: 1;
  min-height: 100vh;
  box-sizing: border-box;
  position: relative;
}

/* TAB VISIBILITY — THE CRITICAL FIX */
.tab-content {
  display: none;
  animation: tabFadeIn 0.22s ease;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

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

/* Standard padded view (for Admin, Logs, MCP, Gallery tabs) */
.view-section {
  padding: 32px 40px;
  flex: 1;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.header-title-with-icon {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-icon-img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 8px 24px rgba(245,158,11,0.25);
  border: 1px solid rgba(245,158,11,0.3);
  background: rgba(0,0,0,0.5);
  padding: 4px;
}
.view-header h2 {
  font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.4px;
}
.view-header p {
  font-size: 13px; color: var(--text-muted); margin-top: 4px;
}
.view-controls { display: flex; align-items: center; gap: 10px; }

/* ==========================================================================
   CHAT STUDIO — CINEMATIC LAYOUT
   ========================================================================== */
#chatTab {
  height: 100vh;
  padding: 0;
  overflow: hidden;
  position: relative;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Top bar */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(12, 14, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 10;
}
.chat-topbar-title { font-size: 15px; font-weight: 700; color: #fff; }
.chat-topbar-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* Messages scroll area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 40px 10%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

/* Welcome state */
.chat-welcome {
  text-align: center;
  margin: auto;
  padding: 60px 20px;
  max-width: 520px;
}
.welcome-brand {
  font-family: serif;
  font-size: 46px;
  font-weight: 800;
  font-style: italic;
  background: linear-gradient(135deg, #ffffff 30%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}
.chat-welcome h3 { font-size: 18px; font-weight: 700; color: #e2e8f0; margin-bottom: 8px; }
.chat-welcome p  { font-size: 13px; color: var(--text-muted); }

/* Message bubbles */
.chat-msg-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.chat-msg-row.user-row { flex-direction: row-reverse; }

.avatar-3d {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-avatar-3d  { background: rgba(255,255,255,0.1); color: #fff; }
.ai-avatar-3d {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  box-shadow: 0 0 15px rgba(245,158,11,0.35);
}

.chat-bubble {
  max-width: 72%;
  padding: 13px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: #f1f5f9;
  border: 1px solid var(--border-color);
  background: rgba(19,22,31,0.85);
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble-user {
  background: rgba(245,158,11,0.1);
  border-color: rgba(245,158,11,0.28);
}
.bubble-error { color: #fca5a5 !important; border-color: rgba(239,68,68,0.3) !important; }

/* Typing cursor */
.typing-cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--accent-gold);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursorBlink 0.7s step-end infinite;
}
@keyframes cursorBlink { 50% { opacity: 0; } }

/* Floating prompt bar (chat) */
.chat-input-wrapper {
  flex-shrink: 0;
  padding: 16px 10%;
  background: linear-gradient(to top, rgba(9,10,15,1) 60%, transparent);
}

.floating-prompt-bar {
  background: rgba(16,19,28,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.floating-prompt-bar:focus-within {
  border-color: var(--border-gold-focus);
  box-shadow: 0 16px 50px rgba(0,0,0,0.8), 0 0 28px rgba(245,158,11,0.2);
}
.floating-prompt-bar textarea {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  min-height: 44px;
  max-height: 140px;
  padding: 4px 4px;
  color: #f8fafc !important;
}
.floating-prompt-bar textarea::placeholder { color: #475569; }

.prompt-bar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
}
.prompt-controls-left  { display: flex; align-items: center; gap: 6px; }
.prompt-controls-right { display: flex; align-items: center; gap: 10px; }

.btn-prompt-action {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-prompt-action:hover {
  background: rgba(245,158,11,0.12);
  border-color: var(--border-gold);
  color: var(--accent-gold-light);
}

.char-counter { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.btn-send-circle {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 15px rgba(245,158,11,0.4);
  flex-shrink: 0;
}
.btn-send-circle:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 6px 22px rgba(245,158,11,0.55);
  transform: scale(1.08);
}
.btn-send-circle:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ==========================================================================
   CHAT MODEL SELECTOR DROPDOWN
   ========================================================================== */
.custom-model-selector { position: relative; }

.btn-embedded-model {
  height: 32px;
  padding: 0 12px;
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid var(--border-gold) !important;
  border-radius: 10px;
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer;
  color: #fff !important;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  max-width: 220px;
}
.btn-embedded-model:hover {
  background: rgba(245,158,11,0.15) !important;
  border-color: var(--accent-gold) !important;
  color: var(--accent-gold-light) !important;
}
.btn-embedded-model .selected-model-name { overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

.chevron-icon { font-size: 10px; opacity: 0.6; flex-shrink: 0; }
.selected-model-tags { display: flex; align-items: center; gap: 4px; }

.custom-select-dropdown {
  position: absolute !important;
  bottom: calc(100% + 12px) !important;
  top: auto !important;
  left: 0 !important;
  width: 430px !important;
  max-width: 90vw !important;
  max-height: 470px !important;
  background: rgba(11,13,20,0.99) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid rgba(245,158,11,0.3) !important;
  border-radius: 18px !important;
  padding: 16px !important;
  z-index: 9999 !important;
  box-shadow: 0 30px 70px rgba(0,0,0,0.95), 0 0 30px rgba(245,158,11,0.15) !important;
  display: flex;
  flex-direction: column !important;
  gap: 12px !important;
  animation: dropdownSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-select-dropdown.hidden {
  display: none !important;
}
@keyframes dropdownSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-search-box input {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 13px; color: #fff; outline: none; font-family: inherit;
}
.dropdown-search-box input:focus { border-color: var(--accent-gold); }

.dropdown-filters-bar { display: flex; flex-direction: column; gap: 8px; }
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.filter-pills { display: flex; gap: 5px; flex-wrap: wrap; }

.cat-tab, .filter-pill {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
}
.cat-tab.active, .cat-tab:hover,
.filter-pill.active, .filter-pill:hover {
  background: rgba(245,158,11,0.18);
  border-color: var(--border-gold);
  color: var(--accent-gold-light);
}

/* Model list scroll container */
.custom-select-options,
#modelOptionsContainer,
#photoModelOptionsContainer,
#videoModelOptionsContainer,
#photoSelectOptions,
#videoSelectOptions,
#customSelectOptions {
  max-height: 270px !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
}

.custom-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}
.custom-option-item:hover  { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.28); }
.custom-option-item.selected { background: rgba(245,158,11,0.16); border-color: var(--accent-gold); }
.opt-name  { font-size: 13px; font-weight: 600; color: #fff; }
.opt-badges { display: flex; align-items: center; gap: 5px; }
.empty-msg { font-size: 12px; color: var(--text-muted); padding: 8px; text-align: center; }

/* Badge tags */
.badge-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
}
.badge-icon-svg { flex-shrink: 0; }
.tag-safe       { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.28); }
.tag-unlimited  { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.32); }
.tag-uncensored { background: rgba(239,68,68,0.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.28); }
.tag-paid       { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.28); }

/* ==========================================================================
   ✨ CINEMATIC STUDIO LAYOUT — PHOTO & VIDEO
   ========================================================================== */
.studio-cinematic-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  background: #050608;
}

/* Canvas fills all remaining space */
.studio-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(245,158,11,0.04) 0%, #050608 70%);
}

/* The drag-dropzone acts as the full canvas drop target */
.studio-canvas-dropzone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
}
.studio-canvas-dropzone:hover,
.studio-canvas-dropzone.drag-over {
  background: rgba(245,158,11,0.04);
}
.studio-canvas-dropzone.drag-over {
  outline: 2px dashed rgba(245,158,11,0.5);
  outline-offset: -20px;
}

.canvas-empty-state {
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.canvas-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
  display: block;
}
.canvas-empty-state p {
  font-size: 15px;
  color: rgba(255,255,255,0.3);
  font-weight: 500;
  margin-bottom: 6px;
}
.canvas-empty-state span {
  font-size: 12px;
  color: rgba(255,255,255,0.18);
}

/* Canvas preview — uploaded keyframe/image fills the canvas */
.canvas-preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

.canvas-thumb-overlay {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 8px 16px;
}
.canvas-thumb-overlay .file-name {
  font-size: 12px; color: #94a3b8; font-weight: 500;
}
.btn-remove-file {
  font-size: 11px; color: #fca5a5;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 6px;
  padding: 3px 8px;
  font-weight: 600;
}
.btn-remove-file:hover { background: rgba(239,68,68,0.3); }

/* Generated image showcase inside canvas */
.showcase-card {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-direction: column;
}
.showcase-card .rendered-image {
  max-width: 100%;
  max-height: calc(100% - 60px);
  object-fit: contain;
  border-radius: 4px;
}
.showcase-actions {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
}

/* Preview overlay — empty = invisible, has content = covers dropzone */
.studio-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;   /* transparent when empty — clicks pass through to dropzone */
  z-index: 5;
}
.studio-preview-overlay:not(:empty) {
  pointer-events: auto;   /* clickable when content is injected */
  background: #050608;    /* covers the dropzone */
}

/* Render pulse loading inside canvas */
.render-pulse-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(245,158,11,0.2);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Video queued card */
.video-queued-card {
  background: rgba(19,22,31,0.95);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}
.radar-header {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 14px;
}
.radar-header h4 { font-size: 15px; font-weight: 700; color: #fff; }
.status-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseDot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
.video-queued-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.6; }
.video-queued-card code { color: var(--accent-gold-light); font-size: 12px; }
.preview-thumb { max-width: 100%; max-height: 200px; border-radius: 10px; margin-top: 14px; object-fit: contain; }

/* ==========================================================================
   STUDIO FLOATING BOTTOM BAR
   ========================================================================== */
.studio-float-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 14px 24px;
  background: rgba(10,11,17,0.97);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 -12px 40px rgba(0,0,0,0.6);
  position: relative;
  z-index: 50;
}

/* Pill buttons inside the bar */
.sfb-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-subtle);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.sfb-pill:hover {
  background: rgba(245,158,11,0.12);
  border-color: var(--border-gold);
  color: var(--accent-gold-light);
}
.sfb-pill.active {
  background: rgba(245,158,11,0.15);
  border-color: rgba(245,158,11,0.5);
  color: var(--accent-gold-light);
}
.sfb-pill.sfb-model-trigger {
  max-width: 200px;
  overflow: hidden;
}
.sfb-pill .sfb-chevron {
  opacity: 0.5;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.sfb-pill.open .sfb-chevron { transform: rotate(180deg); }

/* Divider between pill groups */
.sfb-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.1);
  margin: 0 12px;
  flex-shrink: 0;
}

/* Upload pill */
.sfb-upload {
  color: var(--text-subtle);
}
.sfb-upload.has-file {
  color: var(--accent-gold-light);
  border-color: rgba(245,158,11,0.4);
  background: rgba(245,158,11,0.1);
}

/* Pill group (e.g. 1:1 / 16:9 / 9:16) */
.sfb-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* The grow-able prompt textarea in the bar */
.sfb-textarea {
  flex: 1;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  color: #f8fafc !important;
  resize: none;
  outline: none !important;
  min-height: 36px;
  max-height: 100px;
  line-height: 1.5;
  font-family: inherit;
  align-self: center;
}
.sfb-textarea::placeholder { color: #374151; }

/* Generate / Send button (circle gold button at right) */
.sfb-generate-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(245,158,11,0.4);
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 0.2s ease;
}
.sfb-generate-btn:hover {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 6px 24px rgba(245,158,11,0.6);
  transform: scale(1.08);
}
.sfb-generate-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* Model selector wrapper inside bar */
.sfb-selector-wrap {
  position: relative;
  flex-shrink: 0;
}
/* Dropdown from sfb opens upward */
.sfb-selector-wrap .custom-select-dropdown {
  bottom: calc(100% + 14px) !important;
  top: auto !important;
  left: 0 !important;
}

/* ==========================================================================
   PHOTO STUDIO — Dropzone preview mode
   ========================================================================== */
.dropzone-preview {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
}

/* ==========================================================================
   ADMIN, GALLERY, LOGS, MCP — PADDED SECTIONS
   ========================================================================== */
#adminTab, #galleryTab, #logsTab, #mcpTab, #settingsTab {
  padding: 32px 40px;
  overflow-y: auto;
}

/* Card */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  /* Do NOT set overflow:hidden here — it blocks inner table-wrapper scroll */
}
.card h3 {
  font-size: 15px; font-weight: 700; color: #fff;
  margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}

/* Table */
.table-container, .table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;       /* desktop: clip rounded corners */
  box-shadow: var(--shadow-lg);
}
.data-table, table {
  width: 100%; border-collapse: collapse; text-align: left; font-size: 13px;
}
th {
  background: rgba(0,0,0,0.6);
  color: #fbbf24 !important;    /* Bright Amber Gold for headers */
  font-weight: 800;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(245,158,11,0.25);
}
td { padding: 13px 18px; border-bottom: 1px solid var(--border-color); color: #f8fafc; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(245,158,11,0.06); }

.role-badge {
  display: inline-block; padding: 3px 8px;
  border-radius: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase;
}
.role-badge.admin { background: rgba(245,158,11,0.18); color: #fbbf24; border: 1px solid rgba(245,158,11,0.38); }
.role-badge.user  { background: rgba(255,255,255,0.08); color: #cbd5e1; }

/* ==========================================================================
   AUDIT LOGS — REAL-TIME CONSOLE
   ========================================================================== */
.auth-logs-box {
  background: rgba(6,8,14,0.98);
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7), inset 0 0 30px rgba(245,158,11,0.05);
  margin-bottom: 20px;
}
.auth-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(0,0,0,0.6);
  border-bottom: 1px solid rgba(245,158,11,0.25);
}
.status-indicator { display: flex; align-items: center; gap: 10px; }
.status-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseDot 1.5s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.85); }
}
.status-label { font-size: 11px; font-weight: 800; color: #34d399; letter-spacing: 0.6px; text-transform: uppercase; }
.logs-feed-tag { font-size: 11px; font-weight: 700; color: #fbbf24; background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); padding: 3px 10px; border-radius: 6px; }

.auth-logs-console {
  padding: 14px 18px;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;   /* prevent console from causing page-level overflow */
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  background: #050609;
}
.console-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-wrap: wrap;
  min-width: 0;         /* allow flex children to shrink below content size */
}
.console-time    { color: #cbd5e1 !important; font-weight: 600; flex-shrink: 0; }
.console-method  { font-weight: 900; flex-shrink: 0; min-width: 40px; padding: 1px 5px; border-radius: 4px; font-size: 11px; text-align: center; }
.console-method.POST { color: #000000 !important; background: #38bdf8 !important; }
.console-method.GET  { color: #000000 !important; background: #4ade80 !important; }
.console-endpoint { color: #ffffff !important; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-model   { color: #fbbf24 !important; font-weight: 700; font-size: 11px; background: rgba(245,158,11,0.12); padding: 1px 6px; border-radius: 4px; border: 1px solid rgba(245,158,11,0.25); }
.console-status  { font-weight: 800; flex-shrink: 0; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.console-status.s200 { color: #4ade80 !important; background: rgba(74,222,128,0.12); }
.console-status.s400, .console-status.s401, .console-status.s403, .console-status.s404 { color: #fbbf24 !important; background: rgba(251,191,36,0.12); }
.console-status.s500 { color: #f87171 !important; background: rgba(248,113,113,0.12); }

/* ==========================================================================
   USER MANAGEMENT MODAL
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-card {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  background: rgba(13,16,25,0.99);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(245,158,11,0.22);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.9), 0 0 40px rgba(245,158,11,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 20px; font-weight: 800; color: #fff; margin-top: 8px; }
.modal-subtitle  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-close:hover { background: rgba(239,68,68,0.15); color: #fca5a5; border-color: rgba(239,68,68,0.3); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-section-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}
.modal-card-title {
  font-size: 13px; font-weight: 700; color: var(--accent-gold-light);
  margin-bottom: 16px;
  text-transform: uppercase; letter-spacing: 0.3px;
}

.form-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sub-label { font-size: 11px; font-weight: 700; color: var(--text-muted); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }

/* Feature pills */
.feature-pills-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.feature-pill-card {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  cursor: pointer; transition: all 0.15s;
  user-select: none;
}
.feature-pill-card:hover,
.feature-pill-card:has(input:checked) {
  background: rgba(245,158,11,0.12);
  border-color: var(--border-gold);
}
.feature-pill-card input { accent-color: var(--accent-gold); width: 14px; height: 14px; }
.pill-body { font-size: 12px; font-weight: 600; color: var(--text-main); }

/* Quota inputs */
.quota-inputs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quota-input-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
}
.quota-hint { font-size: 10px; color: var(--text-muted); display: block; margin-top: 4px; }

/* Models checklist */
.admin-models-checklist,
.models-checklist-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.models-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.checklist-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent-gold-light);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-text:hover {
  background: rgba(245, 158, 11, 0.12);
}

.card-header-flex { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.model-quick-actions { display: flex; align-items: center; gap: 8px; }
.btn-text-action { font-size: 12px; color: var(--accent-gold-light); font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.btn-text-action:hover { background: rgba(245,158,11,0.12); }
.sep { color: var(--text-muted); }

.model-category-header { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 0 4px; }
.model-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.025);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--text-subtle);
  transition: all 0.12s;
}
.model-check-item:hover { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.2); }
.model-check-item input { accent-color: var(--accent-gold); flex-shrink: 0; }

.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 18px 28px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

/* ==========================================================================
   MEDIA GALLERY
   ========================================================================== */
.gallery-filter-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.2s;
}
.media-card:hover { border-color: var(--border-gold); transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.5); }
.media-card img, .media-card video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
/* Form wrapper inside modal card — flex layout enables inner body scroll */
#userForm,
#apiKeyForm {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ==========================================================================
   MEDIA GALLERY REDESIGN
   ========================================================================== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.media-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.media-card:hover {
  border-color: var(--border-gold);
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.7), 0 0 25px rgba(245,158,11,0.12);
}

.media-preview-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-preview-box img,
.media-preview-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.media-card:hover .media-preview-box img {
  transform: scale(1.04);
}

.media-type-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--accent-gold-light);
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px;
}

.media-info {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.media-title {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.media-model-tag {
  color: var(--accent-gold-light);
  font-weight: 700;
  font-size: 10px;
}
.media-date { color: #64748b; }

.media-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.empty-gallery {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
}

/* ==========================================================================
   DUAL ENGINE SETTINGS REDESIGN
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.guide-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.auth-mode-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.18s ease;
}
.mode-card:hover {
  background: rgba(245,158,11,0.06);
  border-color: rgba(245,158,11,0.3);
}
.mode-card:has(input:checked) {
  background: rgba(245,158,11,0.12);
  border-color: var(--accent-gold);
  box-shadow: 0 4px 20px rgba(245,158,11,0.15);
}
.mode-card input[type="radio"] {
  accent-color: var(--accent-gold);
  width: 16px; height: 16px;
  margin-top: 3px;
  flex-shrink: 0;
}

.mode-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

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

/* Background Refresher Status Summary */
.status-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(6,8,14,0.9);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: inset 0 0 30px rgba(245,158,11,0.03);
}

.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.summary-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sum-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.sum-value {
  font-size: 12px;
  font-weight: 700;
  color: #f1f5f9;
}

/* ==========================================================================
   MCP ENDPOINTS
   ========================================================================== */
.mcp-endpoint-box { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.endpoint-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ep-label { font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.endpoint-item code {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--accent-gold-light);
  font-family: 'Courier New', monospace;
}
.mcp-tools-list { display: flex; flex-direction: column; gap: 8px; }
.tool-tag {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px; color: var(--text-subtle);
}
.tool-tag code { color: var(--accent-gold-light); font-size: 12px; }

/* ==========================================================================
   MOBILE HEADER
   ========================================================================== */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px; z-index: 200;
  background: rgba(12,14,20,0.97);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}
.mobile-menu-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-main);
}
.mobile-brand { display: flex; align-items: center; gap: 8px; }
.mobile-logo-img { width: 28px; height: 28px; border-radius: 8px; }
.mobile-brand-title { font-size: 14px; font-weight: 700; color: #fff; }
.mobile-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(2px);
}
.mobile-overlay.active { display: block; }

/* ==========================================================================
   RESPONSIVE — TABLET (≤1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .settings-grid { grid-template-columns: 1fr; }
  .quota-inputs-grid { grid-template-columns: 1fr 1fr; }
  .studio-float-bar { padding: 12px 16px; gap: 6px; }
  .sfb-textarea { min-width: 80px; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ==========================================================================
   RESPONSIVE — MOBILE (≤768px)
   ========================================================================== */
@media (max-width: 768px) {

  /* -------- Global Layout Boundaries -------- */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }

  /* -------- Mobile Top Header -------- */
  .mobile-header {
    display: flex;
  }

  /* -------- Sidebar Drawer -------- */
  .sidebar {
    width: 270px;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 150;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-overlay {
    z-index: 140;
  }

  /* -------- Main Workspace -------- */
  .main-content {
    margin-left: 0;
    padding-top: 56px;
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  .tab-content {
    max-width: 100vw !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  /* -------- Chat Studio Mobile -------- */
  #chatTab {
    height: calc(100vh - 56px);
  }
  .chat-container {
    height: calc(100vh - 56px);
  }
  .chat-topbar {
    padding: 12px 16px;
  }
  .chat-messages {
    padding: 16px 12px;
    gap: 12px;
  }
  .chat-bubble {
    max-width: 88%;
    font-size: 13px;
    padding: 10px 13px;
  }
  .chat-input-wrapper {
    padding: 8px 10px;
  }
  .floating-prompt-bar {
    padding: 8px 10px;
    border-radius: 16px;
  }
  .prompt-bar-bottom {
    padding-top: 6px;
  }
  .btn-embedded-model {
    max-width: 140px;
    font-size: 11px;
    padding: 0 8px;
  }
  .btn-embedded-model .selected-model-name {
    max-width: 75px;
  }
  .chat-welcome {
    padding: 30px 14px;
  }
  .welcome-brand {
    font-size: 30px;
  }
  .chat-welcome h3 {
    font-size: 15px;
  }

  /* -------- Mobile Fixed-Centered Dropdown (FACT FIX) -------- */
  .custom-select-dropdown,
  .sfb-selector-wrap .custom-select-dropdown {
    position: fixed !important;
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: 65vh !important;
    transform: none !important;
    z-index: 99999 !important;
    border-radius: 18px !important;
    margin: 0 !important;
    box-shadow: 0 0 60px rgba(0,0,0,0.95), 0 0 30px rgba(245,158,11,0.2) !important;
  }

  /* -------- Photo & Video Studio (2-Row Float Bar FACT FIX) -------- */
  .studio-cinematic-layout {
    height: calc(100vh - 56px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .studio-canvas {
    flex: 1;
    min-height: 180px;
    overflow: hidden;
  }
  .studio-float-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(10,11,17,0.98);
    border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 -8px 30px rgba(0,0,0,0.7);
    flex-shrink: 0;
  }

  /* Row 1: Textarea full width on top */
  .sfb-textarea {
    order: -1 !important;
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    min-height: 44px;
    max-height: 80px;
    font-size: 13px !important;
    margin-bottom: 2px;
    box-sizing: border-box !important;
  }
  .sfb-textarea:focus {
    border-color: var(--accent-gold) !important;
  }

  /* Row 2 Controls */
  .sfb-divider {
    display: none !important;
  }
  .sfb-selector-wrap {
    order: 1 !important;
    flex-shrink: 0;
  }
  .sfb-pill-group {
    order: 2 !important;
    flex-shrink: 0;
    max-width: 48%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sfb-action-group {
    order: 3 !important;
    margin-left: auto !alignment;
    flex-shrink: 0;
  }
  .sfb-pill.sfb-model-trigger {
    max-width: 135px;
    padding: 0 8px;
    font-size: 11px;
  }

  /* -------- Admin / Gallery / Logs / MCP / Settings Padded Sections -------- */
  #adminTab,
  #galleryTab,
  #logsTab,
  #mcpTab,
  #settingsTab {
    padding: 14px 10px 24px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* -------- View Header -------- */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    width: 100%;
    box-sizing: border-box;
  }
  .header-title-with-icon {
    gap: 10px;
    min-width: 0;
    width: 100%;
  }
  .header-title-with-icon > div {
    min-width: 0;
    flex: 1;
  }
  .header-title-with-icon h2,
  .view-header h2 {
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .header-title-with-icon p,
  .view-header p {
    font-size: 11px;
  }
  .header-icon-img {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }
  .view-controls,
  .view-header > div:last-child {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .view-controls > button,
  .view-header > div:last-child > button {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  /* -------- Cards Container -------- */
  .card {
    width: 100%;
    max-width: 100%;
    padding: 14px 10px;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 16px;
  }

  /* -------- System Audit Logs Box -------- */
  .auth-logs-box {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    border-radius: 14px;
  }
  .auth-logs-header {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }
  .status-indicator {
    min-width: 0;
  }
  .status-label {
    font-size: 10px;
    white-space: nowrap;
  }
  .logs-feed-tag {
    font-size: 10px;
    padding: 2px 6px;
  }
  .auth-logs-console {
    padding: 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
  }
  .console-line {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 11px;
    padding: 3px 0;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    flex-wrap: wrap;
  }
  .console-time {
    font-size: 10px;
    flex-shrink: 0;
  }
  .console-method {
    font-size: 11px;
    flex-shrink: 0;
  }
  .console-endpoint {
    font-size: 11px;
    flex: 1 1 100%;
    word-break: break-all;
    white-space: normal;
    min-width: 0;
  }

  /* -------- Data Tables Horizontal Scroll (FACT FIX) -------- */
  .table-wrapper,
  .table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    display: block;
    box-sizing: border-box;
  }

  .data-table,
  table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
    font-size: 11px;
    white-space: nowrap;
  }

  .data-table td .btn {
    padding: 3px 7px !important;
    font-size: 10px !important;
    gap: 3px !important;
  }

  /* -------- Media Gallery -------- */
  .media-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .batch-toolbar {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 10px !important;
  }
  .batch-toolbar-left,
  .batch-toolbar-right {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }
  .batch-toolbar-right .btn {
    flex: 1;
    justify-content: center;
  }

  /* -------- Settings Grid -------- */
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .quota-inputs-grid {
    grid-template-columns: 1fr;
  }
  .form-grid-2col {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* -------- Modals Mobile -------- */
  .modal-backdrop {
    padding: 12px;
    align-items: center;
    justify-content: center;
  }
  .modal-card {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px;
  }
  .modal-header {
    padding: 16px 18px 14px;
  }
  .modal-header h2 {
    font-size: 17px;
  }
  .modal-body {
    padding: 16px 18px;
    gap: 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-models-checklist {
    max-height: 220px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    padding: 14px 18px;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }

  /* User Gallery Modal */
  #userGalleryModal .modal-content,
  .modal-lg {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
  }
  #userGalleryModal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* -------- MCP Endpoint Cards -------- */
  .endpoint-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .endpoint-item code {
    word-break: break-all;
    font-size: 11px;
  }
}

/* ==========================================================================
   RESPONSIVE — SMALL PHONES (≤480px)
   ========================================================================== */
@media (max-width: 480px) {
  .media-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .btn-embedded-model {
    max-width: 110px;
  }
  .selected-model-name {
    display: none;
  }
  .sfb-pill {
    padding: 0 7px;
    height: 32px;
    font-size: 11px;
  }
  .sfb-clear-btn {
    height: 34px;
    padding: 0 8px;
    font-size: 11px;
  }
  .sfb-generate-btn {
    width: 36px;
    height: 36px;
  }
  .auth-card {
    padding: 24px 16px;
    border-radius: 16px;
  }
  .welcome-brand {
    font-size: 26px;
  }
}

/* ==========================================================================
   WORKSPACE CLEAR & BATCH GALLERY STYLES
   ========================================================================== */
.sfb-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sfb-clear-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.sfb-clear-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #fff;
  transform: translateY(-1px);
}

.batch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1px solid var(--border-gold) !important;
  border-radius: 14px !important;
}
.batch-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.checkbox-label-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
}
.selected-count-badge {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.batch-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-select-cb {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #f59e0b;
}

.modal-lg {
  max-width: 900px;
  width: 90vw;
}

/* User Gallery Modal base positioning */
#userGalleryModal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#userGalleryModal .modal-content {
  background: rgba(13, 16, 25, 0.99);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.9), 0 0 40px rgba(245, 158, 11, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
  width: 90vw;
  max-width: 900px;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
#userGalleryModal .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
#userGalleryModal .modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}
#userGalleryModal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
#userGalleryModal .modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-close-modal:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}