/* --- System Design & Color Tokens (Geschool Blue Theme) --- */
:root {
  --geschool-blue-dark: #145a9f;
  --geschool-blue-light: #2388d8;
  --geschool-blue-bg: #edf3f8;
  --bg-chat-pattern: #eef3f8;
  --panel-bg: #ffffff;
  --border-color: #d7e1ec;
  
  --text-primary: #182338;
  --text-secondary: #5d6f84;
  --text-muted: #9aa8b8;
  
  --bubble-user: #1769c2;
  --bubble-user-text: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-bot-border: #dce5ee;
  --bubble-bot-text: #1f2c3f;
  
  --success-color: #00ba7c;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-title: 'Plus Jakarta Sans', var(--font-family-sans);
}

/* --- Base Resets & Layout --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-sans);
  background-color: #e9f0f7;
  color: var(--text-primary);
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  /* Prevent iOS rubber-band scroll on body */
  position: fixed;
  width: 100%;
}

/* App Layout Grid (Desktop vs Mobile) */
.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #eef3f8;
  overflow: hidden;
}

.sidebar {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  visibility: hidden !important;
}

.geschool-logo {
  height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Chat Area Container */
.chat-container {
  flex-grow: 1;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #eef3f8;
  position: relative;
}

/* Chat Header */
.chat-header {
  padding: 13px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(201, 213, 226, 0.82);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  box-shadow: 0 8px 22px rgba(31, 44, 63, 0.05);
  flex-shrink: 0;
}

.header-bot-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0; /* allow text truncation */
}

.mobile-logo-container {
  height: 38px;
  width: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f8fbfe;
  border: 1px solid rgba(215, 225, 236, 0.95);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 6px 18px rgba(20, 90, 159, 0.08);
}

@media (min-width: 768px) {
  .mobile-logo-container {
    display: flex;
  }
}

.header-details h2 {
  font-family: var(--font-family-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-details p {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success-color);
  box-shadow: 0 0 0 4px rgba(0, 186, 124, 0.12);
  display: inline-block;
}

.verified-badge {
  color: var(--geschool-blue-light);
  font-size: 14px;
  margin-left: 4px;
  user-select: none;
}

.header-actions button {
  background: #f8fbfe;
  border: 1px solid rgba(215, 225, 236, 0.95);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.header-actions button:hover {
  background: #edf6ff;
  color: var(--geschool-blue-dark);
}

/* Chat Body area */
.chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 34px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  /* iOS momentum scrolling */
  -webkit-overflow-scrolling: touch;
}

/* Welcome Container styling */
.welcome-container {
  width: 100%;
  max-width: 560px;
  margin: auto;
  text-align: center;
  padding: 40px 36px 34px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(32, 54, 76, 0.10);
  border: 1px solid rgba(211, 222, 234, 0.9);
  animation: fadeIn 0.4s ease;
}

.welcome-logo {
  height: 76px;
  width: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 18px;
}

.welcome-container h1 {
  font-family: var(--font-family-title);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-container .subtitle {
  max-width: 430px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 auto 24px;
}

.suggestions-container {
  width: 100%;
}

.suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 4px 0 0;
}

.suggestion-tag {
  background: #ffffff;
  border: 1px solid rgba(23, 105, 194, 0.28);
  border-radius: 999px;
  padding: 9px 15px;
  margin: 0;
  font-family: var(--font-family-sans);
  font-size: 13px;
  font-weight: 600;
  color: #1769c2;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
  width: auto;
  display: inline-block;
  word-break: break-word;
}

.suggestion-tag:hover {
  background: #f2f8ff;
  border-color: rgba(23, 105, 194, 0.55);
  box-shadow: 0 8px 20px rgba(23, 105, 194, 0.10);
  transform: translateY(-1px);
}

/* Jarak antar pesan & struktur wrapper */
.message-wrapper {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: 880px;
  margin: 0 auto 12px auto;
}

.message-wrapper:last-child {
  margin-bottom: 0;
}

.message-wrapper.bot {
  align-items: flex-start;
  padding-left: 40px; /* Jarak untuk avatar di kiri */
}

.message-wrapper.user {
  align-items: flex-end;
}

/* Avatar Bot */
.message-wrapper.bot .avatar {
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #dce5ee;
  box-shadow: 0 6px 18px rgba(20, 90, 159, 0.08);
}

/* Bubble General */
.bubble {
  font-size: 14.5px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

/* Bubble User */
.bubble.user {
  background-color: var(--bubble-user);
  color: #ffffff;
  border-radius: 18px 18px 6px 18px;
  padding: 11px 15px;
  max-width: 68%;
  line-height: 1.5;
  box-shadow: 0 10px 24px rgba(23, 105, 194, 0.18);
}

/* Bubble Bot */
.bubble.bot {
  background-color: #FFFFFF;
  color: #1f2937;
  border: 1px solid var(--bubble-bot-border);
  border-radius: 18px 18px 18px 6px;
  padding: 14px 17px;
  max-width: 75%;
  line-height: 1.6;
  box-shadow: 0 10px 30px rgba(32, 54, 76, 0.08);
}

.bubble.bot .message-text {
  line-height: 1.62;
}

/* Timestamp */
.timestamp {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 4px;
  display: inline-block;
}

.message-wrapper.user .timestamp {
  align-self: flex-end;
  margin-right: 4px;
}

.message-wrapper.bot .timestamp {
  align-self: flex-start;
  margin-left: 4px;
}

/* Markdown parsing support spacing */
.bubble p {
  margin-bottom: 8px;
}
.bubble p:last-child {
  margin-bottom: 0;
}
.bubble strong {
  font-weight: 600;
  color: inherit;
}
.bubble ul, .bubble ol {
  margin: 8px 0 12px;
  padding-left: 24px;
}

/* Markdown list rendering — pastikan angka/bullet muncul rapi */
.bubble.bot ol {
  list-style: decimal outside;
}
.bubble.bot ul {
  list-style: disc outside;
}
.bubble.bot .chat-list {
  display: grid;
  gap: 7px;
  margin: 9px 0 13px;
  padding-left: 25px;
}
.bubble.bot .chat-list-ordered {
  gap: 10px;
}
.bubble.bot .chat-list-unordered {
  margin-top: 4px;
}
.bubble.bot li {
  display: list-item;
  margin: 0;
  padding-left: 4px;
  line-height: 1.55;
}
.bubble.bot li::marker {
  color: var(--geschool-blue-dark);
  font-weight: 700;
}
.bubble.bot p {
  margin: 0 0 8px;
}
.bubble.bot p:last-child {
  margin-bottom: 0;
}
.bubble.bot .message-gap {
  height: 7px;
}
.bubble code {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 13px;
}
.bubble pre {
  background-color: #1e1e2e;
  color: #cdd6f4;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 13px;
  margin: 10px 0;
}
.bubble pre code {
  background-color: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.bubble iframe {
  max-width: 100%;
  border-radius: 8px;
  margin: 10px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
}

/* Source references */
.source-info-container {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
}

.source-toggle-btn {
  background: transparent;
  border: none;
  color: var(--geschool-blue-light);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 2px 0;
}

.source-content {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-content.hidden {
  display: none;
}

.source-item {
  display: flex;
  justify-content: space-between;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-secondary);
}

.source-match {
  font-weight: 600;
}

.match-high { color: #10b981; }
.match-mid { color: #f59e0b; }
.match-fallback { color: #64748b; }

/* Typing indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #9CA3AF;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Footer / Input area */
.chat-footer {
  padding: 14px 24px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(201, 213, 226, 0.82);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.chat-input-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.input-wrapper {
  flex-grow: 1;
  background: #ffffff;
  border: 1px solid #cfdae7;
  border-radius: 18px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--geschool-blue-light);
  box-shadow: 0 0 0 4px rgba(35, 136, 216, 0.12);
}

#chat-input {
  width: 100%;
  background: transparent;
  border: none;
  resize: none;
  font-family: var(--font-family-sans);
  font-size: 14px;
  color: var(--text-primary);
  max-height: 100px;
  line-height: 1.5;
  outline: none;
  /* Prevent iOS auto-zoom on focus (< 16px triggers zoom) */
  font-size: max(16px, 14px);
}

#send-btn {
  background: var(--geschool-blue-dark);
  color: #ffffff;
  border: none;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 12px 26px rgba(20, 90, 159, 0.24);
}

#send-btn:hover {
  background: var(--geschool-blue-light);
  transform: scale(1.05);
}

.app-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 2px;
}

.mobile-admin-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
}

.mobile-admin-link:hover {
  color: var(--geschool-blue-dark);
}

/* Scroll to Bottom Button */
.scroll-bottom-btn {
  position: absolute;
  bottom: 100px;
  right: 30px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 15;
  transition: opacity 0.2s, transform 0.2s;
  color: var(--text-secondary);
}

.scroll-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.scroll-bottom-btn:hover {
  color: var(--text-primary);
  background: #f8fafc;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* --- Admin Dashboard Styles (Light Theme) --- */
.admin-body {
  background-color: #f5f6fa; /* Light theme for admin */
  color: #334155;
  height: auto !important;
  min-height: 100vh;
  display: block;
  overflow-y: auto !important;
  position: static !important;
  width: 100%;
}

/* Navbar Styles */
.admin-navbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-logo {
  height: 36px;
  width: auto;
}

.navbar-brand {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 20px;
  color: var(--geschool-blue-dark);
}

.navbar-center {
  display: flex;
  gap: 30px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  height: 64px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--geschool-blue-dark);
}

.nav-link.active {
  color: var(--geschool-blue-dark);
  border-bottom-color: var(--geschool-blue-dark);
}

.navbar-right {
  display: flex;
  align-items: center;
}

.profile-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.profile-menu:hover {
  background-color: #f1f5f9;
}

.profile-pic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.profile-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}

.admin-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.admin-container-header {
  margin-bottom: 20px;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--geschool-blue-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s;
}

.back-link:hover {
  opacity: 0.8;
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  border: 1px solid var(--border-color);
}

.admin-card h2 {
  color: var(--text-primary);
  font-size: 18px;
  margin-bottom: 20px;
  font-family: var(--font-family-title);
  font-weight: 600;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.form-group textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--geschool-blue-light);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.help-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-group label {
  margin-bottom: 0;
  cursor: pointer;
}

.btn-primary {
  background: var(--geschool-blue-light);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--geschool-blue-dark);
  transform: translateY(-1px);
}

.status-message {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: opacity 0.3s;
}

.status-message.hidden {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.status-message.success {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.status-message.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* --- Login Overlay --- */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.login-box {
  background: #ffffff;
  padding: 30px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 350px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  text-align: center;
}

.login-box h2 {
  color: var(--geschool-blue-dark);
  font-family: var(--font-family-title);
  margin-bottom: 10px;
}

.login-box p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

.login-box input {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  font-size: 14px;
}

.login-box input:focus {
  outline: none;
  border-color: var(--geschool-blue-light);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* API Key management styles */
.admin-input {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-family-sans);
  font-size: 14px;
}

.admin-input:focus {
  outline: none;
  border-color: var(--geschool-blue-light);
  background: #ffffff;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-primary);
  border: 1px solid #cbd5e1;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #fca5a5;
  transform: translateY(-1px);
}

/* ============================================================ */
/* Clickable Links in Chat Bubbles                               */
/* ============================================================ */
.chat-link {
  color: var(--geschool-blue-light);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  word-break: break-all;
  transition: color 0.2s;
}
.chat-link:hover {
  color: var(--geschool-blue-dark);
  text-decoration-style: solid;
}
/* Link warna putih di dalam bubble user (biru) */
.message-wrapper.user .chat-link {
  color: #cce8ff;
}
.message-wrapper.user .chat-link:hover {
  color: #ffffff;
}

.yt-embed-wrapper {
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  animation: fadeInUp 0.3s ease;
}
.yt-link-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  width: 100%;
}
.yt-thumbnail-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #000;
}
.yt-play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}
.yt-link-card:hover .yt-play-overlay {
  background: rgba(0, 0, 0, 0.45);
}
.play-icon {
  color: #ffffff;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.5));
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.yt-link-card:hover .play-icon {
  transform: scale(1.2);
  color: #ff0000; /* YouTube Red on hover */
}
.yt-card-info {
  padding: 10px 14px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
}
.yt-card-title {
  font-weight: 600;
  color: #1e293b;
}
.yt-card-action {
  color: var(--geschool-blue-light, #1a6eb5);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================ */
/* Forgot Password / Reset Token Button in Admin Login          */
/* ============================================================ */
.btn-forgot-pw {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s;
  padding: 0;
}
.btn-forgot-pw:hover {
  color: var(--geschool-blue-light);
}


/* ============================================================ */
/* RESPONSIVE BREAKPOINTS — Mobile First                         */
/* ============================================================ */

/* --- Small phones (< 375px, e.g. iPhone SE) --- */
@media (max-width: 374px) {
  .welcome-container {
    padding: 18px 12px;
  }
  .welcome-logo {
    height: 56px;
    margin-bottom: 12px;
  }
  .welcome-container h1 {
    font-size: 17px;
  }
  .welcome-container .subtitle {
    font-size: 12.5px;
  }
  .suggestions-list {
    justify-content: center;
  }
  .bubble.user, .bubble.bot {
    max-width: 90%;
    font-size: 13.5px;
  }
  .chat-body {
    padding: 14px 10px;
  }
  .chat-footer {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
}

/* --- Normal phones (375px – 767px, iPhone/Android) --- */
@media (max-width: 767px) {
  body {
    background-color: #ffffff;
  }

  .app-layout {
    /* Fill entire screen on mobile */
    max-width: 100%;
    border-radius: 0;
  }

  .chat-body {
    padding: 16px 12px;
    gap: 12px;
  }

  .welcome-container {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  }

  .message-wrapper {
    max-width: 100%;
  }

  .bubble.user, .bubble.bot {
    max-width: 85%;
    font-size: 14px;
    padding: 10px 13px;
  }

  /* Bot avatar smaller on mobile */
  .message-wrapper.bot .avatar {
    width: 26px;
    height: 26px;
  }
  .message-wrapper.bot {
    padding-left: 36px;
  }

  /* Hide scroll button on small screens to avoid overlap */
  .scroll-bottom-btn {
    bottom: 80px;
    right: 14px;
    width: 36px;
    height: 36px;
  }

  /* Input area optimized */
  .chat-footer {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  #send-btn {
    width: 40px;
    height: 40px;
  }

  /* Typing indicator */
  #typing-indicator {
    max-width: 100%;
  }

  /* Chat header tighter on mobile */
  .chat-header {
    padding: 10px 14px;
  }

  .header-details p {
    font-size: 12px;
  }
}

/* --- Tablets & iPad (768px – 1023px) --- */
@media (min-width: 768px) and (max-width: 1023px) {
  .chat-body {
    padding: 20px 20px;
  }

  .bubble.user, .bubble.bot {
    max-width: 75%;
  }

  .message-wrapper {
    max-width: 700px;
  }

  .welcome-container {
    max-width: 420px;
    padding: 28px 22px;
  }

  .suggestions-list {
    justify-content: center;
  }

  .chat-footer {
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* --- iPad Pro / Large Tablets (1024px+) --- */
@media (min-width: 1024px) {
  .bubble.user, .bubble.bot {
    max-width: 68%;
  }

  .suggestions-list {
    justify-content: center;
  }
}

/* --- Desktop (1280px+) --- */
@media (min-width: 1280px) {
  .bubble.user, .bubble.bot {
    max-width: 65%;
  }

  .welcome-container {
    max-width: 500px;
    padding: 36px 30px;
  }

  .welcome-container h1 {
    font-size: 24px;
  }

  .suggestions-list {
    grid-template-columns: 1fr 1fr;
  }

  .chat-body {
    padding: 28px 24px;
  }
}

/* --- iOS Safari notch / safe area fix --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-footer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

/* --- API Key Status Dashboard --- */
.api-status-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-status-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  background-color: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.api-key-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.api-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ok {
  background-color: #e6f6ec;
  color: #0d8a43;
  border: 1px solid #c2ebd0;
}

.badge-limited {
  background-color: #ffebee;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

.badge-unknown {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.badge-error {
  background-color: #fef3c7;
  color: #d97706;
  border: 1px solid #fde68a;
}

.api-status-usage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.usage-text {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.usage-bar-bg {
  height: 8px;
  background-color: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.usage-bar-fill.normal {
  background-color: #10b981;
}

.usage-bar-fill.warning {
  background-color: #f59e0b;
}

.usage-bar-fill.danger {
  background-color: #ef4444;
}

.api-meta-info {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.api-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Password Field with Toggle --- */
.password-field-wrap {
  position: relative;
  width: 100%;
}

.password-field-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding-right: 44px;
}

.btn-toggle-pw {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  height: 100%;
  border-radius: 0 10px 10px 0;
  transition: color 0.2s;
}

.btn-toggle-pw:hover {
  color: var(--geschool-blue);
}

/* --- Logout Button in Navbar --- */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-family: inherit;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.6);
}

/* --- Secondary Button --- */
.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

/* --- Key Row (new layout) --- */
.key-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fafbfc;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.key-row-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.key-index {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  min-width: 50px;
}

.key-preview {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.key-date {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

/* --- Add Key Form --- */
.add-key-form {
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 14px;
}

/* --- Spin animation for login spinner --- */
@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spin-icon {
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

/* --- Login logo --- */
.login-logo-wrap {
  text-align: center;
  margin-bottom: 12px;
}

.login-logo {
  height: 48px;
  width: auto;
}

/* --- Info toast type --- */
.status-message.info {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* --- Login Close Button (×) --- */
.login-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  text-decoration: none;
  transition: background 0.18s, color 0.18s, transform 0.18s;
  z-index: 10;
}

.login-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: scale(1.1);
}

/* Ensure login-box is positioned relative for the close button */
.login-box {
  position: relative;
}

/* ============================================================ */
/* Admin Enterprise Polish                                      */
/* ============================================================ */
.admin-body {
  background:
    radial-gradient(circle at top left, rgba(35, 136, 216, 0.10), transparent 34rem),
    linear-gradient(180deg, #f7faff 0%, #eef3f8 100%) !important;
  color: #172033;
}

.admin-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 68px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.92) !important;
  border-bottom: 1px solid rgba(202, 213, 226, 0.72) !important;
  box-shadow: 0 12px 34px rgba(24, 35, 56, 0.06) !important;
  backdrop-filter: blur(16px);
}

.navbar-left {
  min-width: 180px;
}

.navbar-logo {
  height: 38px;
  padding: 5px;
  border: 1px solid rgba(215, 225, 236, 0.95);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 90, 159, 0.08);
}

.navbar-brand {
  color: #172033 !important;
  letter-spacing: 0;
}

.navbar-center {
  gap: 8px;
  padding: 5px;
  border: 1px solid rgba(215, 225, 236, 0.72);
  border-radius: 999px;
  background: #f8fbfe;
}

.nav-link {
  height: auto;
  min-height: 38px;
  padding: 0 14px;
  border-bottom: 0 !important;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.nav-link.active {
  background: #ffffff;
  color: var(--geschool-blue-dark);
  box-shadow: 0 5px 16px rgba(24, 35, 56, 0.08);
}

.btn-logout {
  border-color: #d7e1ec !important;
  color: #475569 !important;
  background: #ffffff !important;
}

.btn-logout:hover {
  border-color: #b6c7da !important;
  background: #f8fbfe !important;
}

.admin-container {
  width: 100%;
  max-width: 1160px !important;
  padding: 28px 24px 56px !important;
}

.admin-container-header {
  margin-bottom: 14px;
}

.back-link {
  width: fit-content;
  padding: 8px 12px;
  border: 1px solid rgba(35, 136, 216, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
}

.admin-main {
  gap: 18px !important;
}

.admin-dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.admin-dashboard-column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
}

.admin-dashboard-primary .admin-card,
.admin-dashboard-secondary .admin-card {
  margin-top: 0 !important;
}

.admin-dashboard-secondary .admin-card {
  padding: 22px !important;
}

.admin-dashboard-secondary .admin-card h2 {
  font-size: 17px !important;
}

.admin-dashboard-secondary .help-text {
  font-size: 12.5px;
}

.admin-dashboard-secondary textarea {
  min-height: 110px;
}

.admin-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border: 1px solid rgba(183, 201, 219, 0.75);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(248,251,254,0.94) 100%);
  box-shadow: 0 22px 60px rgba(24, 35, 56, 0.08);
}

.admin-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  color: #0b57d0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #00ba7c;
  box-shadow: 0 0 0 5px rgba(0, 186, 124, 0.12);
}

.admin-hero h1 {
  margin: 0;
  color: #172033;
  font-family: var(--font-family-title);
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.admin-hero p {
  max-width: 660px;
  margin-top: 10px;
  color: #5d6f84;
  font-size: 14px;
  line-height: 1.55;
}

.admin-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-hero-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.summary-stats-container {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px !important;
  margin-bottom: 0 !important;
}

.summary-badge-card {
  padding: 18px !important;
  border-radius: 14px !important;
  border: 1px solid rgba(202, 213, 226, 0.78) !important;
  box-shadow: 0 12px 28px rgba(24, 35, 56, 0.06) !important;
}

.admin-card {
  border-radius: 16px !important;
  border: 1px solid rgba(202, 213, 226, 0.78) !important;
  box-shadow: 0 16px 44px rgba(24, 35, 56, 0.06) !important;
  padding: 26px !important;
  background: rgba(255, 255, 255, 0.98) !important;
}

.admin-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px !important;
  color: #172033 !important;
  font-size: 19px !important;
  letter-spacing: 0;
}

.admin-card h2::before {
  content: "";
  width: 4px;
  height: 19px;
  border-radius: 999px;
  background: linear-gradient(180deg, #2388d8, #145a9f);
}

.help-text {
  color: #64748b !important;
  line-height: 1.45;
}

.form-group label {
  color: #24324a !important;
  font-size: 13px !important;
  font-weight: 800 !important;
}

.admin-input,
.form-group textarea,
.login-box input {
  border: 1px solid #d7e1ec !important;
  border-radius: 10px !important;
  background: #fbfdff !important;
  color: #172033 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.admin-input:focus,
.form-group textarea:focus,
.login-box input:focus {
  border-color: #2388d8 !important;
  box-shadow: 0 0 0 4px rgba(35, 136, 216, 0.12) !important;
  background: #ffffff !important;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border-radius: 10px !important;
  min-height: 40px;
  font-weight: 800 !important;
  box-shadow: 0 8px 18px rgba(24, 35, 56, 0.08);
}

.btn-primary {
  background: linear-gradient(135deg, #2388d8, #0b57d0) !important;
  border: 1px solid rgba(11, 87, 208, 0.35) !important;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1769c2, #0a4db8) !important;
}

.btn-secondary {
  background: #ffffff !important;
  border-color: #d7e1ec !important;
}

.btn-secondary:hover {
  background: #f3f7fb !important;
}

.btn-danger {
  border: 1px solid #fecaca !important;
  background: #fff1f2 !important;
}

.key-row,
.api-status-item {
  border-radius: 12px !important;
  border-color: rgba(202, 213, 226, 0.78) !important;
  background: #fbfdff !important;
}

#system-activity-logs,
#shadow-patterns-list,
  #shadow-events-list {
  border-radius: 12px !important;
  border-color: rgba(202, 213, 226, 0.78) !important;
  background: #f8fbfe !important;
}

#shadow-guard-card > div[style*="grid-template-columns:repeat(auto-fit,minmax(150px,1fr))"] > div {
  border-radius: 12px !important;
  background: #ffffff !important;
  box-shadow: 0 8px 18px rgba(24, 35, 56, 0.04);
}

#shadow-guard-card details {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff;
}

#shadow-guard-card details[open] {
  background: #fbfdff;
}

.provider-badge {
  border-radius: 999px !important;
  background: #ffffff !important;
  box-shadow: 0 7px 18px rgba(24, 35, 56, 0.05);
}

.login-overlay {
  background:
    radial-gradient(circle at top, rgba(35, 136, 216, 0.16), transparent 30rem),
    rgba(247, 250, 255, 0.90) !important;
}

.login-box {
  max-width: 380px !important;
  border-radius: 18px !important;
  box-shadow: 0 24px 70px rgba(24, 35, 56, 0.16) !important;
}

@media (max-width: 860px) {
  .admin-navbar {
    padding: 0 16px;
    gap: 10px;
  }

  .navbar-left {
    min-width: auto;
  }

  .navbar-brand {
    display: none;
  }

  .navbar-center {
    gap: 4px;
    margin-left: auto;
  }

  .nav-link {
    padding: 0 10px;
    font-size: 12px;
  }

  .navbar-right {
    display: none;
  }

  .admin-container {
    padding: 18px 14px 36px !important;
  }

  .admin-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 22px;
  }

  .admin-hero h1 {
    font-size: 24px;
  }

  .admin-hero-actions {
    justify-content: flex-start;
  }

  .summary-stats-container {
    grid-template-columns: 1fr !important;
  }

  .admin-card {
    padding: 20px !important;
  }

  .admin-dashboard-shell {
    grid-template-columns: 1fr;
  }

  .admin-dashboard-secondary {
    order: 2;
  }

  .admin-dashboard-primary {
    order: 1;
  }
}

/* ============================================================ */
/* Admin App Shell: Sidebar + Per-Page Dashboard                 */
/* ============================================================ */
.has-admin-shell .admin-container {
  max-width: none !important;
  padding: 0 !important;
}

.admin-app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  width: min(1500px, calc(100% - 48px));
  max-width: 100%;
  margin: 0 auto;
  padding: 24px 0 40px;
}

.admin-workspace {
  min-width: 0;
  max-width: 100%;
}

.admin-app-shell > * {
  min-width: 0;
}

.admin-sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 116px);
  min-width: 0;
  max-width: 100%;
}

.admin-sidebar-card,
.admin-sidebar-note {
  border: 1px solid rgba(202, 213, 226, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 44px rgba(24, 35, 56, 0.07);
}

.admin-sidebar-card {
  padding: 18px;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-sidebar-brand strong {
  display: block;
  color: #172033;
  font-size: 15px;
  letter-spacing: 0;
}

.admin-sidebar-brand span,
.admin-sidebar-note span {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}

.admin-sidebar-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  padding: 7px;
  border: 1px solid #dbe6f1;
  border-radius: 13px;
  background: #fff;
}

.admin-sidebar-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
}

.admin-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #00ba7c;
  box-shadow: 0 0 0 5px rgba(0, 186, 124, 0.13);
}

.admin-side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  border: 1px solid rgba(202, 213, 226, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 16px 44px rgba(24, 35, 56, 0.07);
}

.admin-side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.admin-side-link:hover {
  border-color: #dbe6f1;
  background: #f8fbfe;
  color: #172033;
}

.admin-side-link.is-active {
  border-color: rgba(35, 136, 216, 0.28);
  background: linear-gradient(135deg, rgba(35, 136, 216, 0.12), rgba(11, 87, 208, 0.08));
  color: #0b57d0;
}

.admin-side-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 9px;
  background: #eef6ff;
  color: #145a9f;
  font-size: 11px;
  font-weight: 900;
}

.admin-side-link.is-active .admin-side-icon {
  background: #0b57d0;
  color: #fff;
}

.admin-sidebar-note {
  margin-top: auto;
  padding: 14px;
}

.admin-sidebar-note strong {
  color: #24324a;
  font-size: 13px;
}

.has-admin-shell .admin-container-header {
  display: none;
}

.admin-page-titlebar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid rgba(202, 213, 226, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 44px rgba(24, 35, 56, 0.07);
}

.admin-page-titlebar.is-overview {
  display: none;
}

.admin-page-kicker {
  color: #0b57d0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-page-titlebar h1 {
  margin: 6px 0 0;
  color: #172033;
  font-family: var(--font-family-title);
  font-size: 26px;
  line-height: 1.18;
  letter-spacing: 0;
}

.admin-page-titlebar p {
  max-width: 680px;
  margin: 8px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
}

.admin-page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-page-actions a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.admin-page-section {
  display: none !important;
}

.admin-page-section.is-active {
  display: flex !important;
}

.admin-card.admin-page-section.is-active {
  display: block !important;
}

.summary-stats-container.admin-page-section.is-active {
  display: grid !important;
}

.admin-insights-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.admin-insights-grid.is-active,
.monitoring-command-grid.is-active {
  display: grid !important;
}

.admin-metric-card,
.admin-wide-card,
.monitor-card {
  min-width: 0;
  border: 1px solid rgba(202, 213, 226, 0.82);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 44px rgba(24, 35, 56, 0.06);
}

.admin-metric-card {
  display: flex;
  min-height: 178px;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.admin-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.admin-metric-top small,
.admin-panel-heading small {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 800;
}

.admin-metric-card > strong {
  color: #172033;
  font-family: var(--font-family-title);
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.admin-metric-card p {
  margin: auto 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

.admin-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9f1f8;
}

.admin-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #0b57d0);
  transition: width 0.25s ease;
}

.admin-mini-chart {
  min-height: 78px;
  margin-top: auto;
}

.admin-wide-card {
  padding: 22px;
}

.admin-usage-card {
  grid-column: span 2;
}

.admin-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-panel-heading span {
  display: block;
  margin-bottom: 4px;
  color: #0b57d0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-panel-heading h3 {
  margin: 0;
  color: #172033;
  font-family: var(--font-family-title);
  font-size: 19px;
  line-height: 1.2;
}

.admin-chart-wrap {
  min-height: 132px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(248, 251, 254, 0.72), rgba(255, 255, 255, 0.9)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(203, 213, 225, 0.52) 32px);
}

.admin-chart-wrap.tall {
  min-height: 220px;
}

.admin-line-chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.provider-mix-list {
  display: grid;
  gap: 14px;
}

.provider-mix-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.provider-mix-row strong {
  display: block;
  color: #24324a;
  font-size: 13px;
}

.provider-mix-row span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
}

.provider-stack {
  display: flex;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.provider-stack span {
  min-width: 0;
}

.stack-ok { background: #16a34a; }
.stack-limited { background: #f59e0b; }
.stack-error { background: #ef4444; }
.stack-idle { background: #cbd5e1; }

.monitoring-command-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 16px;
  align-items: stretch;
}

.monitor-card {
  padding: 22px;
}

.monitor-card-large {
  grid-row: span 2;
}

.provider-donut-wrap {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-height: 150px;
}

.provider-donut {
  position: relative;
  display: grid;
  width: 128px;
  height: 128px;
  place-items: center;
  border-radius: 999px;
}

.provider-donut::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: inherit;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e2e8f0;
}

.provider-donut span {
  position: relative;
  z-index: 1;
  color: #172033;
  font-family: var(--font-family-title);
  font-size: 24px;
  font-weight: 900;
}

.provider-donut-legend,
.chart-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.provider-donut-legend {
  flex-direction: column;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 999px;
}

.legend-dot.blue { background: #2563eb; }
.legend-dot.green { background: #16a34a; }
.legend-dot.yellow { background: #f59e0b; }
.legend-dot.red { background: #ef4444; }

.chart-legend-row {
  margin-top: 12px;
}

.monitor-timeline {
  display: grid;
  gap: 10px;
}

.monitor-timeline-item {
  position: relative;
  padding: 10px 12px 10px 34px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fbfdff;
}

.monitor-timeline-item::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 13px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.monitor-timeline-item.warn::before {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12);
}

.monitor-timeline-item.danger::before {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

.monitor-timeline-item span {
  display: block;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
}

.monitor-timeline-item p {
  margin: 3px 0 0;
  color: #334155;
  font-size: 12.5px;
  line-height: 1.45;
}

.monitor-empty {
  padding: 20px;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.token-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.token-metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid #dbe7f5;
  border-radius: 14px;
  background: #f8fbff;
}

.token-metric span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
}

.token-metric strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 950;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding: 16px 4px 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.admin-footer span:last-child {
  color: #94a3b8;
  font-weight: 600;
}

@media (max-width: 1180px) {
  .admin-app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
    width: min(1180px, calc(100% - 32px));
    gap: 16px;
  }

  .admin-sidebar {
    top: 84px;
  }

  .admin-insights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-usage-card {
    grid-column: span 1;
  }
}

@media (max-width: 980px) {
  .admin-app-shell {
    grid-template-columns: 1fr;
    width: calc(100% - 24px);
    padding-top: 16px;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    width: 100%;
    overflow: hidden;
  }

  .admin-sidebar-card {
    display: none;
  }

  .admin-side-nav {
    position: sticky;
    top: 78px;
    z-index: 40;
    flex-direction: row;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    border-radius: 16px;
    scrollbar-width: none;
  }

  .admin-side-nav::-webkit-scrollbar {
    display: none;
  }

  .admin-side-link {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    white-space: nowrap;
  }

  .admin-sidebar-note {
    display: none;
  }

  .monitoring-command-grid {
    grid-template-columns: 1fr;
  }

  .monitor-card-large {
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .admin-app-shell {
    width: calc(100% - 20px);
    padding-bottom: 28px;
  }

  .admin-page-titlebar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .admin-page-titlebar h1 {
    font-size: 22px;
  }

  .admin-page-actions {
    justify-content: flex-start;
  }

  .admin-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-insights-grid {
    grid-template-columns: 1fr;
  }

  .provider-mix-row,
  .provider-donut-wrap {
    grid-template-columns: 1fr;
  }

  .provider-donut {
    width: 112px;
    height: 112px;
  }

  .admin-panel-heading {
    flex-direction: column;
  }

  .token-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
