/* ═══════════════════════════════════════════════════
   MeuDoc — PDF Generation Service
   Industrial-precision ERP aesthetic
   ═══════════════════════════════════════════════════ */

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

/* ── Tokens ─────────────────────────────────────── */
:root {
  --bg-body: #eef1f5;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f8f9fb;
  --bg-sidebar: #111827;
  --bg-sidebar-hover: #1d2939;
  --bg-sidebar-active: #1976d2;
  --bg-input: #f5f7fa;
  --bg-overlay: rgba(17, 24, 39, 0.55);

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;
  --text-sidebar: #9ca3af;
  --text-sidebar-active: #ffffff;

  --accent: #1976d2;
  --accent-hover: #1565c0;
  --accent-subtle: #e8f0fe;
  --accent-text: #1565c0;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;

  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);

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

  --sidebar-width: 260px;
  --header-height: 0px;

  --transition-fast: 150ms cubic-bezier(.4,0,.2,1);
  --transition-base: 250ms cubic-bezier(.4,0,.2,1);
  --transition-slow: 350ms cubic-bezier(.4,0,.2,1);
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }

/* ── Utility ────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }

/* ── Login Screen ───────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827 0%, #1e3a5f 50%, #111827 100%);
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 50%, rgba(25,118,210,.12), transparent),
    radial-gradient(ellipse 500px 350px at 80% 30%, rgba(25,118,210,.08), transparent);
  pointer-events: none;
}

.login-card {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,.05);
  text-align: center;
  animation: loginEnter .5s var(--transition-base) both;
}
@keyframes loginEnter {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-brand-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(25,118,210,.35);
}
.login-brand-icon svg { width: 24px; height: 24px; color: #fff; }
.login-brand h1 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.login-subtitle {
  color: var(--text-muted);
  font-size: .92rem;
  margin-bottom: 36px;
  line-height: 1.5;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

#google-signin-btn {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.login-footer {
  margin-top: 32px;
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Pending Screen ─────────────────────────────── */
.pending-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
}
.pending-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: loginEnter .5s var(--transition-base) both;
}
.pending-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: var(--warning-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pending-icon svg { width: 32px; height: 32px; color: var(--warning); }
.pending-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
.pending-card p { color: var(--text-secondary); font-size: .92rem; margin-bottom: 24px; }
.pending-email { font-weight: 500; color: var(--text-primary); }

/* ── App Shell ──────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  animation: fadeIn .3s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon svg { width: 20px; height: 20px; color: #fff; }
.sidebar-brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: -.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.sidebar-section-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.25);
  padding: 16px 12px 6px;
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-sidebar);
  font-size: .9rem;
  font-weight: 450;
  transition: all var(--transition-fast);
  cursor: pointer;
  width: 100%;
  text-align: left;
  position: relative;
}
.sidebar-nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}
.sidebar-nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(25,118,210,.3);
}
.sidebar-nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .7;
}
.sidebar-nav-item.active svg { opacity: 1; }

.sidebar-user {
  padding: 16px 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.1);
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: .72rem;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout-btn {
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  transition: all var(--transition-fast);
}
.sidebar-logout-btn:hover { background: rgba(220,38,38,.15); color: #f87171; }
.sidebar-logout-btn svg { width: 18px; height: 18px; }

/* ── Main Content ───────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.page-header {
  padding: 28px 32px 0;
}
.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.page-header p {
  color: var(--text-secondary);
  font-size: .9rem;
  margin-top: 2px;
}

.page-body {
  padding: 24px 32px 40px;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.card-body { padding: 24px; }

/* ── Form Elements ──────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: .9rem;
  transition: all var(--transition-fast);
  outline: none;
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--bg-surface);
}
.form-textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
}
.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: .88rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(25,118,210,.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 6px rgba(25,118,210,.35); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

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

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #15803d; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-sm svg { width: 15px; height: 15px; }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-input); color: var(--text-primary); }

/* ── Model Selector ─────────────────────────────── */
.model-selector { position: relative; }
.model-selector-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}
.model-selector-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.model-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  animation: dropIn .15s ease;
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.model-search-box { padding: 10px 12px 6px; }
.model-search-box .form-input { font-size: .82rem; padding: 8px 10px; }
.model-filters {
  display: flex;
  gap: 6px;
  padding: 4px 12px 8px;
  flex-wrap: wrap;
}
.model-filter-chip {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 500;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.model-filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.model-filter-chip.active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent-text); }
.model-list {
  overflow-y: auto;
  flex: 1;
  max-height: 300px;
  border-top: 1px solid var(--border);
}
.model-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
  display: block;
  width: 100%;
  text-align: left;
}
.model-item:last-child { border-bottom: none; }
.model-item:hover { background: var(--bg-surface-raised); }
.model-item.selected { background: var(--accent-subtle); }
.model-item-name {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.model-item-id {
  font-size: .72rem;
  color: var(--text-muted);
}
.model-item-meta {
  display: flex;
  gap: 10px;
  margin-top: 3px;
  font-size: .7rem;
  color: var(--text-muted);
}
.model-item-default {
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
  display: block;
  width: 100%;
  text-align: left;
  font-size: .85rem;
  font-weight: 500;
  color: var(--accent-text);
}
.model-item-default:hover { background: var(--accent-subtle); }

/* ── Chat Layout ────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
}

/* Conversations sidebar */
.conv-sidebar {
  width: 260px;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.conv-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.conv-sidebar-header h3 { font-size: .95rem; font-weight: 600; }
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.conv-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  margin-bottom: 2px;
}
.conv-item:hover { background: var(--bg-surface-raised); }
.conv-item.active { background: var(--accent-subtle); }
.conv-item-title {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item-date {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.chat-empty h3 { font-size: 1.2rem; color: var(--text-primary); margin-top: 16px; margin-bottom: 4px; }
.chat-empty p { font-size: .9rem; max-width: 400px; }

/* Chat header */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-header-info { min-width: 0; }
.chat-header-info h3 {
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-model {
  font-size: .72rem;
  color: var(--text-muted);
}
.chat-header-actions { display: flex; align-items: center; gap: 8px; }

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 85%;
  animation: msgIn .2s ease both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg-user {
  align-self: flex-end;
}
.chat-msg-assistant {
  align-self: flex-start;
}
.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: .9rem;
  line-height: 1.6;
}
.chat-msg-user .chat-msg-bubble {
  background: var(--accent);
  color: var(--text-inverse);
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant .chat-msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.chat-msg-meta {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.chat-msg-user .chat-msg-meta { text-align: right; }

/* PDF attachment in message */
.chat-msg-pdf {
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-msg-pdf-icon {
  width: 36px;
  height: 36px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-msg-pdf-icon svg { width: 20px; height: 20px; color: var(--danger); }
.chat-msg-pdf-info { flex: 1; min-width: 0; }
.chat-msg-pdf-name {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.chat-msg-pdf-size {
  font-size: .72rem;
  color: var(--text-muted);
}
.chat-msg-pdf-actions { display: flex; gap: 6px; }

/* Missing info in chat */
.chat-msg-missing {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  font-size: .85rem;
  color: #92400e;
}

/* Loading message */
.chat-msg-loading .chat-msg-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-msg-loading .spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
  margin: 0;
}

/* Chat input */
.chat-input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: .9rem;
  line-height: 1.5;
  outline: none;
  transition: all var(--transition-fast);
  max-height: 120px;
  font-family: inherit;
}
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.chat-send-btn {
  padding: 10px 14px;
  flex-shrink: 0;
}
.chat-input-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: .72rem;
  color: var(--text-muted);
}
.chat-filename-input {
  width: 200px;
  padding: 4px 8px;
  font-size: .78rem;
  background: transparent;
  border: 1px solid transparent;
}
.chat-filename-input:focus {
  border-color: var(--border);
  background: var(--bg-input);
}

/* Result panel */
.result-panel {
  position: relative;
}
.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.result-empty svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: .4; }
.result-empty p { font-size: .9rem; }

/* Loading */
.generate-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.generate-loading p {
  font-size: .9rem;
  color: var(--text-secondary);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

/* Missing info */
.result-missing {
  padding: 24px;
}
.result-missing-box {
  background: var(--warning-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  gap: 12px;
}
.result-missing-box svg { width: 22px; height: 22px; color: var(--warning); flex-shrink: 0; margin-top: 1px; }
.result-missing-box .missing-text { font-size: .9rem; color: #92400e; line-height: 1.6; }

/* Success */
.result-success { padding: 24px; }
.result-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.result-meta-item {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
}
.result-meta-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-meta-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── PDF Preview Modal ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .25s ease both;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.modal-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
}

/* ── Tables ─────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--bg-surface-raised); }
tbody tr:last-child td { border-bottom: none; }

.td-truncate {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--accent-subtle); color: var(--accent-text); }

/* ── User row ───────────────────────────────────── */
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-cell img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.user-cell-info { line-height: 1.3; }
.user-cell-name { font-weight: 500; color: var(--text-primary); font-size: .85rem; }
.user-cell-email { font-size: .75rem; color: var(--text-muted); }

.actions-cell { display: flex; gap: 6px; }

/* ── Config Form ────────────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.config-grid .form-group-full {
  grid-column: 1 / -1;
}

/* ── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 450px;
  font-size: .88rem;
  animation: toastIn .3s ease both;
}
.toast.toast-exit { animation: toastOut .25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(30px); } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-message { flex: 1; color: var(--text-primary); }

/* ── Empty State ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .35; }
.empty-state p { font-size: .92rem; }

/* ── View transitions ───────────────────────────── */
.view { animation: viewIn .25s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Mobile Toggle ──────────────────────────────── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.mobile-toggle svg { width: 20px; height: 20px; color: var(--text-primary); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 1024px) {
  .generate-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-toggle { display: flex; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header { padding: 20px 20px 0; padding-top: 64px; }
  .page-body { padding: 16px 20px 32px; }
  .form-row { grid-template-columns: 1fr; }
}
