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

* {
  box-sizing: border-box;
}

body {
  background-color: #f8fafc;
  background-image: 
    linear-gradient(#e2e8f0 1px, transparent 1px),
    linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  color: #1e293b;
}

.page-container {
  background-color: #f1f5f9;
  border: 3px solid #1e3a8a;
  width: 98vw;
  max-width: 1600px;
  min-height: 90vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  border-radius: 8px;
}

/* Header Row */
.header-row {
  display: grid;
  grid-template-columns: 280px 1fr auto;
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .header-row {
    grid-template-columns: 1fr;
  }
}

.logo-card {
  background-color: white;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border: 1px solid #cbd5e1;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  cursor: pointer;
}

.logo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(30, 58, 138, 0.15);
  border-color: #1e3a8a;
}

.logo-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.logo-text-group h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-text-group h2 .back-hint {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.logo-text-group p {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: #64748b;
}

.title-card {
  background-color: white;
  border-radius: 6px;
  padding: 16px 22px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  border: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title-card h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  color: #0f172a;
}

.title-card p {
  margin: 5px 0 0 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.4;
}

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

.header-btn {
  background-color: white;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  text-decoration: none;
}

.header-btn:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.header-btn.settings {
  border-color: #3b82f6;
  color: #1d4ed8;
}

.header-btn.settings:hover {
  background-color: #eff6ff;
  border-color: #1d4ed8;
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

/* Main Workspace Grid */
.workspace-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Card Sections */
.expert-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 20px 24px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.expert-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
}

.expert-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.expert-card-step-badge {
  background: #1e3a8a;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* Upload Area */
.upload-drop-zone {
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  padding: 28px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.upload-drop-zone:hover, .upload-drop-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.upload-icon {
  width: 44px;
  height: 44px;
  color: #3b82f6;
  margin-bottom: 10px;
}

.upload-prompt-text {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 6px 0;
}

.upload-hint-text {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

.upload-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.active-file-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}

.active-file-pill svg {
  width: 16px;
  height: 16px;
}

.quick-action-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quick-action-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Stage Selector */
.stage-selector-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.stage-selector-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.stage-select {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: white;
}

/* Prompt Box */
.ai-request-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.ai-request-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 6px;
}

.ai-request-content {
  font-size: 15px;
  font-weight: 600;
  color: #1e3a8a;
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  padding: 10px 14px;
  border-radius: 0 4px 4px 0;
  margin: 0;
}

.optional-notes-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: #1e293b;
  resize: vertical;
  min-height: 60px;
  margin-bottom: 16px;
}

.btn-launch-expert {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
  width: 100%;
}

.btn-launch-expert:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
  background: linear-gradient(135deg, #172554 0%, #1d4ed8 100%);
}

.btn-launch-expert:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Progress Monitor */
.progress-card {
  display: none;
}

.progress-card.active {
  display: block;
}

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

.progress-status-text {
  font-size: 14px;
  font-weight: 600;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-time-text {
  font-size: 13px;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 5px;
  transition: width 0.3s ease;
}

/* Thinking Console */
.thinking-box {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.5;
  white-space: pre-wrap;
  border: 1px solid #1e293b;
}

.thinking-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Results Section */
.results-card {
  display: none;
}

.results-card.active {
  display: block;
}

/* Stat Cards */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-box {
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid transparent;
}

.stat-box.total {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.stat-box.accepted {
  background: #f0fdf4;
  border-color: #86efac;
}

.stat-box.conditional {
  background: #fefce8;
  border-color: #fde047;
}

.stat-box.error {
  background: #fef2f2;
  border-color: #fca5a5;
}

.stat-box.contradiction {
  background: #faf5ff;
  border-color: #d8b4fe;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-box.accepted .stat-label { color: #15803d; }
.stat-box.conditional .stat-label { color: #a16207; }
.stat-box.error .stat-label { color: #b91c1c; }
.stat-box.contradiction .stat-label { color: #7e22ce; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.stat-box.accepted .stat-value { color: #166534; }
.stat-box.conditional .stat-value { color: #854d0e; }
.stat-box.error .stat-value { color: #991b1b; }
.stat-box.contradiction .stat-value { color: #6b21a8; }

/* Filter & Export Toolbar */
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.filter-pills-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  border: 1px solid #cbd5e1;
  background: white;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-pill:hover, .filter-pill.active {
  background: #1e3a8a;
  color: white;
  border-color: #1e3a8a;
}

.search-input {
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  width: 220px;
}

.export-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-btn {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.export-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.export-btn.docx {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
}

.export-btn.docx:hover {
  background: #dbeafe;
}

.export-btn.xlsx {
  border-color: #16a34a;
  color: #15803d;
  background: #f0fdf4;
}

.export-btn.xlsx:hover {
  background: #dcfce7;
}

.export-btn.multiprompt {
  border-color: #8b5cf6;
  color: #6d28d9;
  background: #f5f3ff;
}

.export-btn.multiprompt:hover {
  background: #ede9fe;
  color: #5b21b6;
}

.export-btn.txt {
  border-color: #f59e0b;
  color: #b45309;
  background: #fffbeb;
}

.export-btn.txt:hover {
  background: #fef3c7;
}

/* Interactive Table */
.table-responsive-wrapper {
  overflow-x: auto;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: white;
  max-height: 75vh;
  position: relative;
}

.expert-table {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.expert-table th, .expert-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  vertical-align: top;
  line-height: 1.4;
}

/* Header Styling */
.expert-table thead th {
  background-color: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.expert-table thead tr:nth-child(2) th {
  background-color: #f1f5f9;
  top: 36px;
}

.expert-table thead tr:nth-child(3) th {
  background-color: #f8fafc;
  color: #64748b;
  font-size: 11px;
  top: 72px;
}

/* Cell alignment */
.expert-table td.center {
  text-align: center;
}

.expert-table td.nowrap {
  white-space: nowrap;
}

/* Verdict Badges */
.verdict-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11.5px;
  text-align: center;
  white-space: nowrap;
}

.verdict-badge.accepted {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.verdict-badge.conditional {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.verdict-badge.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.verdict-badge.contradiction {
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
}

/* Sub-row styling */
.expert-table tr.sub-rule-row {
  background-color: #fafafa;
}

.expert-table tr.sub-rule-row td.empty-side {
  background-color: #f8fafc;
  border-top: none;
}

.expert-table tr:hover {
  background-color: #f8fafc;
}

/* Settings Modal */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 31, 58, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.settings-modal {
  background: white;
  border-radius: 12px;
  width: 95%;
  max-width: 1400px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  position: relative;
  border: 1px solid #e2e8f0;
}

.settings-modal h2 {
  margin: 0 0 24px 0;
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

.settings-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: #64748b;
  transition: color 0.2s;
}

.settings-close-btn:hover {
  color: #0f172a;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  padding-bottom: 8px;
}

.settings-panel-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.settings-panel-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #1e3a8a;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 8px;
}

.settings-panel-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.settings-panel-card input,
.settings-panel-card select,
.settings-panel-card textarea {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  background: white;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid #e2e8f0;
  padding-top: 16px;
}

.btn-secondary {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.btn-primary {
  background: #2563eb;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  cursor: pointer;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}
