/* ===== ETS V10.0 Modern Theme — Dark (default) ===== */
:root {
  --bg-primary: #1E2328;
  --bg-secondary: #161A1F;
  --bg-tertiary: #2A3038;
  --bg-hover: #323A44;
  --bg-active: #3A4350;

  --text-primary: #FFFFFF;
  --text-secondary: #C7C7C7;
  --text-tertiary: #B3B3B3;
  --text-muted: #7E7E7E;

  --accent-primary: #C79837;
  --accent-secondary: #EFCA46;
  --accent-gradient: linear-gradient(135deg, #C79837 0%, #D4A84B 50%, #EFCA46 100%);

  --border-subtle: #1A1E24;
  --border-light: #3A4350;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  --sidebar-width: 320px;
  --header-height: 64px;

  --header-backdrop: rgba(22, 26, 31, 0.85);
  --logo-bg: #1a1a2e;

  /* Legacy variable mappings */
  --bg: var(--bg-primary);
  --bg-white: var(--bg-secondary);
  --bg-2: var(--bg-secondary);
  --bg-3: var(--bg-tertiary);
  --bg-4: var(--bg-active);
  --bg-input: var(--bg-secondary);
  --accent: var(--accent-primary);
  --accent-hover: #9E855C;
  --accent-light: rgba(199, 152, 55, 0.12);
  --accent-2: var(--accent-secondary);
  --fg: var(--text-primary);
  --fg-gray: var(--text-secondary);
  --fg-dark: var(--text-primary);
  --fg-inverse: #ffffff;
  --muted: var(--text-muted);
  --muted-2: var(--text-tertiary);
  --text-dark: var(--text-primary);
  --text-gray: var(--text-secondary);
  --charcoal: var(--bg-tertiary);
  --bg-black: var(--bg-secondary);
  --border: var(--border-subtle);
  --border-accent: rgba(199, 152, 55, 0.25);
  --shadow: rgba(0, 0, 0, 0.4);

  /* SQL block */
  --sql-bg: #0D1117;
  --sql-border: #30363D;

  /* Status colours */
  --color-success: #3FB950;
  --color-error:   #F85149;
  --color-warn:    #D29922;
}

/* ===== ETS V10.0 Modern Theme — Light ===== */
[data-theme="light"] {
  --bg-primary: #FFFFFF;
  --bg-secondary: #F5F5F5;
  --bg-tertiary: #EFF0F1;
  --bg-hover: #E5E7EA;
  --bg-active: #CED5D9;

  --text-primary: #1A1A1A;
  --text-secondary: #474747;
  --text-tertiary: #6B7280;
  --text-muted: #9CA3AF;

  --accent-primary: #C79837;
  --accent-secondary: #9E855C;
  --accent-gradient: linear-gradient(135deg, #C79837 0%, #B08930 50%, #9E855C 100%);

  --border-subtle: #E5E7EB;
  --border-light: #D1D5DB;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.16);

  --header-backdrop: rgba(255, 255, 255, 0.85);
  --logo-bg: #ffffff;

  --accent-hover: #B08930;
  --accent-light: rgba(199, 152, 55, 0.10);
  --fg-inverse: #ffffff;
  --border-accent: rgba(199, 152, 55, 0.20);
  --shadow: rgba(0, 0, 0, 0.12);

  --sql-bg:     #F6F8FA;
  --sql-border: #D0D7DE;
}

/* Light mode element overrides */
[data-theme="light"] .kb-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23474747' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="light"] .skeleton {
  background: linear-gradient(90deg,
    rgba(0, 0, 0, 0.04) 25%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 75%
  );
  background-size: 200% 100%;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

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

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

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

/* ===== Layout ===== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-normal), transform var(--transition-normal), min-width var(--transition-normal);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-icon img {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--logo-bg);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.new-chat-btn {
  margin: 16px;
  padding: 14px 20px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: white;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.new-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.new-chat-btn svg {
  flex-shrink: 0;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-section {
  margin-bottom: 16px;
}

.history-label {
  display: block;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.history-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

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

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--logo-bg);
}

.user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.user-name {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.user-plan {
  display: block;
  font-size: 0.75rem;
  color: var(--accent-secondary);
}

/* ===== Main Chat Area ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

.chat-header-bar {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--header-backdrop);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.menu-toggle {
  display: flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  transition: all var(--transition-fast);
  background: none;
  border: none;
  cursor: pointer;
}

.menu-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent-secondary);
}

.header-brand {
  font-size: 1.125rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Knowledge Base Switcher */
.kb-switcher {
  margin-left: auto;
}

#preset-select {
  margin-left: auto;
}

.kb-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 32px 8px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c7c7c7' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.logout-btn {
  margin-left: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logout-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  margin-left: 8px;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Dark mode (default): show sun icon, hide moon */
.theme-icon-moon { display: none; }
.theme-icon-sun  { display: block; }

/* Light mode: show moon icon, hide sun */
[data-theme="light"] .theme-icon-sun  { display: none; }
[data-theme="light"] .theme-icon-moon { display: block; }

.kb-select:hover {
  border-color: var(--accent-primary);
  background-color: var(--bg-hover);
}

.kb-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(199, 152, 55, 0.2);
}

.kb-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Desktop sidebar collapse */
.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
  padding: 0;
}

/* ===== Chat Screen ===== */
.chat-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.chat {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 24px 24px 24px 24px;
  width: 100%;
}

.chat > * {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Welcome Message ===== */
.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.6s ease;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.welcome-icon img {
  width: 80px;
  height: 80px;
  max-width: 80px;
  max-height: 80px;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  border-radius: var(--radius-md);
  background: var(--logo-bg);
}

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

.welcome-message h2 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-message p {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin: 0 0 32px 0;
  line-height: 1.6;
}

/* ===== Input Area ===== */
.input-area {
  padding: 12px 24px 8px;
  background: linear-gradient(to top, var(--bg-primary) 0%, transparent 100%);
  flex-shrink: 0;
}

.input-container {
  max-width: 900px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
}

.input-wrapper input,
#query-input {
  flex: 1;
  background: transparent;
  color: var(--text-primary);
  border: 0;
  outline: none;
  font-size: 0.9375rem;
  padding: 12px 8px;
  font-family: inherit;
  line-height: 1.5;
}

.input-wrapper input::placeholder,
#query-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  cursor: pointer;
}

.send-btn:hover {
  transform: scale(1.05);
}

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

/* Stop button (replaces send during processing) */
.stop-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  cursor: pointer;
}

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

.stop-btn .stop-icon {
  width: 14px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 2px;
}

.input-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 0;
}

.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 0;
}

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

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* ===== Messages ===== */
.msg {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  animation: fadeIn 0.3s ease-in;
}

.msg-user {
  justify-content: flex-end;
}

.msg .bubble {
  max-width: 720px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  white-space: pre-line;
  word-wrap: break-word;
  line-height: 1.7;
  font-size: 0.9375rem;
}

.msg-user .bubble {
  background: var(--bg-active);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 20px 20px 4px 20px;
  padding: 16px 20px;
  font-size: 0.9375rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.msg-assistant .title {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* ===== Message Container Styles ===== */
.message-container {
  margin: 24px 0;
  max-width: 900px;
  animation: slideInUp 0.4s ease-out;
}

.user-message-container {
  margin-left: auto;
  margin-right: auto;
}

.assistant-message-container {
  margin-left: auto;
  margin-right: auto;
  position: relative;
}

.message-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
}

.message-label strong {
  font-weight: 600;
  color: var(--accent-primary);
}

/* User message bubble */
.user-bubble {
  background: var(--bg-active);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 16px 16px 4px 16px;
  padding: 16px 20px;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

/* Editable user bubble (after stop) */
.user-bubble.editable {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(199, 152, 55, 0.2);
  outline: none;
  cursor: text;
}

.user-bubble.editable:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(199, 152, 55, 0.25);
}

.edit-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
  animation: fadeIn 0.2s ease;
}

/* Answer card */
.answer-card {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px 16px 16px 4px;
  padding: 20px 24px;
  font-size: 0.9375rem;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Inline Assistant Message Style */
.assistant-inline {
  background: transparent;
  border: none;
  box-shadow: none;
}

.assistant-content {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
  word-wrap: break-word;
  padding-right: 10px;
}

.assistant-content .assistant-label {
  display: inline;
  margin-right: 4px;
}

.assistant-content .assistant-text {
  display: inline;
}

.assistant-text > p.md-para:first-child {
  display: inline;
}

.assistant-label {
  color: var(--accent-primary);
  font-weight: 600;
}

.assistant-text {
  color: var(--text-secondary);
}

.assistant-text h1,
.assistant-text h2,
.assistant-text h3,
.assistant-text h4 {
  margin: 16px 0 8px 0;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.assistant-text h1:first-child,
.assistant-text h2:first-child,
.assistant-text h3:first-child,
.assistant-text h4:first-child {
  margin-top: 0;
}

.assistant-text h4 {
  font-size: 15px;
}

.assistant-text a,
.answer-card a,
.bubble a {
  color: var(--accent-secondary);
  text-decoration: none;
}

.assistant-text a:hover,
.answer-card a:hover,
.bubble a:hover {
  color: #EFCA46;
  text-decoration: underline;
}

.assistant-text strong {
  font-weight: 600;
  color: var(--text-primary);
}

.assistant-text code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.875em;
  color: var(--accent-secondary);
  border: 1px solid var(--border-light);
}

.assistant-text a {
  color: var(--accent-secondary);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 101, 0.3);
}

/* ===== Processing / Tool Indicators ===== */
.processing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  animation: slideIn 0.3s ease-out;
}

.processing-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.processing strong {
  color: var(--accent-secondary);
  font-weight: 600;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(199, 152, 55, 0.3);
  border-top-color: var(--accent-primary);
  animation: spin 0.8s linear infinite;
}

/* Tool Card Styles */
.tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin: 16px auto 16px 0;
  max-width: 720px;
  animation: slideInUp 0.4s ease-out;
}

.tool-card-header {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.tool-card-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.tool-card.tool-error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
}

.tool-card.tool-error .tool-card-header {
  color: #f87171;
}

.tool-card.tool-error .tool-card-content {
  color: #fca5a5;
}

/* Tool Processing indicator */
.tool-processing {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px auto 4px 0;
  padding: 4px 0;
  max-width: 720px;
  text-align: left;
  animation: fadeIn 0.3s ease-in;
}

.tool-processing-name {
  font-weight: 500;
  color: var(--text-primary);
}

.tool-processing-dots::after {
  content: '';
  animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
  100% { content: '.'; }
}

.tool-status-icon {
  margin-right: 8px;
  font-weight: 600;
}

.tool-processing.tool-completed {
  color: var(--accent-primary);
}

.tool-processing.tool-completed .tool-status-icon {
  color: var(--accent-primary);
}

.tool-processing.tool-completed .tool-processing-name {
  color: var(--accent-primary);
}

.tool-progress-text {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
  transition: opacity 0.2s ease;
}

/* Dynamic Tool Category Colors */

/* Search */
.tool-processing.tool-search {
  background: rgba(199, 152, 55, 0.06);
  border: 1px solid rgba(199, 152, 55, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-search .tool-processing-name {
  color: var(--accent-primary);
}

.tool-processing.tool-search.tool-completed .tool-status-icon,
.tool-processing.tool-search.tool-completed .tool-processing-name {
  color: var(--accent-primary);
}

/* Validation */
.tool-processing.tool-validation {
  background: rgba(13, 148, 136, 0.06);
  border: 1px solid rgba(13, 148, 136, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-validation .tool-processing-name {
  color: #0d9488;
}

.tool-processing.tool-validation.tool-completed .tool-status-icon,
.tool-processing.tool-validation.tool-completed .tool-processing-name {
  color: #0f766e;
}

/* Extraction */
.tool-processing.tool-extraction {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-extraction .tool-processing-name {
  color: #059669;
}

.tool-processing.tool-extraction.tool-completed .tool-status-icon,
.tool-processing.tool-extraction.tool-completed .tool-processing-name {
  color: #047857;
}

/* Analysis */
.tool-processing.tool-analysis {
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-analysis .tool-processing-name {
  color: var(--text-tertiary);
}

.tool-processing.tool-analysis.tool-completed .tool-status-icon,
.tool-processing.tool-analysis.tool-completed .tool-processing-name {
  color: var(--text-secondary);
}

/* Database */
.tool-processing.tool-database {
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-database .tool-processing-name {
  color: #818cf8;
}

.tool-processing.tool-database.tool-completed .tool-status-icon,
.tool-processing.tool-database.tool-completed .tool-processing-name {
  color: #6366f1;
}

/* Report */
.tool-processing.tool-report {
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-report .tool-processing-name {
  color: #38bdf8;
}

.tool-processing.tool-report.tool-completed .tool-status-icon,
.tool-processing.tool-report.tool-completed .tool-processing-name {
  color: #0ea5e9;
}

/* Default */
.tool-processing.tool-default {
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 4px 0;
}

.tool-processing.tool-default .tool-processing-name {
  color: var(--text-tertiary);
}

.tool-processing.tool-default.tool-completed .tool-status-icon,
.tool-processing.tool-default.tool-completed .tool-processing-name {
  color: var(--text-secondary);
}

.tool-processing.tool-error-inline {
  color: #ef4444;
}

.tool-processing.tool-error-inline .tool-status-icon {
  color: #ef4444;
}

.tool-processing.tool-error-inline .tool-processing-name {
  color: #ef4444;
}

.tool-processing.tool-confirmation {
  color: #b45309;
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  animation: confirmPulse 2s ease-in-out infinite;
}

.tool-processing.tool-confirmation .tool-status-icon {
  color: #d97706;
}

.tool-processing.tool-confirmation .tool-processing-name {
  color: #b45309;
}

@keyframes confirmPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(217, 119, 6, 0); }
}

.confirmation-waiting-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 12px auto 12px 0;
  max-width: 720px;
  background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius-md);
  color: #b45309;
  font-size: 14px;
  font-weight: 500;
  animation: confirmPulse 2s ease-in-out infinite;
}

.confirmation-waiting-indicator svg {
  flex-shrink: 0;
  animation: spin 2s linear infinite;
}

.input-highlight {
  animation: inputPulse 1.5s ease-in-out infinite;
}

@keyframes inputPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.15); }
}

/* Tool Expandable */
.tool-expandable {
  background: rgba(199, 152, 55, 0.04);
  border: 1px solid rgba(199, 152, 55, 0.12);
  border-radius: var(--radius-sm);
  padding: 0;
  margin: 8px auto 8px 0;
  max-width: 720px;
}

.tool-expandable .tool-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.tool-expandable .tool-header:hover {
  background: rgba(199, 152, 55, 0.08);
}

.tool-expand-icon {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.tool-expand-icon.expanded {
  transform: rotate(0deg);
}

.tool-content-panel {
  border-top: 1px solid var(--border-subtle);
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 0 0 8px 8px;
  max-height: 500px;
  overflow-y: auto;
}

.tool-content-inner {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.tool-content-inner h2, .tool-content-inner h3 {
  color: var(--accent-primary);
  margin: 16px 0 8px 0;
  font-size: 15px;
}

.tool-content-inner h2:first-child, .tool-content-inner h3:first-child {
  margin-top: 0;
}

.tool-content-inner table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}

.tool-content-inner th, .tool-content-inner td {
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.tool-content-inner th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
}

.tool-content-inner td {
  background: var(--bg-secondary);
}

.tool-content-inner ul, .tool-content-inner ol {
  margin: 8px 0;
  padding-left: 20px;
}

.tool-content-inner li {
  margin: 4px 0;
}

/* ===== Markdown Tables ===== */
.md-table-wrapper {
  overflow-x: auto;
  margin: 8px 0 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.md-table a {
  color: var(--accent-secondary);
  text-decoration: none;
}

.md-table a:hover {
  color: #EFCA46;
  text-decoration: underline;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.md-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
}

.md-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

.md-table tr:hover {
  background: var(--bg-hover);
}

/* ===== Copy Button ===== */
.copy-btn {
  position: absolute;
  top: 8px;
  right: -40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.msg:hover .copy-btn,
.answer-wrapper:hover .copy-btn,
.assistant-inline:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
  transform: scale(1.05);
}

.copy-btn:active {
  transform: scale(0.95);
}

.copy-btn.copied {
  background: rgba(199, 152, 55, 0.15);
  border-color: rgba(199, 152, 55, 0.35);
  color: var(--accent-primary);
}

/* ===== Message Timestamps ===== */
.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0;
  margin-top: 4px;
  transition: opacity 0.2s ease;
  text-align: right;
}

.msg:hover .message-timestamp,
.answer-wrapper:hover .message-timestamp,
.assistant-inline:hover .message-timestamp {
  opacity: 0.7;
}

.answer-wrapper {
  position: relative;
  margin: 24px 0;
}

/* ===== Scroll to Bottom ===== */
.scroll-to-bottom {
  position: fixed;
  bottom: 140px;
  right: 40px;
  width: 48px;
  height: 48px;
  background: var(--accent-primary);
  border: 1px solid rgba(199, 152, 55, 0.2);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(199, 152, 55, 0.3);
  transition: all 0.3s ease;
  z-index: 99;
}

.scroll-to-bottom:hover {
  background: var(--accent-hover);
  transform: translateY(-3px);
  box-shadow: 0 6px 25px rgba(199, 152, 55, 0.4);
}

.scroll-to-bottom:active {
  transform: translateY(-1px);
}

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

/* ===== Code & Pre Formatting ===== */
.answer-card code,
.bubble code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.875em;
  color: var(--accent-secondary);
  border: 1px solid var(--border-light);
}

.answer-card pre,
.bubble pre {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.answer-card pre code,
.bubble pre code {
  background: none;
  padding: 0;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.answer-card ul,
.answer-card ol,
.bubble ul,
.bubble ol {
  margin: 10px 0 10px 1.25rem;
  padding-left: 1.1rem;
  list-style-position: outside;
}

.answer-card li,
.bubble li {
  margin: 6px 0;
  line-height: 1.6;
}

.assistant-text ul,
.assistant-text ol {
  margin: 10px 0 10px 1.25rem;
  padding-left: 1.1rem;
  list-style-position: outside;
}

.assistant-text li {
  margin: 6px 0;
  line-height: 1.6;
}

.answer-card ul {
  list-style-type: disc;
}

.answer-card ol {
  list-style-type: decimal;
}

.answer-card a,
.bubble a {
  color: var(--accent-secondary);
  text-decoration: underline;
  text-decoration-color: rgba(255, 138, 101, 0.3);
  transition: all 0.2s ease;
}

.answer-card a:hover,
.bubble a:hover {
  color: #EFCA46;
  text-decoration-color: rgba(239, 202, 70, 0.6);
}

.answer-card h1,
.answer-card h2,
.answer-card h3,
.answer-card h4,
.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
  margin: 8px 0 4px 0;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.answer-card h1:first-child,
.answer-card h2:first-child,
.answer-card h3:first-child,
.answer-card h4:first-child,
.bubble h1:first-child,
.bubble h2:first-child,
.bubble h3:first-child,
.bubble h4:first-child {
  margin-top: 0;
}

.answer-card p,
.bubble p,
.assistant-text p {
  margin: 2px 0;
}

.md-para {
  display: block;
  margin: 8px 0;
}

.md-para:first-child {
  margin-top: 0;
}

.md-para:last-child {
  margin-bottom: 0;
}

.md-para:empty {
  display: none;
}

.answer-card h1,
.bubble h1 {
  font-size: 20px;
}

.answer-card h2,
.bubble h2 {
  font-size: 18px;
}

.answer-card h3,
.bubble h3 {
  font-size: 16px;
}

.answer-card h4,
.bubble h4 {
  font-size: 15px;
}

.answer-card strong,
.bubble strong {
  font-weight: 600;
  color: var(--text-primary);
}

.answer-card em,
.bubble em {
  font-style: italic;
  color: var(--accent-secondary);
}

/* ===== Skeleton Loading ===== */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 16px;
  margin: 8px 0;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 95%; }

/* ===== Results ===== */
.result {
  margin: 16px 0;
  padding: 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.result .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.result .sql-btn {
  margin-left: auto;
  background: rgba(199, 152, 55, 0.1);
  border: 1px solid rgba(199, 152, 55, 0.2);
  color: var(--accent-primary);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
}

.result .sql-btn:hover {
  background: rgba(199, 152, 55, 0.15);
  border-color: rgba(199, 152, 55, 0.3);
}

.result .viz { margin: 14px 0; }
.result .table { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); }
.result table { border-collapse: collapse; width: 100%; font-size: 14px; }

.result th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  color: var(--text-primary);
}

.result td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.result tr:last-child td { border-bottom: none; }
.result tr:hover { background: var(--bg-hover); }

.pill {
  display: inline-block;
  background: rgba(199, 152, 55, 0.1);
  color: var(--accent-primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(199, 152, 55, 0.2);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal[hidden] { display: none; }

.modal-content {
  width: min(850px, calc(100% - 40px));
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal .close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.modal pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Simple bar chart */
.bar {
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
  font-size: 14px;
}

.bar .track {
  height: 14px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  position: relative;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.bar .fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 7px;
  box-shadow: 0 0 10px rgba(199, 152, 55, 0.3);
  transition: width 0.3s ease;
}

/* ===== Chart container ===== */
.chart-container {
  margin: 16px 0;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.chart-container canvas {
  max-width: 100%;
  height: auto !important;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-secondary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ===== Image display ===== */
.image-container {
  margin: 16px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.image-container img {
  width: 100%;
  height: auto;
  display: block;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.image-grid-item {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.image-grid-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 20px rgba(199, 152, 55, 0.2);
}

.image-grid-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

/* Enhanced image section styles */
.image-section-header {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.reference-images-grid {
  margin-top: 16px;
  animation: slideInUp 0.4s ease-out;
}

.reference-image-wrapper {
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  min-height: 200px;
  position: relative;
}

.reference-image-wrapper:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(199, 152, 55, 0.2);
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 32px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  animation: slideInUp 0.6s ease-out;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.3s ease;
}

.feature-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}

.feature-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.feature-text {
  font-size: 14px;
  line-height: 1.4;
}

.feature-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

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

/* Enhanced modal styles */
.image-modal-content {
  max-width: 95vw;
  max-height: 95vh;
  padding: 0;
  overflow: hidden;
}

.image-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--bg-tertiary);
}

.image-modal-body {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

/* ===== Drag and Drop Zone ===== */
#drop-zone {
  position: fixed;
  inset: 0;
  background: var(--header-backdrop);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.drop-zone-content {
  text-align: center;
  padding: 60px;
  border: 3px dashed var(--accent-primary);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(199, 152, 55, 0.1) 0%, rgba(199, 152, 55, 0.05) 100%);
  animation: pulse 2s ease-in-out infinite;
}

.drop-zone-content svg {
  color: var(--accent-primary);
  margin-bottom: 20px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(199, 152, 55, 0.2); }
  50% { box-shadow: 0 0 0 20px rgba(199, 152, 55, 0); }
}

.drop-zone-text {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.drop-zone-subtext {
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== Upload Progress ===== */
.upload-progress-container {
  background: linear-gradient(135deg, rgba(199, 152, 55, 0.1) 0%, rgba(199, 152, 55, 0.05) 100%);
  border: 1px solid rgba(199, 152, 55, 0.25);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin: 16px 0;
  transition: all 0.3s ease;
  animation: slideIn 0.3s ease-out;
}

.upload-progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
}

.upload-progress-header svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.upload-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.upload-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(199, 152, 55, 0.4);
}

.upload-progress-text {
  text-align: right;
  font-size: 13px;
  color: var(--accent-secondary);
  font-weight: 600;
}

/* ===== Upload Screen Styles ===== */
.upload-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.upload-container {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.upload-icon {
  color: var(--accent-primary);
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

.upload-logo {
  margin-bottom: 24px;
  animation: float 3s ease-in-out infinite;
}

.ets-logo {
  height: 64px;
  width: auto;
  transition: opacity 0.3s ease;
}

.ets-logo:not([src]), .ets-logo[src=""] { display: none; }
.chat-logo:not([src]), .chat-logo[src=""] { display: none; }

.upload-title {
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 8px 0;
}

.upload-subtitle {
  color: var(--text-muted);
  font-size: 16px;
  margin: 0 0 40px 0;
}

.upload-dropzone {
  background: var(--bg-secondary);
  border: 2px dashed rgba(199, 152, 55, 0.3);
  border-radius: 20px;
  padding: 48px 32px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, rgba(199, 152, 55, 0.08) 0%, rgba(199, 152, 55, 0.03) 100%);
  transform: scale(1.02);
}

.dropzone-content { pointer-events: none; }

.dropzone-icon {
  color: var(--accent-primary);
  margin-bottom: 20px;
}

.dropzone-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.dropzone-subtext {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 16px 0;
}

.browse-btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.3s ease;
  box-shadow: 0 4px 16px rgba(199, 152, 55, 0.3);
}

.browse-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(199, 152, 55, 0.4);
}

.dropzone-formats {
  color: var(--text-muted);
  font-size: 13px;
  margin: 16px 0 0 0;
  opacity: 0.7;
}

.upload-progress {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

.progress-filename {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80%;
}

.progress-percent {
  color: var(--accent-secondary);
  font-weight: 600;
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(199, 152, 55, 0.4);
}

.upload-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 20px;
  animation: slideIn 0.3s ease-out;
}

.success-icon {
  color: #34D399;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-text {
  color: #34D399;
  font-size: 16px;
  font-weight: 600;
}

/* ===== Chat Header (old one, now replaced by chat-header-bar) ===== */
.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.chat-brand {
  font-size: 24px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chat-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg-secondary);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.chat-file-info svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.new-session-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.new-session-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.new-session-btn svg {
  transition: transform 0.3s ease;
}

.new-session-btn:hover svg {
  transform: rotate(180deg);
}

/* ===== Todos Panel ===== */
.todos-panel {
  position: fixed;
  top: 70px;
  right: 20px;
  width: 280px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.todos-panel.hiding {
  opacity: 0;
  transform: translateX(20px);
}

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

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

.todos-count {
  font-size: 12px;
  color: var(--accent-primary);
  background: rgba(199, 152, 55, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.todos-list {
  padding: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: background 0.15s ease;
}

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

.todo-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-top: 1px;
}

.todo-content {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.todo-pending .todo-icon { color: var(--text-muted); }
.todo-pending .todo-content { color: var(--text-muted); }

.todo-in-progress .todo-icon {
  color: var(--accent-primary);
  animation: todoPulse 1.5s ease-in-out infinite;
}

.todo-in-progress .todo-content { color: var(--text-primary); }

.todo-completed .todo-icon { color: #34D399; }

.todo-completed .todo-content {
  color: var(--text-muted);
  text-decoration: line-through;
}

@keyframes todoPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Citations ===== */
.citations-container {
  margin: 16px auto 16px 0;
  max-width: 720px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  animation: slideInUp 0.4s ease-out;
  box-shadow: var(--shadow-sm);
}

.citations-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.2s ease;
  user-select: none;
}

.citations-header:hover {
  background: var(--bg-active);
}

.citations-icon {
  display: flex;
  align-items: center;
  color: var(--accent-primary);
}

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

.citations-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.citations-toggle.rotated {
  transform: rotate(180deg);
}

.citations-list {
  max-height: 500px;
  overflow-y: auto;
  transition: max-height 0.3s ease;
}

.citations-list.collapsed {
  max-height: 0;
  overflow: hidden;
}

.citation-card {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
}

.citation-card:last-child {
  border-bottom: none;
}

.citation-card.citation-clickable {
  cursor: pointer;
}

.citation-card.citation-clickable:hover {
  background: var(--accent-light);
}

.citation-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.citation-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.citation-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.citation-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-score {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.citation-score.score-high {
  background: rgba(52, 211, 153, 0.15);
  color: #34D399;
}

.citation-score.score-medium {
  background: rgba(251, 191, 36, 0.15);
  color: #FBBF24;
}

.citation-score.score-low {
  background: rgba(248, 113, 113, 0.15);
  color: #F87171;
}

.citation-open-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.citation-clickable:hover .citation-open-icon {
  color: var(--accent-primary);
}

/* ===== Model Thinking Indicator ===== */
.model-thinking {
  margin: 4px auto 4px 0;
  padding: 2px 0;
  max-width: 720px;
  animation: fadeIn 0.3s ease-in;
}

.model-thinking-icon {
  display: none;
}

.model-thinking-text {
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== Error bubble ===== */
.error-bubble {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  color: #fca5a5;
  font-size: 14px;
}

.error-bubble strong {
  color: #f87171;
}

/* ===== Loading states ===== */
.reference-image-wrapper img {
  transition: opacity 0.3s ease;
}

.reference-image-wrapper img[src=""] {
  opacity: 0;
}

.reference-image-wrapper::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.reference-image-wrapper.loading::before {
  opacity: 1;
}

/* Accessibility */
.reference-image-wrapper:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.modal .close:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ===== Document Viewer Modal ===== */
.doc-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.doc-viewer-modal {
  width: 90vw;
  height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.doc-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.doc-viewer-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}

.doc-viewer-close {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}

.doc-viewer-close:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.doc-viewer-body {
  flex: 1;
  overflow: hidden;
}

.doc-viewer-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-secondary);
}

/* ===== Login modal overlay (LDAP/JWT) ===== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

.login-label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.login-label input {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-primary);
}

.login-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.login-submit {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent-primary);
  color: #ffffff;
  font-weight: 500;
  cursor: pointer;
}

.login-submit:hover {
  background: var(--accent-hover);
}

.login-error {
  margin-top: 8px;
  color: #E23326;
  font-size: 12px;
}

/* ===== Dedicated login screen (full page) ===== */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.login-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}

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

.login-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--logo-bg);
}

.login-title {
  font-size: 1.5rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.login-form .login-label {
  margin-bottom: 16px;
}

.login-form .login-label input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.login-form .login-label input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.login-form .login-error {
  margin-bottom: 12px;
}

.login-form .login-submit {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  font-size: 0.9375rem;
  background: var(--accent-primary);
  color: var(--fg-inverse);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition-fast);
}

.login-form .login-submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.login-form .login-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
}

/* Smooth transitions for all interactive elements */
button, a, .copy-btn {
  -webkit-tap-highlight-color: transparent;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
  }

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

  .chat {
    padding: 16px 16px 16px 16px;
  }

  .msg .bubble {
    max-width: 100%;
    padding: 14px 16px;
    font-size: 14px;
  }

  .answer-card {
    margin: 16px 0;
    padding: 16px;
    font-size: 14px;
  }

  .input-area {
    padding: 12px 16px;
  }

  .input-wrapper {
    padding: 6px 12px 6px 12px;
    border-radius: 20px;
  }

  .input-wrapper input,
  #query-input {
    font-size: 15px;
    padding: 10px 8px;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }

  .scroll-to-bottom {
    bottom: 120px;
    right: 20px;
    width: 44px;
    height: 44px;
  }

  .copy-btn {
    opacity: 1;
  }

  .message-timestamp {
    opacity: 0.7;
    font-size: 10px;
  }

  .welcome-message {
    padding: 40px 16px;
  }

  .welcome-message h2 {
    font-size: 1.5rem;
  }

  .welcome-message p {
    font-size: 0.9375rem;
  }

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

  .citations-container {
    max-width: 100%;
  }

  .chat-header-bar {
    padding: 0 16px;
  }

  .reference-images-grid {
    grid-template-columns: 1fr !important;
  }

  .feature-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature-item {
    padding: 12px;
  }

  .todos-panel {
    position: relative;
    top: 0;
    right: 0;
    width: 100%;
    max-height: 200px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
  }

  .chat-screen.has-todos .chat {
    margin-right: 0;
  }

  .doc-viewer-modal {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .upload-container {
    padding: 20px;
  }

  .upload-title {
    font-size: 28px;
  }

  .upload-subtitle {
    font-size: 14px;
    margin-bottom: 32px;
  }

  .upload-dropzone {
    padding: 32px 20px;
  }

  .dropzone-text {
    font-size: 16px;
  }

  .browse-btn {
    padding: 12px 24px;
    font-size: 14px;
  }
}

/* Improve touch targets on mobile */
@media (hover: none) and (pointer: coarse) {
  .send-btn,
  .copy-btn,
  .scroll-to-bottom {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Adjust chat when todos panel is visible */
.chat-screen.has-todos .chat {
  margin-right: 300px;
}

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

/* ===== Attachment styles ===== */
.attachment-bar {
  max-width: 900px;
  margin: 12px auto 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 13px;
}

.attachment-pill button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}

.attachment-pill button:hover {
  color: var(--text-primary);
}

/* ===== Schema management button ===== */
.schema-mgmt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 4px 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.schema-mgmt-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ===== DB Credentials (inline sidebar section) ===== */
.db-cred-section {
  margin: 4px 12px 14px;
  padding: 12px 14px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.db-cred-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}

.db-cred-load-msg {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.db-cred-field {
  margin-bottom: 10px;
}

.db-cred-field label {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.db-cred-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  opacity: 0.75;
}

.db-cred-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.db-cred-field input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.db-cred-field input::placeholder {
  font-size: 11px;
  color: var(--text-muted);
}

.db-cred-msg {
  font-size: 11.5px;
  margin: 6px 0 0;
}

.db-cred-msg-error { color: #ef4444; }
.db-cred-msg-success { color: #22c55e; }

.db-cred-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.db-cred-btn {
  flex: 1;
  padding: 7px 10px;
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.db-cred-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.db-cred-btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  font-weight: 600;
}
.db-cred-btn-primary:hover {
  opacity: 0.9;
  color: #fff;
}

.db-cred-btn-danger:hover {
  border-color: var(--color-error);
  color: var(--color-error);
}

/* ===== Schema modal overlay ===== */
.schema-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.schema-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.schema-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}
.schema-modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.schema-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.schema-modal-close:hover { background: var(--bg-hover); }
.schema-modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.schema-modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}
.schema-modal-desc code {
  font-family: monospace;
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== Schema upload form ===== */
.schema-upload-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.schema-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.schema-label input[type="text"],
.schema-label textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--transition-fast);
  font-family: inherit;
  resize: vertical;
}
.schema-label input[type="text"]:focus,
.schema-label textarea:focus {
  border-color: var(--accent-primary);
}
.schema-checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  color: var(--text-secondary);
}
.schema-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}
.schema-hint code {
  font-family: monospace;
  background: var(--bg-tertiary);
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 11px;
}
.schema-required { color: #e05252; }
.schema-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.schema-file-btn {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.schema-file-btn:hover { background: var(--bg-hover); }
.schema-file-name {
  font-size: 12px;
  color: var(--text-muted);
}
.schema-upload-error {
  padding: 10px 12px;
  background: rgba(224, 82, 82, 0.12);
  border: 1px solid rgba(224, 82, 82, 0.3);
  border-radius: var(--radius-sm);
  color: #e05252;
  font-size: 13px;
}
.schema-upload-success {
  padding: 10px 12px;
  background: rgba(52, 168, 83, 0.12);
  border: 1px solid rgba(52, 168, 83, 0.3);
  border-radius: var(--radius-sm);
  color: #34a853;
  font-size: 13px;
}
.schema-modal-actions {
  display: flex;
  justify-content: flex-end;
}
.schema-submit-btn {
  padding: 9px 20px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.schema-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.schema-submit-btn:hover:not(:disabled) { opacity: 0.9; }

/* ===== Active schema selector ===== */
.active-schemas-container {
  margin: 4px 12px 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}
.active-schemas-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.active-schema-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.active-schema-row:hover { color: var(--text-primary); }
.active-schema-cb { cursor: pointer; }
.active-schema-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Code block copy button --- */
.code-block-wrapper {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--surface-2, rgba(255,255,255,0.08));
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--text-secondary, #9ca3af);
  padding: 0;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: var(--surface-3, rgba(255,255,255,0.14));
  color: var(--text-primary, #f3f4f6);
}

.code-copy-btn.copied {
  color: #22c55e;
  border-color: #22c55e;
  opacity: 1;
}

/* Schema detail popup */
.schema-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.schema-detail-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.schema-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
}

.schema-detail-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.schema-detail-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.schema-detail-close:hover { background: var(--bg-hover); }

.schema-detail-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.schema-detail-source {
  display: flex;
  flex-direction: column;
}

.schema-detail-source-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.schema-detail-proc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schema-detail-proc {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-tertiary, var(--bg-primary));
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

/* ===== T2S Auth page ===== */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg-primary);
}
.auth-card {
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: 12px; padding: 2rem; width: 100%; max-width: 400px;
}
.auth-logo { display: block; margin: 0 auto 1.5rem; height: 48px; border-radius: var(--radius-sm); overflow: hidden; }
.auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.auth-tab {
  flex: 1; padding: 10px 14px; background: transparent; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer;
  font-size: 0.875rem; font-weight: 600; font-family: inherit; transition: all var(--transition-fast);
}
.auth-tab:hover:not(.active) { transform: translateY(-2px); box-shadow: var(--shadow-md); background: var(--bg-hover); color: var(--text-primary); }
.auth-tab.active { background: var(--accent-gradient); border-color: var(--accent-primary); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-field { display: flex; flex-direction: column; gap: 0.375rem; }
.auth-field label { font-size: 0.8125rem; color: var(--text-secondary); }
.auth-hint { font-size: 0.75rem; color: var(--text-muted); }
.auth-field input {
  padding: 0.625rem 0.75rem; background: var(--bg-primary); border: 1px solid var(--border-light);
  border-radius: 6px; color: var(--text-primary); font-size: 0.875rem; transition: border-color 0.15s; font-family: inherit;
}
.auth-field input:focus { outline: none; border-color: var(--accent-primary); }
.auth-submit {
  padding: 14px 20px; background: var(--accent-gradient); border: none; border-radius: var(--radius-md);
  color: #fff; font-size: 0.9375rem; font-weight: 600; font-family: inherit; cursor: pointer;
  width: 100%; margin-top: 0.5rem; box-shadow: var(--shadow-sm); transition: all var(--transition-fast);
}
.auth-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); filter: brightness(1.08); }
.auth-submit:active:not(:disabled) { transform: translateY(0); box-shadow: var(--shadow-sm); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-error { color: #f87171; font-size: 0.8125rem; margin: 0; }
.auth-success { color: #4ade80; font-size: 0.8125rem; margin: 0; }

/* ===== T2S Admin page ===== */
.admin-page { padding: 2rem; background: var(--bg-primary); min-height: 100vh; color: var(--text-primary); }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; }
.admin-header h1 { font-size: 1.25rem; font-weight: 600; margin: 0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th, .admin-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-light); }
.admin-table th { color: var(--text-secondary); font-weight: 500; }
.approve-btn { padding: 0.375rem 0.75rem; background: var(--accent-primary); border: none; border-radius: 4px; color: #fff; font-size: 0.8125rem; cursor: pointer; transition: opacity 0.15s; }
.approve-btn:hover { opacity: 0.88; }
.deactivate-btn { padding: 0.375rem 0.75rem; background: #ef4444; border: none; border-radius: 4px; color: #fff; font-size: 0.8125rem; cursor: pointer; margin-left: 0.5rem; transition: opacity 0.15s; }
.deactivate-btn:hover { opacity: 0.88; }
.role-select { padding: 0.375rem 0.5rem; background: var(--bg-primary); border: 1px solid var(--border-light); border-radius: 4px; color: var(--text-primary); font-size: 0.8125rem; margin-right: 0.5rem; }
.role-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.role-badge.super_admin { background: #7c3aed22; color: #a78bfa; }
.role-badge.admin       { background: #0369a122; color: #38bdf8; }
.role-badge.user        { background: #16803422; color: #4ade80; }
.role-badge.disabled    { background: #ef444422; color: #f87171; }
.role-badge.pending     { background: #d9770622; color: #fb923c; }

/* ===== Welcome grid (guide / domains / how-it-works) ===== */
.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
  width: 100%;
  text-align: left;
}

.welcome-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.welcome-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.75rem; font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.welcome-steps {
  margin: 0; padding: 0 0 0 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.welcome-steps li {
  font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.5;
}

.welcome-steps li strong { color: var(--text-primary); }

.welcome-domains {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px;
}

.domain-tag {
  cursor: pointer;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.domain-tag:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.welcome-card-note {
  font-size: 0.72rem; color: var(--text-muted);
}

.welcome-card-guide {
  padding: 20px;
  text-decoration: none;
  color: inherit;
  display: block;
}

.guide-preview {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.guide-cover-img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ===== Buttons (utility) ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition-fast);
}
.btn-primary {
  background: var(--accent-gradient);
  color: #000;
}
.btn-primary:hover { opacity: 0.9; }

/* ===== Interrupt card ===== */
.interrupt-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  animation: fadeIn 0.3s ease;
}

.interrupt-card-title {
  font-size: 0.75rem; font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ===== Meta row (confidence, tables, verdict) ===== */
.meta-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}

.meta-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-xl);
  font-size: 0.75rem; font-weight: 600;
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.meta-badge.confidence-high { border-color: var(--accent-primary); color: var(--accent-primary); background: var(--accent-light); }
.meta-badge.confidence-mid  { border-color: var(--border-light);  color: var(--text-secondary); }
.meta-badge.confidence-low  { border-color: var(--color-error);   color: var(--color-error);   background: rgba(248,81,73,0.08); }

/* ===== Tiles (execute / accept / revise / yes / no) ===== */
.tile-row {
  display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px;
}

.tile {
  flex: 1; min-width: 120px; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 20px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tile:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.tile:active { transform: translateY(-1px); }
.tile.selected {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}
.tile-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-active);
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}
.tile:hover .tile-icon, .tile.selected .tile-icon {
  background: var(--accent-light);
  color: var(--accent-primary);
}
.tile-label { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.tile-desc { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }
.tile:disabled, .tile[disabled] {
  opacity: 0.45; cursor: not-allowed;
  transform: none !important; box-shadow: none !important;
}

/* ===== Revise / Clarify inline inputs ===== */
.revise-row, .clarify-row {
  margin-top: 12px;
  display: flex; gap: 8px;
}
.revise-input, .clarify-input {
  flex: 1;
  background: var(--bg-tertiary); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px; color: var(--text-primary);
  font-size: 0.875rem; font-family: inherit;
  outline: none; transition: border-color var(--transition-fast);
}
.revise-input:focus, .clarify-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 2px var(--accent-light); }

/* ===== SQL block ===== */
.sql-block {
  margin: 12px 0;
  border: 1px solid var(--sql-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.sql-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--sql-border);
}
.sql-block-label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px;
}
.sql-copy-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-hover); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.75rem; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition-fast);
}
.sql-copy-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.sql-block pre {
  background: var(--sql-bg);
  padding: 16px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

/* ===== Results table ===== */
.results-block { margin-top: 16px; }
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.results-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.results-count { font-size: 0.75rem; color: var(--text-muted); flex: 1; }
.csv-download-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--bg-hover); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.75rem; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition-fast);
}
.csv-download-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}
.results-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.results-table th {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-weight: 600; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.4px;
  text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}
.results-table td {
  padding: 10px 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--bg-hover); }
.results-truncated {
  padding: 8px 14px;
  font-size: 0.75rem; color: var(--text-muted);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.status-success { color: var(--color-success); }
.status-failed  { color: var(--color-error); }
.status-skipped { color: var(--text-muted); }

/* ===== Table family modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 520px; max-width: 92vw;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.modal-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.modal-close {
  background: none; border: none;
  font-size: 1.25rem; line-height: 1;
  color: var(--text-muted); cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.modal-table-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  font-size: 0.8125rem;
}
.modal-table-row:hover { background: var(--bg-hover); }
.modal-table-name {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: var(--text-primary);
  font-size: 0.775rem;
}
.modal-table-badge {
  font-size: 0.68rem; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge-pas {
  background: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid var(--border-accent);
}
.badge-ets {
  background: var(--bg-active);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* ===== System Selector ===== */
.system-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.system-btn {
  padding: 5px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.system-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.system-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #000;
}

/* ===== Terminal Panel ===== */
.terminal-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  max-width: 900px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  animation: fadeIn 0.3s ease;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
}

.terminal-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.terminal-status {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(199, 152, 55, 0.12);
  color: var(--accent-primary);
  letter-spacing: 0.03em;
}

.terminal-status.ts-done  { background: var(--bg-active); color: var(--text-primary); }
.terminal-status.ts-error { background: rgba(248, 81, 73, 0.12); color: #ef4444; }

.terminal-body {
  padding: 14px 16px;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.terminal-body::-webkit-scrollbar { width: 4px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.terminal-line {
  font-size: 0.775rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-line.log-ok    { color: var(--text-primary); }
.terminal-line.log-error { color: #ef4444; }
.terminal-line.log-warn  { color: var(--accent-primary); }
.terminal-line.log-info  { color: var(--text-primary); }
