/* ===== Reset + base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a202c;
  background: #f7fafc;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; width: 100%; }

a { color: #2b6cb0; text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace; }
code { background: #edf2f7; padding: 1px 6px; border-radius: 3px; font-size: 0.92em; }

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
  color: white;
  padding: 20px 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
header .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: -0.3px; }
.brand .subtitle { font-size: 12px; color: #bee3f8; font-weight: 500; }

nav { display: flex; gap: 8px; }
.tab-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.tab-btn:hover { background: rgba(255,255,255,0.2); }
.tab-btn.active { background: white; color: #1a365d; border-color: white; }

/* ===== Main ===== */
main { flex: 1; padding: 32px 0; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.intro { margin-bottom: 24px; max-width: 920px; }
.intro h2 { margin: 0 0 8px; font-size: 22px; color: #1a365d; }
.intro p { margin: 0; color: #4a5568; }

/* ===== Two-column generator layout ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 560px;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.pane {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f7fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pane-header h3 { margin: 0; font-size: 15px; color: #2d3748; }
.pane-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

#tariff-input {
  flex: 1;
  width: 100%;
  padding: 12px 16px;
  border: none;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  resize: none;
  outline: none;
  background: #fdfdfd;
  line-height: 1.5;
}

.pane-footer {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f7fafc;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.output-pane {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  max-height: 720px;
}

.empty-state { text-align: center; color: #718096; padding: 40px 20px; }
.empty-state p { margin: 8px 0; }
.empty-state .hint { font-size: 13px; color: #a0aec0; }

/* ===== Buttons ===== */
.btn-primary, .btn-secondary {
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary { background: #2b6cb0; color: white; }
.btn-primary:hover { background: #2c5282; }
.btn-primary:disabled { background: #a0aec0; cursor: not-allowed; }

.btn-secondary { background: white; color: #2d3748; border: 1px solid #cbd5e0; }
.btn-secondary:hover { background: #edf2f7; }

/* ===== Result cards ===== */
.result-summary {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid;
}
.result-summary.success { background: #f0fff4; border-color: #9ae6b4; color: #22543d; }
.result-summary.error { background: #fff5f5; border-color: #fc8181; color: #742a2a; }
.result-summary.warning { background: #fffaf0; border-color: #f6ad55; color: #744210; }

.result-summary h4 { margin: 0 0 8px; font-size: 15px; }
.result-summary .meta { font-size: 12px; display: flex; gap: 16px; flex-wrap: wrap; }
.result-summary .meta > span { }

.issue-list { margin: 12px 0 0; padding-left: 20px; font-size: 13px; }
.issue-list li { margin-bottom: 4px; }
.issue-list code { font-size: 11px; background: rgba(0,0,0,0.06); }

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: white;
}
.file-list li:last-child { border-bottom: none; }
.file-list li:hover { background: #f7fafc; }
.file-name { font-family: "SF Mono", Menlo, monospace; font-size: 12px; color: #2d3748; }
.file-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-right: 8px;
}
.file-badge.policy { background: #ebf8ff; color: #2c5282; }
.file-badge.program { background: #faf5ff; color: #553c9a; }
.file-badge.valid { background: #f0fff4; color: #22543d; }
.file-badge.invalid { background: #fff5f5; color: #742a2a; }

.file-actions { display: flex; gap: 6px; align-items: center; }
.file-actions a,
.file-actions button {
  padding: 4px 10px;
  background: #edf2f7;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
  color: #2d3748;
  font-family: inherit;
  cursor: pointer;
}
.file-actions a:hover,
.file-actions button:hover { background: #e2e8f0; }
.file-actions .btn-view-primary { background: #2b6cb0; color: white; font-weight: 500; }
.file-actions .btn-view-primary:hover { background: #2c5282; }

.section-heading { margin: 20px 0 10px; font-size: 14px; font-weight: 600; color: #2d3748; }

/* ===== Sources tab ===== */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.source-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.source-card h4 { margin: 0; font-size: 16px; color: #1a365d; }
.source-card .source-meta { font-size: 12px; color: #718096; }
.source-card .source-meta div { margin-bottom: 2px; }
.source-card .source-note { font-size: 11px; color: #718096; background: #f7fafc; padding: 8px; border-radius: 4px; border-left: 3px solid #4299e1; }
.source-card .source-links { display: flex; flex-wrap: wrap; gap: 6px; }
.source-card .source-links a {
  padding: 6px 10px;
  background: #edf2f7;
  border-radius: 4px;
  font-size: 11px;
  color: #2d3748;
  font-weight: 500;
}
.source-card .source-links a:hover { background: #e2e8f0; text-decoration: none; }
.source-card .source-links a.primary { background: #2b6cb0; color: white; }
.source-card .source-links a.primary:hover { background: #2c5282; }

.panel {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}
.panel h3 { margin: 0 0 8px; font-size: 16px; color: #1a365d; }
.panel .hint { margin: 0 0 16px; font-size: 13px; color: #718096; }

.pdf-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pdf-card .pdf-name { font-size: 13px; font-weight: 600; color: #2d3748; word-break: break-all; }
.pdf-card .pdf-size { font-size: 11px; color: #718096; }
.pdf-card .pdf-links { display: flex; gap: 6px; flex-wrap: wrap; }
.pdf-card .pdf-links a {
  padding: 6px 10px;
  background: #edf2f7;
  border-radius: 4px;
  font-size: 11px;
  color: #2d3748;
  font-weight: 500;
}
.pdf-card .pdf-links a:hover { background: #e2e8f0; text-decoration: none; }
.pdf-card .pdf-links a.primary { background: #dc2626; color: white; }
.pdf-card .pdf-links a.primary:hover { background: #b91c1c; }

.sample-select {
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  background: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #2d3748;
  cursor: pointer;
  min-width: 200px;
  transition: background 0.15s;
}
.sample-select:hover { background: #edf2f7; }
.sample-select:focus { outline: 2px solid #2b6cb0; outline-offset: 1px; }

/* ===== Generator console ===== */
.generator-summary {
  padding: 0 16px;
}
.generator-summary:empty { padding: 0; }
.generator-actions {
  justify-content: center;
}

.status-pill {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  display: none;
}
.status-pill.running { display: inline-block; background: #fef3c7; color: #744210; }
.status-pill.passed { display: inline-block; background: #c6f6d5; color: #22543d; }
.status-pill.failed { display: inline-block; background: #fed7d7; color: #742a2a; }

.console-output {
  background: #1a202c;
  color: #e2e8f0;
  padding: 16px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  margin: 0;
  flex: 1;
  min-height: 300px;
}
/* Inside a pane (flex column) the console can expand */
.pane .console-output { flex: 1; }
.console-output .log-stderr { color: #fca5a5; }
.console-output .log-stdout { color: #e2e8f0; }
.console-output .log-info   { color: #cbd5e0; }
.console-output .log-system { color: #93c5fd; font-weight: 600; }
.console-output .log-pass   { color: #86efac; }
.console-output .log-fail   { color: #f87171; }

/* ===== Modal (JSON viewer) ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal-dialog {
  background: white;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 1100px;
  height: 86vh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
  color: white;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 8px;
  border-radius: 4px;
}
.modal-close:hover { background: rgba(255,255,255,0.15); }

.modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}
@media (max-width: 720px) {
  .modal-body { grid-template-columns: 1fr; grid-template-rows: 200px 1fr; }
}

.modal-sidebar {
  border-right: 1px solid #e2e8f0;
  background: #f7fafc;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-sidebar-header {
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #718096;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  background: white;
}

.modal-file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.modal-file-list li {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.modal-file-list li:hover { background: #edf2f7; }
.modal-file-list li.active { background: #ebf8ff; border-left: 3px solid #2b6cb0; padding-left: 11px; }
.modal-file-list li.active .modal-file-name { color: #1a365d; font-weight: 600; }
.modal-file-name {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #2d3748;
  word-break: break-all;
}

.modal-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-viewer-header {
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-viewer-name {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #2d3748;
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.modal-viewer-actions { display: flex; gap: 6px; }
.modal-viewer-actions a,
.modal-viewer-actions button {
  padding: 5px 10px;
  background: #edf2f7;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  color: #2d3748;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-viewer-actions a:hover,
.modal-viewer-actions button:hover { background: #e2e8f0; text-decoration: none; }
.modal-viewer-actions a.primary { background: #2b6cb0; color: white; }
.modal-viewer-actions a.primary:hover { background: #2c5282; }
.modal-viewer-actions button.copied { background: #48bb78; color: white; }

.modal-viewer-body {
  flex: 1;
  margin: 0;
  padding: 20px;
  background: #1a202c;
  color: #e2e8f0;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre;
}
.modal-viewer-body.loading { color: #a0aec0; font-style: italic; }
.modal-viewer-body.error { color: #fca5a5; }

/* Simplified source-card actions now */
.source-card .source-links button {
  padding: 6px 10px;
  background: #edf2f7;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  color: #2d3748;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.source-card .source-links button:hover { background: #e2e8f0; }
.source-card .source-links button.primary { background: #2b6cb0; color: white; }
.source-card .source-links button.primary:hover { background: #2c5282; }

.source-card .count-badge {
  display: inline-block;
  background: #2b6cb0;
  color: white;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

/* ===== Footer ===== */
footer {
  background: #1a202c;
  color: #a0aec0;
  padding: 16px 0;
  font-size: 12px;
  margin-top: 40px;
}
footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer a { color: #bee3f8; }
