/* ============================================
   LAWELY - Legal AI Solution
   Design System v2 — Amber & Warm Neutrals
   ============================================ */

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

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

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Brand */
  --amber: #F5A623;
  --amber-dark: #D4890A;
  --amber-hover: #D4890A;
  --coral: #F07450;

  /* Backward compat aliases */
  --primary: #F5A623;
  --primary-hover: #D4890A;
  --primary-light: rgba(245,166,35,0.12);
  --accent-color: #F5A623;

  /* Background */
  --bg: #FFFAF7;
  --bg-color: #FFFAF7;
  --bg-dark: #F3EDE8;
  --surface: #FFFFFF;
  --white: #FFFFFF;

  /* Text */
  --ink: #1C1917;
  --ink-2: #6B7280;
  --ink-3: #9CA3AF;
  --text-primary: #1C1917;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-sec: #6B7280;
  --black: #000000;

  /* Borders */
  --border: #E5E7EB;
  --border-color: #E5E7EB;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(245,166,35,0.18);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  /* Status */
  --success: #16A34A;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --warning: #D97706;
  --danger: #DC2626;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --info: #2563EB;
  --blue: #2563EB;
  --blue-light: #DBEAFE;
  --purple: #7C3AED;
  --purple-light: #EDE9FE;

  /* Sidebar dark theme */
  --sb-bg: #1C1917;
  --sb-text: rgba(255,255,255,0.6);
  --sb-text-active: #ffffff;
  --sb-border: rgba(255,255,255,0.08);
  --sb-hover: rgba(255,255,255,0.07);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.35;
  min-height: 100vh;
  font-size: 12px;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ============================================
   APP SHELL — Sidebar + Top Bar Layout
   ============================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.main-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 1rem;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: 228px;
  background: var(--sb-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.25s ease, min-width 0.25s ease;
  border-right: 1px solid var(--sb-border);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
}


.sidebar-logo {
  height: 48px;
  padding: 0 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo-text {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.sidebar-logo-l {
  color: var(--amber);
}

.sidebar-logo-rest {
  color: var(--sb-text-active);
}

.sidebar-logo-badge {
  padding: 1px 5px;
  background: rgba(245,166,35,0.13);
  color: var(--amber);
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 0.25rem;
}

.sidebar-new-case {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-new-case-btn {
  width: 100%;
  padding: 0.38rem 0.65rem;
  border-radius: 7px;
  background: var(--amber);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ink);
  transition: opacity 0.15s;
}

.sidebar-new-case-btn:hover {
  opacity: 0.85;
}

.sidebar-cases {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
}

.sidebar-section-label {
  padding: 0.45rem 0.9rem 0.2rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--sb-text);
  opacity: 0.4;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.sidebar-case-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.65rem;
  cursor: pointer;
  transition: all 0.12s;
  border-left: 3px solid transparent;
  margin: 0 0.15rem;
  border-radius: 0 6px 6px 0;
}

.sidebar-case-item:hover {
  background: var(--sb-hover);
}

.sidebar-case-delete {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.sidebar-case-item:hover .sidebar-case-delete {
  opacity: 1;
}
.sidebar-case-delete:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

.sidebar-case-item.active {
  background: rgba(245,166,35,0.12);
  border-left-color: var(--amber);
}

.sidebar-case-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-case-avatar.inactive {
  background: rgba(245,166,35,0.13);
  color: var(--amber);
}

.sidebar-case-avatar.active {
  background: var(--amber);
  color: var(--ink);
}

.sidebar-case-title {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--sb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-case-item.active .sidebar-case-title {
  font-weight: 600;
  color: var(--sb-text-active);
}

.sidebar-case-meta {
  font-size: 0.65rem;
  color: var(--sb-text);
  opacity: 0.45;
  margin-top: 1px;
}

/* Sidebar docs sub-list */
.sidebar-docs-list {
  margin-left: 0.2rem;
  margin-bottom: 0.25rem;
  border-left: 3px solid var(--amber);
  padding-left: 0.5rem;
  animation: fadeUp 0.18s ease;
}

.sidebar-docs-tabs {
  display: flex;
  padding: 0.3rem 0.65rem 0.2rem;
  gap: 0.8rem;
}

.sidebar-docs-tab {
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  color: var(--sb-text);
  opacity: 0.5;
}

.sidebar-docs-tab.active {
  color: var(--amber);
  opacity: 1;
  border-bottom-color: var(--amber);
}

.sidebar-doc-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 0.35rem;
  transition: background 0.1s;
}

.sidebar-doc-item:hover {
  background: var(--sb-hover);
}

.sidebar-doc-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-doc-name {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--sb-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.sidebar-doc-status {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 700;
}

.sidebar-doc-status.indexed {
  background: var(--green-light);
  color: var(--green);
}

.sidebar-doc-status.processing {
  background: #FEF3C7;
  color: #D97706;
}

.sidebar-upload-btn {
  background: transparent;
  border: 1px dashed var(--sb-border);
  border-radius: 6px;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--amber);
  font-family: inherit;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
  margin: 0.15rem 0.35rem;
}

.sidebar-upload-btn:hover {
  background: var(--sb-hover);
}

/* Sidebar user footer */
.sidebar-user {
  border-top: 1px solid var(--sb-border);
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.sidebar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--ink);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--sb-text-active);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  font-size: 0.65rem;
  color: var(--sb-text);
  opacity: 0.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.sidebar-collapse-btn {
  position: fixed;
  left: 227px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 201;
  color: var(--primary);
  font-size: 0.75rem;
  box-shadow: 2px 0 6px rgba(0,0,0,0.06);
}

.sidebar-collapse-btn:hover {
  width: 28px;
  background: var(--primary-light);
}

.sidebar-logout-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--sb-border);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  color: var(--sb-text);
  font-size: 0.85rem;
}

.sidebar-logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.sidebar-action-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--sb-border);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  color: var(--sb-text);
  font-size: 0.7rem;
  text-decoration: none;
}

.sidebar-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-archived-label {
  padding: 0.6rem 0.9rem 0.2rem;
  margin-top: 0.25rem;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--sb-text);
  opacity: 0.35;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-top: 1px solid var(--sb-border);
}

.sidebar-case-item.archived {
  opacity: 0.5;
}

.sidebar-case-item.archived:hover {
  opacity: 0.8;
}

/* ============================================
   FLOATING EXPAND BUTTON
   ============================================ */
.sb-expand-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: all 0.2s ease;
  color: var(--primary);
  font-size: 0.85rem;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  font-size: 0.8rem;
}

.sb-expand-btn:hover {
  width: 28px;
  background: var(--primary-light);
}

.sb-expand-btn.visible {
  display: flex;
}

/* ============================================
   TOP BAR
   ============================================ */
/* Top Bar Level 1: Case Info */
.top-bar-case {
  padding: 0.3rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.5rem;
}

.top-bar-case-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  min-width: 0;
}

.top-bar-case-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-case-detail {
  font-size: 0.68rem;
  color: var(--ink-2);
  font-weight: 500;
}

.top-bar-case-frist {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-2);
}

.top-bar-case-frist.urgent {
  color: var(--danger);
  background: var(--red-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.top-bar-case-parties {
  font-size: 0.68rem;
  color: var(--ink-3);
}

.top-bar-case-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.top-bar-area-badge {
  padding: 1px 6px;
  background: rgba(245,166,35,0.12);
  color: var(--amber-dark);
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
}

/* Top Bar Level 2: Tabs */
.top-bar {
  height: 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.top-bar-tabs {
  display: flex;
  align-items: stretch;
  height: 100%;
  flex: 1;
  overflow-x: auto;
  padding-left: 0.5rem;
}

.top-bar-tab {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.7rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-weight: 400;
  font-size: 0.75rem;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
  height: 100%;
  color: var(--ink-2);
}

.top-bar-tab:hover {
  color: var(--ink);
}

.top-bar-tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--amber);
}

.top-bar-tab.soon {
  color: var(--ink-3);
  cursor: default;
}

.top-bar-tab .bald-badge {
  padding: 1px 5px;
  background: rgba(245,166,35,0.1);
  color: var(--amber-dark);
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 0.1rem;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  flex-shrink: 0;
}

/* Content + Chat layout */
.content-with-chat {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.content-with-chat .main-content-area {
  flex: 1;
  min-width: 0;
}

/* Chat Right Panel */
.chat-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
}

.chat-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
}

.chat-panel-header {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: transparent;
}

.chat-panel-title {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-primary);
}

.chat-clear-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--ink-3);
  padding: 0;
}

.chat-clear-btn:hover {
  color: var(--coral);
  background: rgba(240,116,80,0.08);
}

.chat-panel-toggle {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--ink-2);
}

.chat-panel-toggle:hover {
  background: var(--bg-color);
  color: var(--primary);
}

.chat-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-expand-btn {
  display: none;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  padding: 0.75rem 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  box-shadow: -2px 0 8px rgba(0,0,0,0.06);
  z-index: 10;
}

.chat-expand-btn.visible {
  display: block;
}

/* ============================================
   COMING SOON SCREEN
   ============================================ */
.coming-soon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  animation: fadeUp 0.3s ease;
}

.coming-soon-inner {
  text-align: center;
  max-width: 480px;
  padding: 2rem;
}

.coming-soon-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(245,166,35,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 1.5rem;
}

.coming-soon-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(245,166,35,0.1);
  color: var(--amber-dark);
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.coming-soon-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.coming-soon h2 {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.coming-soon p {
  color: var(--ink-2);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.coming-soon-features {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
}

.coming-soon-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.coming-soon-feature-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(245,166,35,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.coming-soon-feature-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.1rem;
}

.coming-soon-feature-desc {
  font-size: 0.78rem;
  color: var(--ink-2);
  line-height: 1.45;
}

/* ============================================
   HEADER (legacy — still styled for compat)
   ============================================ */
.header {
  background: var(--surface);
  padding: 1.25rem 2.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Logo — new wordmark style */
.logo {
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--text-primary);
}

.logo::before {
  content: none;
}

.logo::after {
  content: none;
}

.logo span {
  display: none;
}

/* API Status */
.api-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 1.5s infinite;
}

.status-dot.connected {
  background: var(--success);
  animation: none;
}

.status-dot.error {
  background: var(--danger);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Sidebar skeleton loading */
.skeleton-item { pointer-events: none; }
.skeleton-line { background: var(--sb-border); }
.skeleton-pulse { animation: skeleton-shimmer 1.5s ease-in-out infinite; }
@keyframes skeleton-shimmer {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ============================================
   TAB NAVIGATION (legacy — still styled)
   ============================================ */
.tab-nav-container {
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 62px;
  z-index: 99;
}

.tab-nav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2.5rem;
  display: flex;
  gap: 0;
}

.tab-btn {
  flex: 1;
  max-width: 280px;
  padding: 1rem 1.5rem;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
}

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

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
}

.tab-icon {
  font-size: 1.1rem;
}

.tab-label {
  font-weight: 600;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0;
}

.tab-content {
  display: none;
}

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

/* ============================================
   SECTIONS
   ============================================ */
.section {
  margin-bottom: 0.65rem;
}

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

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 0.5rem;
}

.section-title-small {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--primary);
  color: var(--ink);
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

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

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-large {
  padding: 1rem 2.5rem;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn .spinner {
  width: 16px;
  height: 16px;
  border-color: rgba(255,255,255,0.3);
  border-top-color: white;
}

.btn-text.hidden,
.btn-spinner.hidden {
  display: none;
}

/* ============================================
   OVERVIEW — Fallinformationen card
   ============================================ */
.overview-info-card {
  background: var(--bg-dark);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.65rem;
}

.overview-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.overview-info-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.overview-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.25rem;
}

.overview-info-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.overview-info-label {
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.overview-info-value {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

.overview-info-value.urgent {
  color: var(--danger);
  font-weight: 700;
  background: var(--red-light);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
  font-size: 0.72rem;
}

.overview-info-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

/* ============================================
   OVERVIEW — Notes list
   ============================================ */
.overview-notes-list {
  display: flex;
  flex-direction: column;
}

.overview-notes-list:empty::after {
  content: 'Keine Notizen vorhanden.';
  display: block;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ============================================
   DOCUMENT CARDS
   ============================================ */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.document-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.document-card:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.document-card.has-pdf {
  border-left: 4px solid var(--primary);
}

.document-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.document-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.document-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.document-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  letter-spacing: 0.01em;
}

.document-badges {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.doc-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.doc-badge.pdf-badge {
  background: var(--primary);
  color: var(--ink);
}

.doc-badge.indexed-badge {
  background: var(--success);
  color: white;
}

/* ============================================
   LEGAL RESEARCH TAB
   ============================================ */

/* No Data State */
.no-data-state {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  padding: 2rem;
}

.no-data-content {
  text-align: center;
  padding: 2rem;
  background: var(--surface);
  border-radius: 12px;
  max-width: 400px;
  border: 1px solid var(--border-color);
}

.no-data-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.no-data-content h2 {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.no-data-content p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.88rem;
}

/* Streaming Loading State */
.loading-state-streaming {
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  min-height: 200px;
  border: 1px solid var(--border-color);
}

.loading-state-streaming.hidden {
  display: none;
}

.streaming-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.progress-bar-track {
  flex: 1;
  height: 5px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-bar-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 120px;
}

.streaming-stage {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.streaming-stage-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.58rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.streaming-stage-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.streaming-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Streaming Text */
.streaming-text-container {
  max-height: 500px;
  overflow-y: auto;
  padding: 0.5rem 0.7rem 0.5rem 1.1rem;
  background: transparent;
  border-radius: 6px;
  border: none;
}

.streaming-text {
  font-size: 0.82rem;
  line-height: 1.38;
  color: var(--text-primary);
}

.streaming-text:empty::before {
  content: 'Generiere...';
  color: var(--text-muted);
  font-style: italic;
}

.streaming-current {
  display: inline;
  color: var(--text-primary);
}

.streaming-current::after {
  content: '|';
  animation: blink 1s infinite;
  color: var(--primary);
  font-weight: bold;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Streaming text formatting */
.streaming-text h4 {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.5rem 0 0.1rem 0;
}

.streaming-text h4:first-child {
  margin-top: 0;
}

.streaming-text h5 {
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0.4rem 0 0.05rem 0;
}

.streaming-text h5:first-child {
  margin-top: 0;
}

.streaming-text p {
  margin: 0;
  line-height: 1.38;
  color: var(--text-primary);
}

.streaming-text ul {
  margin: 0.1rem 0;
  padding-left: 1.1rem;
}

.streaming-text li {
  margin: 0;
  color: var(--text-primary);
}

.streaming-text .analysis-list-item {
  margin: 0;
  color: var(--text-primary);
}

.streaming-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Streaming Fragments */
.streaming-fragments-container {
  max-height: 500px;
  overflow-y: auto;
}

.streaming-fragments-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.streaming-fragment-item {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  background: var(--surface);
  animation: fragmentFadeIn 0.3s ease-out;
  transition: all 0.2s ease;
}

.streaming-fragment-item:hover {
  border-color: var(--amber);
}

.streaming-fragment-item.new {
  background: var(--primary-light);
}

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

.streaming-fragment-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
  flex-wrap: wrap;
}

.streaming-fragment-source {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.78rem;
}

.streaming-fragment-page {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.streaming-fragment-score {
  font-size: 0.65rem;
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  font-weight: 700;
  margin-left: auto;
}

.streaming-fragment-score.high {
  background: #DCFCE7;
  color: #16A34A;
}

.streaming-fragment-score.medium {
  background: #FEF3C7;
  color: #D97706;
}

.streaming-fragment-score.low {
  background: #FEE2E2;
  color: #DC2626;
}

.streaming-fragment-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
  max-height: 48px;
  overflow: hidden;
}

/* Research Content */
.research-content.hidden {
  display: none;
}

.research-top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

/* Context Analysis Section */
/* ============================================
   UNIFIED PANEL COMPONENTS
   All panels (Kontextanalyse, Fallanalyse,
   Rechtsfragmente, Rechtsprechung) use these.
   ============================================ */

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 0.65rem;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.85rem;
  background: transparent;
}

.panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.panel-status-badge {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.25rem;
}

.panel-status-badge.done {
  background: var(--green-light);
  color: var(--green);
}

.panel-title-number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toggle-analysis-btn {
  background: transparent;
  border: none;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.toggle-analysis-btn .toggle-icon {
  color: var(--ink-2);
  font-size: 0.7rem;
  line-height: 1;
  display: block;
}

.toggle-analysis-btn:hover {
  background: var(--bg-dark);
}

.toggle-analysis-btn:hover .toggle-icon {
  color: var(--ink);
}

/* Small action buttons in panel headers (Erneut suchen, PDF, etc.) */
.panel-action-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.panel-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.panel-action-btn.panel-action-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--ink);
}

.panel-action-btn.panel-action-primary:hover {
  background: var(--primary-hover);
}

.panel-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Panel body content styling for analysis text */
.panel-body {
  padding: 0.5rem 0.85rem 0.5rem 1.1rem;
  font-size: 0.82rem;
  line-height: 1.38;
}

.panel-body h4 {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0.5rem 0 0.1rem 0;
}

.panel-body h4:first-child {
  margin-top: 0;
}

.panel-body p {
  margin-bottom: 0;
  color: var(--text-primary);
}

.panel-body strong {
  color: var(--text-primary);
  font-weight: 700;
}

.panel-body .research-list {
  margin: 0;
  padding: 0;
}

.case-analysis-loading {
  text-align: center;
  color: var(--text-muted);
}

.case-analysis-btn {
  background: var(--primary);
  border: none;
  color: var(--ink);
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  letter-spacing: 0.01em;
}

.case-analysis-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.case-analysis-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Search Terms Section */
.search-terms-section {
  padding: 0.4rem 0.85rem;
  margin: 0;
  border-top: 1px solid var(--border-color);
}

.search-terms-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.search-terms-btn {
  margin-left: auto;
  white-space: nowrap;
}

.search-terms-label {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.search-terms-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.search-terms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.search-term-tag {
  padding: 0.18rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.search-term-tag.active {
  background: var(--primary);
  color: var(--ink);
}

.search-term-tag.active:hover {
  background: var(--primary-hover);
}

.search-term-tag.disabled {
  background: var(--bg-dark);
  color: var(--text-muted);
  text-decoration: line-through;
}

.search-term-tag.disabled:hover {
  background: var(--border-color);
}

.search-term-add {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-term-add:hover {
  background: var(--primary);
  color: var(--ink);
  border-style: solid;
}

.search-term-input {
  border: none;
  background: var(--primary);
  color: var(--ink);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  width: 140px;
  outline: none;
}

.search-term-input::placeholder {
  color: rgba(28,25,23,0.5);
}

.search-terms-actions {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.35rem;
}

.search-terms-actions .btn-primary {
  padding: 0.5rem 1.25rem;
  background: var(--primary);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.search-terms-actions .btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.search-terms-actions .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.search-terms-refresh {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}

.search-terms-refresh:hover {
  background: var(--primary);
  color: var(--ink);
}

/* Fragments count pill (used in panel headers) */
.fragments-count {
  padding: 0.15rem 0.5rem;
  background: var(--surface);
  font-size: 0.68rem;
  color: var(--text-muted);
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

/* Research List */
.research-list {
  list-style: none;
}

.research-item {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  transition: all 0.2s ease;
  cursor: pointer;
  background: var(--surface);
}

.research-item:hover {
  border-color: var(--amber);
  background: var(--bg-color);
}

.research-item.hidden-item {
  opacity: 0.5;
  border-left: 3px solid var(--text-muted);
}

.research-item-content {
  flex: 1;
}

.research-item-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
  flex-wrap: wrap;
}

.fragment-source {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.78rem;
}

.fragment-page {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.fragment-score {
  font-size: 0.65rem;
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  font-weight: 700;
}

.fragment-score.high {
  background: #DCFCE7;
  color: #16A34A;
}

.fragment-score.medium {
  background: #FEF3C7;
  color: #D97706;
}

.fragment-score.low {
  background: #FEE2E2;
  color: #DC2626;
}

.research-item-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.research-list.compact .research-item {
  padding: 0.5rem 0.75rem;
}

.research-list.compact .research-item-text {
  max-height: 60px;
  overflow: hidden;
}

/* Search Method Badge */
.search-method-badge {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.method-bm25 {
  background: var(--info);
}

.method-semantic {
  background: var(--purple);
}

.method-hybrid {
  background: var(--success);
}

/* Visibility Toggle */
.visibility-toggle {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.visibility-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.visibility-toggle.hidden {
  background: #FEF3C7;
  border-color: #D97706;
  color: #D97706;
}

.visibility-toggle.show-btn {
  background: #DCFCE7;
  border-color: #16A34A;
  color: #16A34A;
}

/* ── Court Fragments (Rechtsprechung) ────────── */
.court-fragments-section-wrapper {
  margin-top: 1rem;
}

.court-item {
  border-left: 3px solid #6366F1;
}

.court-item:hover {
  border-color: #6366F1;
}

.court-item.hidden-item {
  border-left-color: var(--text-muted);
}

.court-handle {
  cursor: default;
  color: #6366F1;
}

.court-source {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.court-section-label-unused {
  display: none;
  font-weight: 500;
}

.court-ecli-unused {
  display: none;
}

/* ============================================
   CHAT TAB
   ============================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border-radius: 0;
  overflow: hidden;
  border: none;
}

.chat-context-bar {
  padding: 0.35rem 0.65rem;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.context-label {
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 0.65rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-welcome {
  text-align: center;
  padding: 1rem 0.65rem;
  color: var(--text-muted);
}

.chat-welcome-icon {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
  opacity: 0.5;
}

.chat-welcome h3 {
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
}

.chat-welcome p {
  max-width: 260px;
  margin: 0 auto;
  line-height: 1.38;
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.chat-message {
  max-width: 90%;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  line-height: 1.38;
  font-size: 0.75rem;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--amber);
  color: var(--ink);
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--bg-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-message.assistant p {
  margin-bottom: 0.15rem;
}

.chat-message.assistant p:last-child {
  margin-bottom: 0;
}

.chat-message.loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-input-container {
  padding: 0.35rem 0.6rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.35rem;
  align-items: flex-end;
  background: var(--bg-color);
}

.chat-input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 0.75rem;
  font-family: inherit;
  resize: none;
  min-height: 28px;
  max-height: 100px;
  background: var(--surface);
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(245,166,35,0.14);
}

.chat-send {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.chat-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.chat-sources-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chat-source-chip {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  background: var(--primary-light);
  color: var(--amber-dark);
  border-radius: 4px;
  font-weight: 600;
  cursor: default;
  white-space: nowrap;
}

.chat-source-chip:hover {
  background: var(--primary);
  color: var(--ink);
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--bg-color);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-right: 1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: var(--bg-color);
}

.modal-footer .btn {
  padding: 0.5rem 1.25rem;
  font-size: 0.82rem;
  white-space: nowrap;
  min-width: fit-content;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-footer .btn-danger {
  margin-right: auto;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--surface);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.14);
}

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

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Appointment Details */
.appointment-detail {
  margin-bottom: 1.5rem;
}

.appointment-detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.appointment-detail-value {
  font-size: 1rem;
  color: var(--text-primary);
}

.appointment-type-badge {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--primary-light);
  color: var(--amber-dark);
}

.transcript-box {
  background: var(--bg-color);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

/* ============================================
   LOGIN OVERLAY
   ============================================ */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  overflow: hidden;
}

.login-overlay.hidden {
  display: none;
}

/* Login blobs */
.login-blob {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.login-blob-1 {
  width: 480px;
  height: 480px;
  bottom: -130px;
  left: -130px;
  border-radius: 60% 40% 70% 30%/50% 60% 40% 70%;
  background: radial-gradient(circle at 40% 40%, #F5A623, #F07450cc);
  animation: blobDrift 10s ease-in-out infinite alternate;
}

.login-blob-2 {
  width: 320px;
  height: 320px;
  top: -80px;
  right: -80px;
  border-radius: 40% 60% 30% 70%/60% 40% 70% 30%;
  background: radial-gradient(circle at 60% 40%, #F07450bb, #F5A62388);
  animation: blobDrift 13s ease-in-out infinite alternate-reverse;
  filter: blur(2px);
}

.login-blob-3 {
  width: 180px;
  height: 180px;
  top: 40%;
  right: 13%;
  border-radius: 50%;
  background: radial-gradient(circle, #F07450aa, transparent);
  opacity: 0.4;
  animation: blobDrift 8s ease-in-out infinite alternate;
}

@keyframes blobDrift {
  from { transform: translate(0,0) rotate(0deg); }
  to { transform: translate(18px,14px) rotate(7deg); }
}

.login-box {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 60px rgba(17,24,39,0.1);
  position: relative;
  z-index: 1;
}

.login-logo {
  font-family: var(--font-family);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.login-logo::before {
  content: none;
}

.login-logo::after {
  content: none;
}

.login-logo .login-logo-subtitle {
  display: none;
}

.login-subtitle {
  color: var(--amber-dark);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 2.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Maintenance screen */
.maintenance-box {
  text-align: center;
}

.maintenance-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.maintenance-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.maintenance-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.maintenance-retry {
  padding: 0.6rem 1.5rem;
}

.login-box .form-group {
  text-align: left;
}

.login-btn {
  width: 100%;
  padding: 0.7rem;
  font-size: 0.88rem;
  margin-top: 0.75rem;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  min-height: 1.25rem;
}

/* Upload progress */
.upload-progress-list {
  margin-top: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
}

.upload-progress-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}

.upload-progress-item:last-child { border-bottom: none; }
.upload-progress-icon { flex-shrink: 0; width: 1.2rem; text-align: center; }
.upload-progress-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress-status { flex-shrink: 0; font-size: 0.75rem; color: var(--text-sec); }
.upload-progress-status.success { color: var(--success); }
.upload-progress-status.error { color: var(--danger); }
.upload-progress-status.uploading { color: var(--primary); animation: pulse-text 1.5s ease-in-out infinite; }
@keyframes pulse-text { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============================================
   TOAST NOTIFICATIONS (Pill, centered)
   ============================================ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.4rem;
  border-radius: 99px;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 2000;
  white-space: nowrap;
  pointer-events: none;
}

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

/* ============================================
   SPINNERS
   ============================================ */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner.large {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.spinner.hidden {
  display: none;
}

.loading-spinner-small {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ============================================
   EMPTY & HIDDEN STATES
   ============================================ */
.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

/* ============================================
   NUMBERED LISTS (Amber numbers)
   ============================================ */
.context-analysis-content ol,
.case-analysis-content ol {
  list-style: none;
  counter-reset: item;
  padding-left: 0;
}

.context-analysis-content ol li,
.case-analysis-content ol li {
  counter-increment: item;
  margin-bottom: 0;
  padding-left: 1.5rem;
  position: relative;
}

.context-analysis-content ol li::before,
.case-analysis-content ol li::before {
  content: counter(item) ".";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.analysis-list-item {
  padding: 0;
  padding-left: 1.25rem;
  position: relative;
}

.item-number {
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.big-number {
  font-size: 4rem;
  font-weight: 300;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* ============================================
   MULTI-USER: Header user info
   ============================================ */
.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.user-tier-badge {
  background: var(--primary-light);
  color: var(--amber-dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.user-name-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.admin-panel-link {
  background: var(--primary);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: background 0.15s;
}

.admin-panel-link:hover {
  background: var(--primary-hover);
}

.btn-logout-header {
  background: none;
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.btn-logout-header:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   CASES SECTION
   ============================================ */
.cases-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 900px) {
  .cases-layout {
    grid-template-columns: 1fr 360px;
  }
}

.btn-icon-sm {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.1s;
}

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

.btn-danger-sm:hover {
  background: var(--red-light);
  color: var(--danger);
}

/* Feedback thumbs up/down */
.feedback-buttons {
  display: inline-flex;
  gap: 0.2rem;
  margin-top: 0.5rem;
}

.header-actions .feedback-buttons,
.fragments-header-right .feedback-buttons {
  margin-top: 0;
  align-items: center;
}

.header-actions .feedback-buttons .btn-feedback,
.header-feedback .btn-feedback {
  font-size: 1rem;
  padding: 0.25rem 0.45rem;
  opacity: 0.7;
}

.header-actions .feedback-buttons .btn-feedback:hover,
.header-feedback .btn-feedback:hover {
  opacity: 1;
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-feedback {
  background: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.btn-feedback:hover {
  opacity: 1;
  background: var(--bg-color);
  border-color: var(--border-color);
}

.btn-feedback.active[data-rating="up"] {
  opacity: 1;
  border-color: var(--primary);
  background: rgba(245, 166, 35, 0.1);
}

.btn-feedback.active[data-rating="down"] {
  opacity: 1;
  border-color: var(--danger);
  background: var(--red-light);
}

.chat-message .feedback-buttons {
  justify-content: flex-end;
  border-top: none;
  margin-top: 0.35rem;
}

.case-status-badge {
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.case-status-active {
  background: var(--green-light);
  color: #065F46;
}

.case-status-archived {
  background: #F3F4F6;
  color: #6B7280;
}

/* Case documents panel */
.case-docs-panel {
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  position: relative;
}

.drop-zone-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--amber);
  border-radius: 12px;
  background: rgba(245, 166, 35, 0.05);
  color: var(--amber-dark);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.drop-zone-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.case-docs-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.case-docs-panel-title {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.case-docs-list {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.case-doc-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg-color);
  border-radius: 5px;
}

.case-doc-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
}

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

.case-doc-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.case-doc-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.case-doc-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  line-height: 1.3;
}

.case-doc-badge.indexed {
  background: var(--green-light);
  color: var(--green);
}

.case-doc-badge.processing {
  background: rgba(245,166,35,0.15);
  color: var(--amber-dark);
}

.case-doc-badge.failed {
  background: var(--red-light);
  color: var(--danger);
}

.case-doc-error {
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 0.1rem;
}

.case-doc-summary {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  line-height: 1.4;
  padding: 0.3rem 0.5rem;
  background: var(--bg-color);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}

.case-doc-summary-pending {
  color: var(--text-muted);
  font-style: italic;
  border-left-color: var(--warning);
}

.case-doc-summary-failed {
  color: var(--danger);
  border-left-color: var(--danger);
}

.case-doc-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.loading-inline {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* Case Profile Modal */
.modal-wide {
  max-width: 680px;
}

.profile-parties-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.profile-parties-header .form-label {
  margin-bottom: 0;
}

.profile-party-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.5rem;
}

.profile-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.5rem;
  border-radius: 8px;
  margin-top: 0.25rem;
}

.profile-remove-btn:hover {
  color: var(--danger);
  background: var(--red-light);
}

.profile-custom-objective {
  margin-top: 0.5rem;
}

.profile-footer-spacer {
  flex: 1;
}

.profile-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ============================================
   CASE PANEL TABS (Dokumente / Notizen)
   ============================================ */
.case-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin: -0.25rem 0 0.25rem 0;
}

.case-panel-tab {
  background: none;
  border: none;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}

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

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

/* ============================================
   CASE NOTES
   ============================================ */
.case-notes-section {
  flex: 1;
  overflow-y: auto;
}

.case-notes-list {
  display: flex;
  flex-direction: column;
}

.note-card {
  padding: 0.55rem 0.65rem 0.55rem 0.65rem;
  cursor: pointer;
  transition: background 0.12s;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  position: relative;
  padding-left: 1.3rem;
}

.note-card::before {
  content: '';
  position: absolute;
  left: 0.45rem;
  top: 0.75rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.note-card:hover {
  background: var(--bg-color);
}

.note-card.pinned {
  border-left: 3px solid var(--primary);
  padding-left: calc(1.3rem - 3px);
  background: var(--primary-light);
}

.note-card.pinned:hover {
  background: rgba(245,166,35,0.18);
}

.note-card-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.1rem;
}

.note-card-title {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.note-card-title.muted {
  color: var(--text-muted);
  font-style: italic;
}

.note-pin-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.15rem;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
}

.note-pin-icon.pinned {
  color: var(--primary);
}

.note-pin-icon:hover {
  color: var(--primary-hover);
}

.note-card-preview {
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Expanded note (editor) */
.note-card.expanded {
  cursor: default;
  background: var(--surface);
}

.note-card.expanded:hover {
  background: var(--surface);
}

.note-editor input {
  width: 100%;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  font-family: var(--font-family);
}

.note-editor input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.14);
}

.note-editor textarea {
  width: 100%;
  min-height: 120px;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
  line-height: 1.38;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  resize: vertical;
  font-family: var(--font-family);
}

.note-editor textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.14);
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.note-actions .btn-danger-sm {
  font-size: 0.75rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.note-actions .btn-danger-sm:hover {
  background: var(--red-light);
}

.note-save-indicator {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ============================================
   MOBILE BOTTOM NAV (dark theme)
   ============================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1C1917;
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 200;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 6px;
  border: none;
  background: none;
  color: rgba(255,255,255,0.4);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bottom-nav-btn.active {
  color: var(--amber);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav-label {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .header {
    padding: 1rem 1.25rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
  }

  .tab-nav {
    padding: 0 1rem;
  }

  .tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
  }

  .tab-label {
    display: none;
  }

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

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
  }

  .section-title {
    font-size: 0.78rem;
  }

  /* Sidebar collapses on mobile */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 300;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.collapsed {
    width: 0;
    min-width: 0;
  }

  .main-content-area {
    padding: 0.75rem;
  }

  /* Chat panel hidden on mobile */
  .chat-panel {
    display: none;
  }
  .chat-expand-btn {
    display: none !important;
  }

  /* Top bar compact on mobile */
  .top-bar-case {
    padding: 0.35rem 0.75rem;
  }
  .top-bar-case-actions {
    display: none;
  }
  .top-bar {
    height: 36px;
  }
  .top-bar-tab {
    font-size: 0.7rem;
    padding: 0 0.5rem;
  }

  /* Overview info grid single column on mobile */
  .overview-info-grid {
    grid-template-columns: 1fr;
  }

  /* Bottom nav */
  .bottom-nav {
    display: flex;
  }

  .tab-nav-container {
    display: none;
  }

  body {
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0));
  }

  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
    margin: 0;
    animation: slideUp 0.25s ease-out;
  }

  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .toast {
    bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }

  .header-right .api-status {
    display: none;
  }

  .user-name-label {
    display: none;
  }

  .btn-logout-header {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

/* Phone breakpoint */
@media (max-width: 480px) {
  body {
    font-size: 12px;
  }

  .header {
    padding: 0.75rem 1rem;
  }

  .logo {
    font-size: 1rem;
  }

  .section-title {
    font-size: 0.78rem;
  }

  .modal {
    max-height: 90vh;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .modal-footer .btn {
    flex: 1;
    min-width: 0;
  }

  .btn {
    min-height: 38px;
    font-size: 0.82rem;
  }

  .form-input, .form-select {
    min-height: 38px;
    font-size: 0.92rem;
  }

  .note-card {
    padding: 0.5rem 0.6rem 0.5rem 1.2rem;
  }

  .main-content-area {
    padding: 0.75rem;
  }
}

/* ============================================
   INIT LOADING OVERLAY
   ============================================ */
.init-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(28, 25, 23, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}

.init-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.init-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.5rem 3rem;
  min-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.init-logo {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 2rem;
  letter-spacing: -0.5px;
}

.init-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.init-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.3s;
}

.init-step.active {
  color: var(--primary);
  font-weight: 600;
}

.init-step.done {
  color: var(--text-primary);
}

.init-step-icon {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}

/* ============================================
   STATUS PILL (top bar)
   ============================================ */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.status-pill:hover {
  border-color: var(--primary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(245,166,35,0.15);
}

.status-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-pill-dot.ready { background: #22c55e; }
.status-pill-dot.active { background: var(--primary); animation: pulse-dot 1.5s ease-in-out infinite; }
.status-pill-dot.error { background: var(--danger); }

.status-pill.processing {
  animation: pill-pulse 2s ease-in-out infinite;
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(245,166,35,0.06);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245,166,35,0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 5px rgba(245,166,35,0); }
}

@keyframes pill-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 1px 4px rgba(245,166,35,0.15); background: rgba(245,166,35,0.06); }
  50% { opacity: 0.75; box-shadow: 0 1px 12px rgba(245,166,35,0.35); background: rgba(245,166,35,0.12); }
}

/* ============================================
   PIPELINE MODAL
   ============================================ */
.pipeline-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(28, 25, 23, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease;
}

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

.pipeline-modal {
  background: var(--surface);
  border-radius: 16px;
  width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

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

.pipeline-modal-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin: 0;
}

.pipeline-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}

.pipeline-modal-close:hover { color: var(--text-primary); }

.pipeline-modal-body {
  padding: 1.25rem 1.5rem;
}

/* Pipeline ETA bar */
.pipeline-eta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  background: rgba(245,166,35,0.08);
  border: 1px solid rgba(245,166,35,0.2);
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pipeline-eta-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.pipeline-eta-time {
  font-weight: 600;
  color: var(--primary);
}

/* Pipeline group */
.pipeline-group {
  margin-bottom: 1.25rem;
}

.pipeline-group:last-child { margin-bottom: 0; }

.pipeline-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: 2rem;
}

/* Pipeline step node */
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  position: relative;
}

/* Vertical line connecting nodes */
.pipeline-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 0.55rem;
  top: 1.6rem;
  width: 1px;
  height: calc(100% - 0.4rem);
  background: var(--border-color);
}

.pipeline-step.active::before { background: var(--primary); }
.pipeline-step.done::before { background: #22c55e; }

.pipeline-node {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.6rem;
  background: var(--surface);
  transition: all 0.3s;
}

.pipeline-step.done .pipeline-node {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}

.pipeline-step.active .pipeline-node {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.pipeline-step.active {
  color: var(--text-primary);
  font-weight: 600;
}

.pipeline-step.done {
  color: var(--text-secondary);
}

.pipeline-idle-msg {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pipeline-idle-msg .pipeline-idle-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.75rem;
}
