/* Immigration Petition Agent — Design System */

:root {
  /* Brand */
  --brand: #1a56db;
  --brand-light: #3b82f6;
  --brand-dark: #1e40af;
  --brand-bg: #eff6ff;

  /* Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Status */
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #2563eb;
  --info-bg: #eff6ff;

  /* Probability colors */
  --prob-high: #059669;
  --prob-medium: #d97706;
  --prob-low: #dc2626;

  /* Layout */
  --sidebar-width: 280px;
  --chat-width: 380px;
  --header-height: 60px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Inter', Georgia, serif;
  --font-mono: 'Courier New', monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  font-size: 14px;
}

/* --------------- Layout --------------- */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: white;
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 8px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.sidebar-logo .subtitle {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.sidebar-nav a.active {
  background: rgba(59,130,246,0.15);
  color: var(--brand-light);
  border-right: 3px solid var(--brand-light);
}

.sidebar-nav .section-label {
  padding: 16px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  font-weight: 600;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-footer {
  margin-top: auto;
  padding: 16px 32px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50, #f9fafb);
}

.app-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
}

.app-footer-brand {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
}

.app-footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-footer-contact {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
}

.app-footer-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--gray-400);
  font-size: 15px;
  transition: all 0.15s;
  text-decoration: none;
}

.app-footer-links a:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.page-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-progress-ring {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.header-progress-ring svg {
  width: 32px;
  height: 32px;
}

.header-progress-ring .pct-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
}

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

/* --------------- Workspace Layout --------------- */

.workspace-layout {
  display: grid;
  grid-template-columns: 1fr var(--chat-width);
  gap: 0;
  min-height: calc(100vh - var(--header-height));
}

.workspace-main {
  padding: 24px 32px;
  padding-right: 40px;
  overflow-y: auto;
}

.workspace-chat {
  border-left: 1px solid var(--gray-200);
  background: white;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow: hidden;
}

/* --------------- Tabs --------------- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  background: white;
  padding: 0 32px;
}

.tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--gray-700);
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-content {
  display: none;
}

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

/* --------------- Cards --------------- */

.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}

.card-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* --------------- Probability Meter --------------- */

.probability-meter {
  text-align: center;
  padding: 24px;
}

.probability-value {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.probability-value.high { color: var(--prob-high); }
.probability-value.medium { color: var(--prob-medium); }
.probability-value.low { color: var(--prob-low); }

.probability-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 8px;
}

.probability-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.probability-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.probability-fill.high { background: var(--prob-high); }
.probability-fill.medium { background: var(--prob-medium); }
.probability-fill.low { background: var(--prob-low); }

/* --------------- Score Cards --------------- */

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.score-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.score-card .score-value {
  font-size: 28px;
  font-weight: 700;
}

.score-card .score-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* --------------- Badges --------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.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(--info-bg); color: var(--info); }

.badge-category {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* --------------- Buttons --------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-group {
  display: flex;
  gap: 8px;
}

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

/* --------------- Forms --------------- */

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

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

.form-help {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.list-entry {
  padding: 12px;
  margin-bottom: 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.list-entry:last-child { margin-bottom: 12px; }

/* --------------- Chat --------------- */

#chat-mode-general {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 0;
}

.chat-message {
  margin-bottom: 16px;
  max-width: 100%;
}

.chat-message .role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.chat-message.user .role { color: var(--brand); }
.chat-message.assistant .role { color: var(--gray-500); }

.chat-message .content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-700);
}

.chat-message .content p { margin-bottom: 8px; }
.chat-message .content ul, .chat-message .content ol { padding-left: 20px; margin-bottom: 8px; }
.chat-message .content code { background: var(--gray-100); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.chat-message .content strong { color: var(--gray-900); }

.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  resize: none;
  min-height: 42px;
  max-height: 120px;
}

.chat-input:focus {
  outline: none;
  border-color: var(--brand);
}

.chat-send-btn {
  padding: 10px 16px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.chat-send-btn:hover { background: var(--brand-dark); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-feedback-btn {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.chat-feedback-btn:hover { color: var(--gray-700); border-color: var(--gray-300); }
.chat-feedback-btn:disabled { cursor: default; }
.chat-feedback-btn:disabled:hover { color: var(--gray-400); border-color: var(--gray-200); }

/* --------------- Checklist --------------- */

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}

.checklist-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.checklist-icon.pass { background: var(--success-bg); color: var(--success); }
.checklist-icon.fail { background: var(--danger-bg); color: var(--danger); }

/* --------------- Evidence Map --------------- */

.evidence-item {
  padding: 10px 14px;
  background: var(--gray-50);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  border-left: 3px solid var(--gray-300);
}

.evidence-item.strong { border-left-color: var(--success); }
.evidence-item.moderate { border-left-color: var(--warning); }
.evidence-item.weak { border-left-color: var(--danger); }

/* --------------- Section Editor --------------- */

.section-editor {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.section-editor.has-draft-issues {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.section-editor-header {
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-editor.has-draft-issues .section-editor-header {
  background: #fffbeb;
}

.section-editor-header h4 {
  font-size: 14px;
  font-weight: 600;
}

.section-issue-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff3cd;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-editor-warning {
  display: none;
  gap: 8px;
  align-items: flex-start;
  padding: 12px 16px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
}

.section-editor-warning.visible {
  display: flex;
}

.section-editor-body {
  padding: 16px;
  min-height: 200px;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.section-editor-body:empty::before {
  content: 'Section not yet drafted. Click "Generate" to draft this section.';
  color: var(--gray-400);
  font-style: italic;
  font-family: var(--font-sans);
}

.draft-issues-banner,
.compile-issue-banner {
  display: none;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.draft-issues-banner.visible,
.compile-issue-banner.visible {
  display: flex;
}

.draft-issues-banner {
  margin-bottom: 16px;
}

.compile-issue-banner {
  margin-top: 12px;
}

.draft-issues-content {
  flex: 1;
}

.draft-issues-summary {
  font-size: 13px;
  margin-top: 2px;
}

.draft-issues-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.draft-issues-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(146, 64, 14, 0.08);
  color: #92400e;
  font-size: 12px;
  font-weight: 600;
}

.draft-placeholder-token {
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 700;
}

.draft-leak-token {
  background: #ffedd5;
  color: #9a3412;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 700;
}

/* --------------- Gap Items --------------- */

.gap-item {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.gap-item.critical { background: #fef2f2; border-left: 3px solid var(--danger); }
.gap-item.high { background: #fffbeb; border-left: 3px solid var(--warning); }
.gap-item.moderate { background: #eff6ff; border-left: 3px solid var(--info); }

.gap-item .gap-severity {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.gap-item.critical .gap-severity { color: var(--danger); }
.gap-item.high .gap-severity { color: var(--warning); }
.gap-item.moderate .gap-severity { color: var(--info); }

/* --------------- Dashboard --------------- */

.petition-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.petition-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  cursor: pointer;
  display: block;
}

.petition-card:hover {
  border-color: var(--brand-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.petition-card .petition-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.petition-card .petition-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-500);
}

/* --------------- New Petition Modal --------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.category-option {
  padding: 16px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.category-option:hover {
  border-color: var(--brand-light);
  background: var(--brand-bg);
}

.category-option.selected {
  border-color: var(--brand);
  background: var(--brand-bg);
}

.category-option h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.category-option p {
  font-size: 12px;
  color: var(--gray-500);
}

/* --------------- Utility --------------- */

.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.hidden { display: none !important; }

/* --------------- Loading --------------- */

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

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

/* --------------- Profile Page --------------- */

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.profile-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.profile-field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 2px;
}

.profile-field-value {
  font-size: 14px;
  color: var(--gray-800);
  word-break: break-word;
}

.profile-stat-block {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.profile-stat-block .stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-800);
}

.profile-stat-block .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.profile-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-700);
  margin: 4px 4px 4px 0;
}

.profile-stat-pill .pill-count {
  background: var(--gray-200);
  color: var(--gray-700);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.profile-academic-section {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.profile-academic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: var(--gray-50);
  transition: background 0.15s;
}

.profile-academic-header:hover {
  background: var(--gray-100);
}

.profile-academic-header .section-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.profile-academic-header .section-count {
  font-size: 12px;
  color: var(--gray-500);
}

.profile-academic-chevron {
  transition: transform 0.2s;
  color: var(--gray-400);
  font-size: 12px;
}

.profile-academic-chevron.rotated {
  transform: rotate(180deg);
}

.profile-academic-body {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  font-size: 13px;
}

.profile-academic-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
}

.profile-academic-item:last-child {
  border-bottom: none;
}

/* --------------- Responsive --------------- */

@media (max-width: 800px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .profile-field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }
  .workspace-chat {
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--chat-width);
    transform: translateX(100%);
    transition: transform 0.3s;
    z-index: 90;
  }
  .workspace-chat.open {
    transform: translateX(0);
  }
}

/* Workstream Cards */
.workstream-cards {
  display: flex;
  gap: 10px;
  padding: 16px 16px 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.ws-card {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid var(--gray-200);
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.ws-card:hover {
  border-color: var(--brand);
  background: #f8faff;
}
.ws-card.ws-active-tab {
  border-color: var(--brand);
  background: #eef4ff;
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.15);
}
.ws-card.ws-active-tab .ws-icon { color: var(--brand); }
.ws-card.ws-active-tab .ws-label { color: var(--brand); }
.ws-card.ws-active-tab .ws-status-badge { color: var(--brand); }
/* Active card bottom indicator */
.ws-card.ws-active-tab::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid var(--brand);
}
.ws-card.ws-complete {
  border-color: var(--success);
  background: #f0fdf4;
}
.ws-card.ws-complete:hover {
  border-color: var(--brand);
  background: #f8faff;
}
.ws-card.ws-complete.ws-active-tab {
  border-color: var(--brand);
  background: #eef4ff;
}
.ws-card.ws-blocked {
  opacity: 0.55;
  cursor: default;
}
.ws-card.ws-blocked:hover {
  border-color: var(--gray-200);
  background: white;
}
.ws-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.ws-icon {
  font-size: 14px;
  color: var(--gray-400);
}
.ws-complete .ws-icon { color: var(--success); }
.ws-active .ws-icon { color: var(--brand); }
.ws-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}
.ws-card-progress {
  margin-bottom: 8px;
}
.ws-progress-bar {
  height: 5px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}
.ws-progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width 0.3s;
}
.ws-complete .ws-progress-fill { background: var(--success); }
.ws-card-status {
  font-size: 12px;
}
.ws-status-badge {
  font-weight: 600;
}
.ws-badge-complete { color: var(--success); }
.ws-badge-progress { color: var(--brand); }
.ws-badge-blocked { color: var(--gray-400); }
.ws-badge-ready { color: var(--brand); }

/* -----------------------------------------------------------------------
   Discovery Mode — AI Advisor Chat (within unified chat panel)
   ----------------------------------------------------------------------- */

/* Discovery mode content within the unified chat panel */
#chat-mode-discovery {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Discovery mode header variant */
.chat-header-discovery {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-mode-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary, #666);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}
.chat-mode-back:hover {
  background: var(--gray-100, #f5f5f5);
  color: var(--text-primary, #333);
}
.discovery-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.discovery-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.discovery-msg.assistant {
  background: var(--accent-light, #e8f0fe);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.discovery-msg.user {
  background: var(--primary-color, #1a73e8);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.discovery-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  flex-shrink: 0;
}
.discovery-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
}
.discovery-input-area button {
  padding: 8px 16px;
  background: var(--primary-color, #1a73e8);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}
.discovery-input-area button:hover { opacity: 0.9; }
.discovery-input-area button:disabled { opacity: 0.5; cursor: not-allowed; }
.discovery-strength-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.strength-strong { background: #c6efce; color: #006100; }
.strength-moderate { background: #ffeb9c; color: #9c5700; }
.strength-weak { background: #ffc7ce; color: #9c0006; }
.strength-unknown { background: #eee; color: #666; }
.strength-not_applicable { background: #eee; color: #999; }
.discovery-field-suggestions {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  max-height: 150px;
  overflow-y: auto;
}
.suggestions-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #666);
  margin-bottom: 8px;
}
.field-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}
.field-suggestion button {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  background: var(--primary-color, #1a73e8);
  color: white;
  border: none;
}
.discovery-trigger {
  font-size: 11px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---- Job Progress Indicator (Phase 1) ---- */

.job-progress {
  padding: 14px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  margin-bottom: 16px;
}

.job-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.job-progress-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

.job-progress-status {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 8px;
  border-radius: 4px;
}

.job-progress-status.queued {
  color: var(--gray-500);
  background: var(--gray-100);
}

.job-progress-status.running {
  color: var(--brand);
  background: var(--info-bg);
}

.job-progress-status.completed {
  color: var(--success);
  background: var(--success-bg);
}

.job-progress-status.failed {
  color: var(--danger);
  background: var(--danger-bg);
}

.job-progress-bar {
  height: 5px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.job-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  background: var(--brand);
}

.job-progress-fill.completed {
  background: var(--success);
}

.job-progress-fill.failed {
  background: var(--danger);
}

.job-progress-detail {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray-600);
}

.job-progress-detail.reconnecting {
  color: var(--gray-400);
  font-style: italic;
}

.job-progress-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ---- Consistency Check (Phase 1) ---- */

.consistency-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.consistency-trigger .badge-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
  margin-left: 4px;
}

.consistency-panel {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: white;
  margin-bottom: 16px;
}

.consistency-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.consistency-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
}

.consistency-summary {
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-600);
}

.consistency-timestamp {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-400);
}

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

.consistency-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  align-items: flex-start;
}

.consistency-item:last-child {
  border-bottom: none;
}

.consistency-item.dismissed {
  opacity: 0.5;
}

.consistency-item.dismissed .consistency-desc {
  text-decoration: line-through;
}

.consistency-severity {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.consistency-severity.critical {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
}

.consistency-severity.warning {
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid #fde68a;
}

.consistency-severity.info {
  color: var(--info);
  background: var(--info-bg);
  border: 1px solid #bfdbfe;
}

.consistency-severity.dismissed-badge {
  color: var(--gray-400);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
}

.consistency-body {
  flex: 1;
  min-width: 0;
}

.consistency-desc {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--gray-900);
}

.consistency-sources {
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-500);
  margin-top: 4px;
}

.consistency-actions {
  flex-shrink: 0;
}

.consistency-actions .dismiss-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}

.consistency-actions .dismiss-btn:hover {
  color: var(--gray-700);
  text-decoration: underline;
}

.consistency-actions .dismissed-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--gray-400);
  font-style: italic;
}

/* Consistency empty state */
.consistency-empty {
  padding: 24px 16px;
  text-align: center;
}

.consistency-empty h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.consistency-empty p {
  font-size: 14px;
  color: var(--gray-500);
  margin: 0;
}

/* Export warning banner for consistency issues */
.export-warning-banner {
  display: none;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #fde68a;
  background: var(--warning-bg);
  color: #92400e;
  margin-bottom: 16px;
}

.export-warning-banner.visible {
  display: flex;
}

.export-warning-banner .export-warning-title {
  font-size: 14px;
  font-weight: 600;
}

.export-warning-banner .export-warning-body {
  font-size: 14px;
  font-weight: 400;
  margin-top: 4px;
}

.export-warning-banner .export-warning-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.export-warning-banner .btn-override {
  font-size: 12px;
  padding: 4px 8px;
}

/* =========================================================
   Claim Confidence Markers (Phase 2 REVW-07)
   ========================================================= */

/* Base claim marker — subtle underline, click/hover for details */
.claim-marker {
  border-bottom: 2px solid transparent;
  cursor: pointer;
  position: relative;
  display: inline;
}

/* 4-tier grounding status colors */
.claim-marker--grounded     { border-bottom-color: #22c55e; }  /* green   */
.claim-marker--inferred     { border-bottom-color: #eab308; }  /* yellow  */
.claim-marker--missing_support { border-bottom-color: #f97316; } /* orange  */
.claim-marker--contradicted { border-bottom-color: #ef4444; }  /* red     */

/* Tooltip shown on hover */
.claim-marker:hover .claim-marker-tooltip { display: block; }
.claim-marker-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  background: #1f2937;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
}

/* Toggle — hide all markers when parent has this class */
.claim-markers-hidden .claim-marker { border-bottom-color: transparent !important; }

/* Confidence badge — inline percentage + tier label */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}
.confidence-badge--high   { background: #dcfce7; color: #166534; }  /* >=80%  */
.confidence-badge--medium { background: #fef9c3; color: #854d0e; }  /* 50-79% */
.confidence-badge--low    { background: #fee2e2; color: #991b1b; }  /* <50%   */

/* Score history panel */
.score-history-panel {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}
.score-history-entry {
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.8rem;
}
.score-history-entry:last-child { border-bottom: none; }
.score-delta--positive { color: #16a34a; font-weight: 600; }
.score-delta--negative { color: #dc2626; font-weight: 600; }



/* Approval dashboard panel (Phase 2 REVW-10) */
.approval-dashboard { padding: 12px; }
.approval-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #e5e7eb; }
.approval-row:last-child { border-bottom: none; }
.approval-status--draft { color: #6b7280; }
.approval-status--needs_approval { color: #d97706; }
.approval-status--approved { color: #16a34a; }
.approval-status--approved_locked { color: #15803d; font-weight: 700; }
.approval-status--rejected { color: #dc2626; }
.approval-status--needs_revision { color: #b45309; }
.approval-unresolved-badge { background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 8px; font-size: 0.7rem; margin-left: 6px; }

/* Phase 4: Mobile Upload (Plan 03) */
.spinner-sm { width:16px; height:16px; border:2px solid var(--gray-200); border-top-color:var(--brand); border-radius:50%; animation:spin 0.6s linear infinite; display:inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
#upload-section label.btn { padding: 10px 20px; }
@media (max-width: 800px) {
  #upload-section label.btn { width: 100%; text-align: center; justify-content: center; }
  #pdf-pages { justify-content: center; }
}

/* Phase 4: Client Dashboard (Plan 02) */
.client-petition-card { transition: box-shadow 0.15s; }
.client-petition-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.client-progress-bar { /* container for step progress bar */ }
.client-nudge-banner { font-size: 13px; line-height: 1.4; }
.client-action-item:hover { background: var(--gray-50, #f8f9fa); border-radius: 4px; }

@media (max-width: 800px) {
  .client-nudge-banner { flex-direction: column; gap: 8px; }
  .client-nudge-banner .btn { width: 100%; }
}
