/* ============================================================
   PJe Analyzer — Design System v3
   Sidebar layout, teal palette, modern cards
   ============================================================ */

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

:root {
  /* Spacing scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;

  /* Colors — Neutral (warmer dark) */
  --bg-base: #0f1117;
  --bg-raised: #171a23;
  --bg-overlay: #1e2130;
  --bg-input: #232738;
  --bg-hover: #2a2e42;
  --border-subtle: #2a2f40;
  --border-default: #363c52;
  --border-focus: #3b82f6;
  --text-primary: #e6e9f0;
  --text-secondary: #8b93a8;
  --text-tertiary: #5c6478;
  --text-inverse: #ffffff;

  /* Colors — Brand (blue) */
  --brand-primary: #2563eb;
  --brand-hover: #3b82f6;
  --brand-muted: rgba(37, 99, 235, 0.10);
  --brand-text: #93c5fd;
  --brand-glow: rgba(37, 99, 235, 0.15);
  --brand-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
  --brand-gradient-soft: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(29, 78, 216, 0.03));

  /* Sidebar */
  --sidebar-bg: #111420;
  --sidebar-width: 240px;
  --sidebar-active-bg: rgba(37, 99, 235, 0.12);
  --sidebar-active-border: var(--brand-primary);

  /* Colors — Semantic */
  --success: #34d399;
  --success-muted: rgba(52, 211, 153, 0.10);
  --success-border: rgba(52, 211, 153, 0.20);
  --danger: #f87171;
  --danger-muted: rgba(248, 113, 113, 0.10);
  --danger-border: rgba(248, 113, 113, 0.20);
  --warning: #fbbf24;
  --warning-muted: rgba(251, 191, 36, 0.10);
  --warning-border: rgba(251, 191, 36, 0.20);
  --info: #60a5fa;
  --info-muted: rgba(96, 165, 250, 0.10);
  --info-border: rgba(96, 165, 250, 0.20);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.75rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px var(--brand-glow);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* --- Tema Claro --- */
[data-theme="light"] {
  --bg-base: #f5f7fa;
  --bg-raised: #ffffff;
  --bg-overlay: #eef1f5;
  --bg-input: #e4e8ef;
  --bg-hover: #dde1ea;
  --border-subtle: #d0d5df;
  --border-default: #bfc5d2;
  --border-focus: #2563eb;
  --text-primary: #1a1d26;
  --text-secondary: #4b5563;
  --text-tertiary: #8b93a8;
  --text-inverse: #ffffff;

  --brand-muted: rgba(37, 99, 235, 0.12);
  --brand-glow: rgba(37, 99, 235, 0.10);
  --brand-gradient-soft: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(29, 78, 216, 0.02));
  --brand-text: #1d4ed8;

  --sidebar-bg: #f0f2f7;
  --sidebar-active-bg: rgba(37, 99, 235, 0.12);
  --sidebar-active-border: #2563eb;

  --success-muted: rgba(5, 150, 105, 0.10);
  --success-border: rgba(5, 150, 105, 0.25);
  --danger-muted: rgba(220, 38, 38, 0.08);
  --danger-border: rgba(220, 38, 38, 0.20);
  --warning-muted: rgba(217, 119, 6, 0.08);
  --warning-border: rgba(217, 119, 6, 0.20);
  --info-muted: rgba(37, 99, 235, 0.08);
  --info-border: rgba(37, 99, 235, 0.20);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.08);
}

[data-theme="light"] .nav-btn {
  color: var(--text-secondary);
}
[data-theme="light"] .nav-btn:hover {
  color: var(--text-primary);
  background: rgba(37, 99, 235, 0.06);
}
[data-theme="light"] .nav-btn.active {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.10);
  border-left-color: #2563eb;
}
[data-theme="light"] .nav-btn svg {
  opacity: 0.85;
}
[data-theme="light"] .nav-btn.active svg {
  opacity: 1;
  color: #2563eb;
}
[data-theme="light"] .sidebar-user-info {
  color: var(--text-secondary);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============================================================
   App Layout — Sidebar + Main
   ============================================================ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-dot {
  color: var(--brand-primary);
}

.brand-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-section-label:first-child {
  padding-top: var(--space-2);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px var(--space-3);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: inherit;
}

.nav-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

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

.nav-btn:hover svg {
  opacity: 1;
}

.nav-btn.active {
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
  color: var(--brand-text);
  font-weight: 600;
}

.nav-btn.active svg {
  opacity: 1;
  color: var(--brand-primary);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
}

.sidebar-user-info svg {
  flex-shrink: 0;
  color: var(--brand-primary);
}

.sidebar-footer-row {
  display: flex;
  gap: var(--space-2);
}

.sidebar-footer-row .sidebar-theme-toggle {
  flex: 1;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

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

.sidebar-logout-btn svg {
  flex-shrink: 0;
}

.sidebar-version {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  padding-left: var(--space-2);
}

.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 8px var(--space-3);
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

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

.sidebar-theme-toggle svg {
  flex-shrink: 0;
}

/* MCP mode info badge */
.mcp-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--brand-muted);
  border: 1px solid rgba(37, 99, 235, 0.20);
  border-radius: var(--radius-md);
  color: var(--brand-text);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.mcp-info svg {
  flex-shrink: 0;
  color: var(--brand-primary);
}

/* ============================================================
   Main Content Area
   ============================================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: var(--space-8) var(--space-8) var(--space-10);
  max-width: 1000px;
}

/* ============================================================
   Screen Header
   ============================================================ */
.screen-header {
  margin-bottom: var(--space-7);
}

.screen-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.screen-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* ============================================================
   Screen Visibility
   ============================================================ */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-base);
}

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

.card h2 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card h2 svg {
  color: var(--brand-primary);
  flex-shrink: 0;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}

.form-group small {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 400;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px var(--space-4);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-muted);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

select {
  cursor: pointer;
  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='%238b93a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input[type="file"] {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

input[type="file"]::file-selector-button {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 6px var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-right: var(--space-3);
  transition: all var(--transition-fast);
}

input[type="file"]::file-selector-button:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-5);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}

.btn.primary {
  background: var(--brand-gradient);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm), var(--shadow-glow);
}
.btn.primary:hover {
  box-shadow: var(--shadow-md), 0 0 24px var(--brand-glow);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn.secondary {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn.secondary:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  color: var(--brand-text);
}

.btn.danger {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn.danger:hover {
  background: rgba(248, 113, 113, 0.18);
  transform: translateY(-1px);
}

.btn.accent {
  background: var(--brand-gradient);
  color: var(--text-inverse);
  border: none;
}
.btn.accent:hover {
  filter: brightness(1.1);
}

.btn.large {
  padding: var(--space-3) var(--space-8);
  font-size: var(--text-md);
  border-radius: var(--radius-md);
  font-weight: 600;
}

.btn.small {
  padding: 5px var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

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

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.action-bar {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-5) 0;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--bg-base) 30%);
  padding-top: var(--space-8);
}

.btn-inline {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 1px 6px;
  margin-left: var(--space-2);
  transition: all var(--transition-fast);
}

.btn-inline:hover {
  color: var(--brand-text);
  border-color: var(--brand-primary);
  background: var(--brand-muted);
}

/* ============================================================
   Status / Feedback Boxes
   ============================================================ */
.status-box {
  margin-top: var(--space-3);
  padding: 10px var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: none;
  line-height: 1.5;
  font-weight: 450;
}

.status-box.show { display: block; animation: fadeIn 0.2s ease; }
.status-box.ok { background: var(--success-muted); color: var(--success); border: 1px solid var(--success-border); }
.status-box.error { background: var(--danger-muted); color: var(--danger); border: 1px solid var(--danger-border); }
.status-box.info { background: var(--info-muted); color: var(--info); border: 1px solid var(--info-border); }

/* ============================================================
   Toggle Buttons (MNI / Upload)
   ============================================================ */
.toggle-row {
  display: flex;
  gap: 0;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

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

.toggle-btn.active {
  background: var(--brand-gradient);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.toggle-row-3 .toggle-btn {
  font-size: var(--text-xs);
}

.toggle-row-4 .toggle-btn {
  font-size: 0.6875rem;
  padding: 8px 4px;
}

/* ─── Extrajudicial ─── */
.extrajudicial-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}
.extrajudicial-info svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--brand-primary);
}
.extrajudicial-progress-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-color);
}
.extrajudicial-progress-item .status-icon {
  font-size: 0.875rem;
}
.extrajudicial-progress-item .status-icon.success { color: var(--success); }
.extrajudicial-progress-item .status-icon.error { color: var(--danger); }
.extrajudicial-progress-item .status-icon.processing { color: var(--brand-primary); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.extrajudicial-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
}
.extrajudicial-result-item svg { color: var(--brand-primary); flex-shrink: 0; }
.extrajudicial-result-item span { flex: 1; }
.extrajudicial-result-item .btn { flex-shrink: 0; }

.extrajudicial-summary {
  padding: var(--space-3) 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

/* ─── Limpar Dados ─── */
.clear-data-card {
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
}
.clear-data-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

#extrajudicial-results h3 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

/* ============================================================
   Key Status Indicators
   ============================================================ */
.key-status {
  font-size: var(--text-xs);
  font-weight: 500;
  margin-left: var(--space-2);
}

/* ============================================================
   Upload List
   ============================================================ */
.upload-list {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-overlay);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.upload-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.upload-item .name {
  flex: 1;
  font-weight: 450;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item .size {
  color: var(--text-tertiary);
  margin: 0 var(--space-3);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.upload-item .remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 var(--space-1);
  line-height: 1;
  transition: color var(--transition-fast);
}

.upload-item .remove:hover {
  color: var(--danger);
}

/* ============================================================
   Preset Controls
   ============================================================ */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.card-header-row h2 {
  margin: 0;
  border: none;
  padding: 0;
}

.preset-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.preset-controls select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 10px;
  font-size: var(--text-sm);
  max-width: 200px;
}

/* ============================================================
   Queue
   ============================================================ */
.queue-summary {
  padding: var(--space-3) var(--space-4);
  background: var(--brand-muted);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--brand-text);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.queue-jobs {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.job-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--border-default);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.job-card.pending {
  border-left-color: var(--text-tertiary);
}

.job-card.running {
  border-left-color: var(--brand-primary);
  background: var(--brand-muted);
}

.job-card.completed {
  border-left-color: var(--success);
}

.job-card.error {
  border-left-color: var(--danger);
}

.job-card.cancelled {
  border-left-color: var(--warning);
  opacity: 0.5;
}

.job-card .job-num {
  font-weight: 600;
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.job-card .job-status {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.job-card .job-msg {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-left: var(--space-2);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   Results
   ============================================================ */
.result-card {
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.result-card:hover {
  border-color: var(--border-default);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.result-header:hover {
  background: var(--bg-overlay);
}

.result-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-mono);
}

.result-header .duration {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* PDF docs button */
.btn-pdf-docs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--brand-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.btn-pdf-docs:hover {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

/* PDF modal */
.pdf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.pdf-modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.pdf-modal-header h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}
.pdf-modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}
.pdf-modal-close:hover { color: var(--danger); }
.pdf-modal-body {
  padding: var(--space-3) var(--space-5);
  overflow-y: auto;
  flex: 1;
}
.pdf-file-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: background var(--transition-fast);
}
.pdf-file-item:hover {
  background: var(--bg-hover);
  color: var(--brand-text);
}
.pdf-file-item svg {
  color: var(--brand-primary);
  flex-shrink: 0;
}
.pdf-modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-align: center;
}

/* Badges */
.badge {
  font-size: var(--text-xs);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.ok {
  background: var(--success-muted);
  color: var(--success);
}

.badge.err {
  background: var(--danger-muted);
  color: var(--danger);
}

.badge.fallback {
  background: var(--warning-muted);
  color: var(--warning);
  font-weight: 500;
}

/* Result Body */
.result-body {
  padding: var(--space-5);
  line-height: 1.7;
  font-size: var(--text-base);
  white-space: pre-wrap;
  max-height: 600px;
  overflow-y: auto;
  color: var(--text-primary);
}

.result-body::-webkit-scrollbar {
  width: 6px;
}

.result-body::-webkit-scrollbar-track {
  background: transparent;
}

.result-body::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

.result-body.collapsed { display: none; }

.no-results {
  text-align: center;
  color: var(--text-tertiary);
  padding: var(--space-10) var(--space-6);
  font-size: var(--text-base);
}

/* ============================================================
   Export Controls
   ============================================================ */
.export-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.export-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  padding: 3px var(--space-2);
  border: 1px solid var(--border-subtle);
}

.export-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: var(--space-1);
}

/* ============================================================
   OCR Checkbox
   ============================================================ */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition-fast);
}

.checkbox-label:hover {
  border-color: var(--brand-primary);
}

.checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--brand-primary);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label span {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.ocr-hint {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 400;
}

/* ============================================================
   Field Hints
   ============================================================ */
.field-hint {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

/* ============================================================
   Section Divider
   ============================================================ */
.section-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-5) 0;
}

/* ============================================================
   Header Actions
   ============================================================ */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ============================================================
   Search Row
   ============================================================ */
.search-row {
  display: flex;
  gap: var(--space-2);
}

.search-row input {
  flex: 1;
}

/* ============================================================
   History Items
   ============================================================ */
.history-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: all var(--transition-fast);
}

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

.history-item.clickable {
  cursor: pointer;
}

.history-item.clickable:hover {
  border-color: var(--brand-primary);
  background: var(--brand-muted);
}

.history-item-main {
  flex: 1;
  min-width: 0;
}

.history-item-top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}

.history-date {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.history-stats {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.history-provider {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.history-prompt {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 var(--space-1);
  line-height: 1;
  transition: color var(--transition-fast);
  flex-shrink: 0;
}

.history-delete:hover {
  color: var(--danger);
}

/* History detail info */
.history-detail-info {
  margin-bottom: var(--space-5);
}

.detail-row {
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

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

.detail-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: var(--space-2);
}

/* ============================================================
   Log Cards
   ============================================================ */
.log-card {
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.log-card:hover {
  border-color: var(--border-default);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.log-header:hover {
  background: var(--bg-overlay);
}

.log-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.log-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.log-numero {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.log-date {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.log-provider {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.log-tokens {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.log-cost {
  font-size: var(--text-xs);
  color: var(--brand-text);
  font-family: var(--font-mono);
  font-weight: 600;
}

.log-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.log-duration {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.log-body {
  padding: var(--space-5);
}

.log-body.collapsed {
  display: none;
}

.log-section {
  margin-bottom: var(--space-4);
}

.log-section:last-child {
  margin-bottom: 0;
}

.log-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--brand-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}

.log-section-content {
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-primary);
  max-height: 400px;
  overflow-y: auto;
  padding: var(--space-3);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.log-response {
  max-height: 500px;
}

.log-error {
  color: var(--danger) !important;
}

.log-progress-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.log-progress-item {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--brand-primary);
  font-family: var(--font-mono);
}

/* ============================================================
   Mobile Menu Button
   ============================================================ */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: 200;
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: var(--space-2);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-6) var(--space-4);
    padding-top: var(--space-10);
  }

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

  .card-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .preset-controls {
    justify-content: flex-start;
  }

  .preset-controls select {
    max-width: none;
    flex: 1;
  }

  .export-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .export-group {
    justify-content: center;
  }

  .result-header {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .job-card {
    flex-wrap: wrap;
  }

  .job-card .job-msg {
    max-width: none;
    flex-basis: 100%;
    margin-left: 28px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row {
    flex-direction: column;
  }

  .log-header {
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
  }

  .log-header-right {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .history-item-top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    background: var(--bg-raised);
    border-top: 1px solid var(--border-subtle);
    z-index: 50;
    justify-content: center;
  }

  .btn-row {
    flex-direction: column;
  }

  .screen-header h1 {
    font-size: var(--text-xl);
  }

  /* Chat side panel — full width on mobile */
  .chat-side-panel {
    width: 100%;
  }

  .chat-backdrop.visible {
    display: block;
  }

  .result-header-actions {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ============================================================
   Scrollbar (global)
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-default);
}

/* ============================================================
   Result Header Actions (icon buttons row)
   ============================================================ */

.result-header-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  margin-right: 8px;
}

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

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

.btn-chat-toggle {
  color: var(--brand-primary);
}

/* ============================================================
   Result Edit Mode
   ============================================================ */

.result-body-edit {
  padding: 0;
}

.result-edit-textarea {
  width: 100%;
  min-height: 200px;
  padding: var(--space-4);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
}

.result-edit-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.result-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: var(--space-3);
  justify-content: flex-end;
}

/* ============================================================
   Chat Side Panel (full-height lateral overlay)
   ============================================================ */

.chat-side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  height: 100vh;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 150;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}

.chat-side-panel.open {
  transform: translateX(0);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-header-title span {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand-text);
}

.chat-header-title small {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.chat-header-actions {
  display: flex;
  gap: var(--space-2);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-msg {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: 90%;
  word-wrap: break-word;
}

.chat-msg.system {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-style: italic;
  max-width: 100%;
  text-align: center;
  padding: var(--space-3);
  background: transparent;
}

.chat-msg.user {
  background: var(--brand-muted);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: var(--text-primary);
  align-self: flex-end;
  white-space: pre-wrap;
}

.chat-msg.assistant {
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  align-self: flex-start;
  max-width: 95%;
}

.chat-msg.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  align-self: flex-start;
}

.chat-msg.loading {
  color: var(--text-secondary);
  font-style: italic;
}

.chat-typing {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--brand-primary);
  border-radius: 50%;
  animation: chatPulse 1s ease-in-out infinite;
}

@keyframes chatPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chat-input-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background: var(--sidebar-bg);
  align-items: flex-end;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.4;
}

.chat-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.chat-input:disabled {
  opacity: 0.5;
}

.chat-send-btn {
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
}

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

/* Chat backdrop overlay (mobile) */
.chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
}

.chat-backdrop.visible {
  display: block;
}

/* ============================================================
   Auth Login Overlay
   ============================================================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  z-index: 9999;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: var(--space-8);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
  justify-content: center;
}

.auth-card .form-group {
  margin-bottom: var(--space-5);
}

.auth-card .status-box {
  display: none;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}

.auth-card .status-box.show.error {
  display: block;
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* ============================================================
   Admin Screen
   ============================================================ */

.admin-table-wrap {
  overflow-x: auto;
  margin-top: var(--space-4);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.admin-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-overlay);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
}

.admin-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.admin-table tfoot td,
.admin-table tfoot tr {
  border-top: 2px solid var(--border-default);
  background: var(--bg-overlay);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin {
  background: var(--brand-muted);
  color: var(--brand-primary);
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge-user {
  background: var(--bg-overlay);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-locked {
  background: var(--danger-muted);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Create user form */
.admin-create-section {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

.admin-create-section h3 {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.admin-create-form {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  flex-wrap: wrap;
}

.admin-create-form input,
.admin-create-form select {
  flex: 1;
  min-width: 120px;
}

/* Filter row */
.admin-filter-row {
  display: flex;
  gap: var(--space-4);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.admin-filter-row .form-group {
  flex: 1;
  min-width: 140px;
}

.text-muted {
  color: var(--text-tertiary);
  text-align: center;
}

/* ── Token Consumption Screen ─────────────────────────────────────── */

.token-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.token-card {
  background: var(--bg-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.token-card-total {
  border-color: var(--brand-primary);
  background: var(--brand-muted);
}

.token-card-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.token-card-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.token-card-total .token-card-value {
  color: var(--brand-primary);
}

.token-table-wrap {
  overflow-x: auto;
}

.token-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.token-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.token-table td {
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

.token-table td:first-child { color: var(--text-primary); font-weight: 500; }
.token-table td.cost { color: var(--brand-primary); font-weight: 600; }
.token-table td.total-cost { color: var(--brand-primary); font-weight: 700; }
