/* ============================================
   ECONOMY GENERATOR - STYLES
   ============================================ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  line-height: 1.5;
  padding: 1rem;
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================
   NAVIGATION
   ============================================ */
.micras-tool-nav {
  background: #293241;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 40px;
  font-size: 0.85rem;
  gap: 0.5rem;
  position: relative;
  z-index: 9999;
  margin: -1rem -1rem 1rem -1rem;
}

.micras-tool-nav a {
  color: #ffffff;
  text-decoration: none;
  transition: color 0.2s;
}

.micras-tool-nav a:hover {
  text-decoration: underline;
}

.micras-tool-nav .micras-tool-nav-sep {
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0.25rem;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #1e293b;
  color: white;
  padding: 0.5rem 1rem;
  z-index: 10000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   HEADER
   ============================================ */
.header {
  background: linear-gradient(to right, #1e293b, #334155);
  color: white;
  padding: 1.5rem;
  border-radius: 0.5rem 0.5rem 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: bold;
}

.header p {
  color: #cbd5e1;
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.flex-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.reset-btn {
  background: transparent;
  border: 1px solid #94a3b8;
  color: #cbd5e1;
  padding: 0.4rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.reset-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: #e2e8f0;
  color: white;
}

/* ============================================
   INTRO BOX
   ============================================ */
.intro-box {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 0 0 0.5rem 0.5rem;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: #3730a3;
  margin-bottom: 0;
}

.intro-box a {
  color: #4338ca;
}

/* ============================================
   INPUTS PANEL — compact across top
   ============================================ */
.inputs-panel {
  margin-top: 1rem;
}

.inputs-panel-header {
  margin-bottom: 0.75rem;
}

.inputs-panel-header .section-header {
  margin-bottom: 0.75rem;
}

.preset-row {
  margin-bottom: 0;
}

.name-inputs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem 1rem;
  margin-bottom: 0.75rem;
}

.name-inputs-row .input-group {
  margin-bottom: 0;
}

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem 1rem;
}

@media (min-width: 900px) {
  .inputs-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.inputs-grid .input-group {
  margin-bottom: 0;
}

/* ============================================
   SECTIONS & INPUT GROUPS
   ============================================ */
.section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.25rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

.section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.input-group {
  margin-bottom: 0.75rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.label-row label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
}

input[type="text"],
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  color: #1f2937;
  background: white;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-error {
  border-color: #ef4444 !important;
}

.input-error-msg {
  color: #dc2626;
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

/* ============================================
   TOOLTIPS
   ============================================ */
.tooltip-trigger {
  background: #e5e7eb;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #6b7280;
  cursor: help;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tooltip-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: -8px;
  background: #1f2937;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  width: 250px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
}

.tooltip-content.tooltip-below {
  bottom: auto;
  top: calc(100% + 8px);
}

.tooltip-trigger:hover .tooltip-content,
.tooltip-trigger:focus .tooltip-content {
  display: block;
}

/* ============================================
   BADGES (plausibility indicators)
   ============================================ */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-small {
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
}

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

.badge-yellow {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

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

.badge-neutral {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #d1d5db;
}

/* ============================================
   RESULTS BANNER — GDP + Overall Badge
   ============================================ */
.results-banner {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.results-banner .result-highlight {
  flex: 1;
  margin-bottom: 0;
}

.results-banner .overall-highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.results-banner .overall-highlight .badge {
  font-size: 1rem;
  padding: 0.35rem 1.25rem;
  margin-top: 0.25rem;
}

.result-highlight {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid #c7d2fe;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}

.result-highlight-label {
  display: block;
  font-size: 0.8rem;
  color: #4338ca;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.result-highlight-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e1b4b;
}

/* ============================================
   RESULTS GRID — 2-column on desktop
   ============================================ */
.results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================
   OUTPUT CARDS
   ============================================ */
.output-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  background: white;
}

.output-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.875rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.output-card-header h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.output-card-body {
  padding: 0.625rem 0.875rem;
}

.output-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.85rem;
}

.output-row + .output-row {
  border-top: 1px solid #f3f4f6;
}

.output-label {
  color: #6b7280;
}

.output-value {
  font-weight: 600;
  color: #1f2937;
  text-align: right;
}

/* Sub-sections (expandable detail) */
.output-subsection {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #e5e7eb;
}

.output-subheading {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.375rem;
}

.output-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 0;
  font-size: 0.8rem;
  color: #6b7280;
}

.output-sub-row .output-value {
  font-weight: 500;
  color: #4b5563;
}

/* ============================================
   EXPORT ROW
   ============================================ */
.export-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.export-btn {
  background: white;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.export-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

/* Override inputs */
.override-toggle-row {
  padding: 0.25rem 0 0.4rem 0;
  font-size: 0.75rem;
}

.override-toggle-label {
  cursor: pointer;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.override-toggle-label input[type="checkbox"] {
  margin: 0;
}

.override-input {
  width: 4rem;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  text-align: right;
  margin-left: 0.5rem;
}

.override-input:focus {
  outline: 2px solid #3b82f6;
  border-color: #3b82f6;
}

.output-value.overridden {
  color: #1e40af;
  font-weight: 700;
}

.override-hint {
  font-size: 0.7rem;
  color: #6b7280;
  padding: 0.15rem 0 0.25rem 0;
  font-style: italic;
}

.override-hint.override-error {
  color: #dc2626;
}

.export-btn-accent {
  background: #1e40af;
  color: white;
  border-color: #1e40af;
}

.export-btn-accent:hover {
  background: #1e3a8a;
  border-color: #1e3a8a;
}

.export-btn-save {
  background: #059669;
  color: white;
  border-color: #059669;
}

.export-btn-save:hover {
  background: #047857;
  border-color: #047857;
}

.profile-manage-row {
  text-align: right;
  margin-top: 0.25rem;
}

.manage-link {
  font-size: 0.8rem;
  color: #6b7280;
}

/* ============================================
   DIALOG OVERLAYS
   ============================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog-overlay[hidden] {
  display: none;
}

.dialog-box {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.dialog-box-wide {
  max-width: 480px;
}

.dialog-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.dialog-label {
  display: block;
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.25rem;
}

.dialog-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.dialog-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.dialog-btn {
  padding: 0.4rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid #d1d5db;
}

.dialog-btn-cancel {
  background: white;
  color: #374151;
}

.dialog-btn-cancel:hover {
  background: #f3f4f6;
}

.dialog-btn-confirm {
  background: #059669;
  color: white;
  border-color: #059669;
}

.dialog-btn-confirm:hover {
  background: #047857;
}

/* Manage profiles list */
.manage-list {
  max-height: 300px;
  overflow-y: auto;
}

.manage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

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

.manage-name {
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manage-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.manage-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  background: white;
  cursor: pointer;
}

.manage-btn:hover {
  background: #f3f4f6;
}

.manage-btn-danger {
  color: #dc2626;
  border-color: #fca5a5;
}

.manage-btn-danger:hover {
  background: #fef2f2;
}

.manage-empty {
  padding: 1rem 0;
  color: #9ca3af;
  text-align: center;
  font-size: 0.9rem;
}

/* ============================================
   COMPARISON MODE
   ============================================ */
.compare-hint {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #1e40af;
}

.comparison-panel {
  margin-bottom: 1rem;
  border: 2px solid #3b82f6;
  border-radius: 0.5rem;
  overflow: hidden;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.comparison-table th {
  background: #eff6ff;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid #bfdbfe;
}

.comparison-table td {
  padding: 0.375rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table tr:hover {
  background: #f9fafb;
}

.compare-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compare-delta {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.compare-better {
  color: #166534;
}

.compare-worse {
  color: #991b1b;
}

.compare-active {
  background: #3b82f6 !important;
  color: white !important;
  border-color: #3b82f6 !important;
}

/* ============================================
   ADVANCED OVERRIDES PANEL
   ============================================ */
.advanced-overrides-panel {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  margin-top: 0.75rem;
}

.advanced-overrides-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.625rem;
}

.advanced-overrides-header h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: #854d0e;
}

.advanced-overrides-hint {
  font-size: 0.72rem;
  color: #a16207;
  font-style: italic;
}

.advanced-overrides-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

@media (max-width: 767px) {
  .advanced-overrides-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.adv-override-group label {
  display: block;
  font-size: 0.72rem;
  color: #6b7280;
  margin-bottom: 0.15rem;
}

.adv-override-group .override-input {
  width: 100%;
  margin-left: 0;
}

/* Inline overrides (inside output rows) */
.inline-override {
  width: 4.5rem;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  text-align: right;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.inline-override:focus {
  outline: 2px solid #3b82f6;
  border-color: #3b82f6;
}

/* Active override button state */
.reset-btn.override-active {
  background: rgba(251, 191, 36, 0.3);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* ============================================
   METHODOLOGY SECTION
   ============================================ */
.methodology-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 2rem;
}

.methodology-section summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
  font-size: 0.95rem;
}

.methodology-section summary:hover {
  background: #f9fafb;
}

.methodology-content {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.88rem;
  color: #4b5563;
  line-height: 1.6;
}

.methodology-content h4 {
  color: #1f2937;
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
}

.methodology-content h4:first-child {
  margin-top: 0;
}

.methodology-content h5 {
  color: #374151;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.9rem;
}

.methodology-content p {
  margin-bottom: 0.5rem;
}

.methodology-content ul {
  margin: 0.25rem 0 0.75rem 1.5rem;
}

.methodology-content li {
  margin-bottom: 0.25rem;
}

/* ============================================
   WARNING BOXES
   ============================================ */
.warning-box {
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.warning-yellow {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #fde047;
}

.warning-red {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.warning-green {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.preset-warning {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #93c5fd;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.warning-main {
  display: block;
}

.warning-context {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.85;
  font-style: italic;
}

/* ============================================
   VALIDATION MESSAGES
   ============================================ */
.validation-msg {
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 0.5rem;
  transition: opacity 0.2s;
}

.validation-msg:empty {
  display: none;
}

/* ============================================
   COPY FEEDBACK
   ============================================ */
.copy-feedback {
  color: #16a34a;
  font-size: 0.8rem;
  font-weight: 500;
}

.copy-feedback-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #166534;
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 0.375rem;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.copy-feedback-toast.visible {
  opacity: 1;
}

.copy-feedback-toast.toast-error {
  background: #991b1b;
}

/* ============================================
   TOOLTIP — TOUCH SUPPORT
   ============================================ */
.tooltip-trigger.tooltip-open .tooltip-content {
  display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 767px) {
  body {
    padding: 0.5rem;
  }

  .micras-tool-nav {
    margin: -0.5rem -0.5rem 0.75rem -0.5rem;
    padding: 0 0.75rem;
    font-size: 0.8rem;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
    border-radius: 0.375rem 0.375rem 0 0;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .flex-row {
    width: 100%;
    justify-content: stretch;
  }

  .reset-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.78rem;
  }

  .intro-box {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    border-radius: 0 0 0.375rem 0.375rem;
  }

  .inputs-panel {
    padding: 1rem;
  }

  .inputs-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .section-header h3 {
    font-size: 1rem;
  }

  /* Inputs: larger touch targets */
  input[type="text"],
  select {
    padding: 0.625rem 0.75rem;
    font-size: 1rem;
  }

  .results-banner {
    flex-direction: column;
    gap: 0.5rem;
  }

  .result-highlight {
    padding: 0.75rem;
  }

  .result-highlight-value {
    font-size: 1.25rem;
  }

  .output-card-header {
    padding: 0.5rem 0.75rem;
  }

  .output-card-body {
    padding: 0.5rem 0.75rem;
  }

  .output-row {
    font-size: 0.82rem;
    padding: 0.3rem 0;
  }

  .tooltip-content {
    width: 200px;
    right: -4px;
  }

  .tooltip-trigger {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  /* Export buttons full width */
  .export-row {
    flex-direction: column;
  }

  .export-btn {
    width: 100%;
    text-align: center;
    padding: 0.625rem 1rem;
  }

  .methodology-section summary {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
  }

  .methodology-content {
    padding: 0 1rem 1rem;
    font-size: 0.85rem;
  }
}
