* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       color: #1e293b; background: linear-gradient(135deg, #0b1020 0%, #16213e 45%, #312e81 100%); }
.hidden { display: none !important; }
.muted { color: #64748b; }
.small { font-size: 12px; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
              background: url('/resources/background.png') center center / cover no-repeat; }
.login-card { background: rgba(255,255,255,0.12); padding: 32px; border-radius: 16px;
              box-shadow: 0 20px 50px rgba(0,0,0,0.4); width: 360px;
              backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
              border: 1px solid rgba(255,255,255,0.22); }
.login-card h1 { margin: 0 0 4px 0; font-size: 24px; color: #ffffff; }
.login-card .subtitle { color: rgba(255,255,255,0.75); font-size: 13px; margin-bottom: 24px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.90); }
.login-card input { width: 100%; padding: 10px; margin-top: 6px;
                    border: 1px solid rgba(255,255,255,0.30);
                    border-radius: 8px; font-size: 14px;
                    background: rgba(255,255,255,0.15); color: #ffffff; }
.login-card input::placeholder { color: rgba(255,255,255,0.45); }
.login-card input:focus { outline: none; border-color: rgba(255,255,255,0.70);
                          background: rgba(255,255,255,0.22); }
.btn-full { width: 100%; }

/* Topbar / stepper */
.topbar { background: white; padding: 14px 24px; display: flex; justify-content: space-between;
          align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
          position: relative; z-index: 100; }
.brand { font-weight: 800; font-size: 18px; }
.user-info { display: flex; gap: 10px; align-items: center; }
#username-pill { background: #e0e7ff; color: #3730a3; padding: 6px 12px; border-radius: 999px;
                 font-size: 13px; font-weight: 600; }
.stepper { display: flex; gap: 12px; padding: 16px 24px; background: #fff;
           border-bottom: 1px solid #e2e8f0; flex-wrap: wrap;
           position: relative; z-index: 100; }
.step { display: flex; gap: 8px; align-items: center; padding: 8px 14px;
        border-radius: 999px; background: #f1f5f9; color: #94a3b8;
        font-size: 13px; font-weight: 600; }
.step.active { background: #6366f1; color: white; }
.step.done { background: #10b981; color: white; }
.step-num { width: 22px; height: 22px; border-radius: 999px; background: rgba(255,255,255,0.25);
            display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }

/* Layout */
main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.card { background: white; border-radius: 12px; padding: 20px 24px; margin-bottom: 16px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.card h2 { margin: 0 0 12px 0; font-size: 18px; }
.card h3 { margin: 20px 0 8px 0; font-size: 14px; color: #475569; }
label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 12px; }
label.inline { display: inline-flex; gap: 8px; align-items: center;
               margin-right: 18px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; margin-top: 4px; font-family: inherit;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: #6366f1; }
.row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; align-items: flex-end; }
.row > label, .row > * { flex: 0 0 auto; }
.row > .flex-1 { flex: 1 1 auto; }

/* Buttons */
.btn { padding: 8px 16px; border: 1px solid #cbd5e1; background: white; color: #1e293b;
       border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
       transition: all 0.15s; }
.btn:hover { background: #f8fafc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #4f46e5; color: white; border-color: #4f46e5; }
.btn-primary:hover { background: #4338ca; }
.btn-success { background: #16a34a; color: white; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-info    { background: #0ea5e9; color: white; border-color: #0ea5e9; }
.btn-warning { background: #d97706; color: white; border-color: #d97706; }
.btn-danger  { background: #dc2626; color: white; border-color: #dc2626; }
.btn-ghost { background: transparent; border: 1px solid #cbd5e1; color: #1e293b; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* Pills */
.pill { display: inline-flex; padding: 6px 12px; border-radius: 999px; font-size: 12px;
        font-weight: 600; background: #e2e8f0; color: #334155; }
.pill.blue   { background: #1d4ed8; color: white; }
.pill.teal   { background: #0f766e; color: white; }
.pill.purple { background: #7c3aed; color: white; }
.pill.green  { background: #166534; color: white; }
.pill.amber  { background: #92400e; color: white; }
.pill.slate  { background: #334155; color: white; }
.pill.pink   { background: #be185d; color: white; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* Dropzone */
.dropzone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 32px;
            text-align: center; color: #64748b; cursor: pointer; transition: all 0.15s; }
.dropzone:hover, .dropzone.dragover { border-color: #6366f1; background: #eef2ff; }
.dropzone a { color: #4f46e5; font-weight: 600; }

/* Lists */
.error-list, .warning-list { padding: 14px 18px; border-radius: 8px; margin-top: 12px; font-size: 13px; }
.error-list   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.warning-list { background: #fef3c7; border: 1px solid #fcd34d; color: #854d0e; }
.error-list ul, .warning-list ul { margin: 0; padding-left: 20px; }
.error-banner { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px;
                margin-top: 12px; font-size: 13px; font-weight: 600; }

.summary-card { background: #f0fdf4; border: 1px solid #86efac; border-radius: 12px;
                padding: 16px; margin-top: 16px; }
.upload-info-banner { background: #eff6ff; border: 1px solid #93c5fd; color: #1e40af;
                      border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.upload-info-banner ul { margin: 6px 0 0 0; padding-left: 20px; }

/* Function grid */
.function-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.function-grid label { display: flex; gap: 8px; align-items: center; padding: 6px 10px;
                       background: #f8fafc; border-radius: 6px; margin: 0; font-weight: 500; }
.function-grid label:hover { background: #f1f5f9; }
.function-grid input { width: auto; margin: 0; }

/* Rules tables */
.rules-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.rules-table th, .rules-table td { padding: 6px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.rules-table th { background: #f8fafc; font-weight: 600; }
.rules-table .remove-btn { background: #fee2e2; color: #991b1b; border: none; padding: 4px 8px;
                            border-radius: 4px; cursor: pointer; font-size: 11px; }

/* Validation summary */
#validation-summary { padding: 12px; border-radius: 10px; margin: 10px 0; font-size: 12px; line-height: 1.5; }
#validation-summary.ok  { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
#validation-summary.bad { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
#validation-summary ul { margin: 4px 0 0 0; padding-left: 18px; }

/* Progress card */
.progress-card { background: linear-gradient(135deg, #0b1020 0%, #16213e 45%, #312e81 100%);
                 color: white; padding: 28px 32px; border-radius: 20px;
                 box-shadow: 0 18px 40px rgba(15,23,42,0.22); }
.progress-card.complete { background: linear-gradient(135deg,#052e16 0%,#14532d 50%,#064e3b 100%); }
.progress-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.progress-stage { font-size: 13px; opacity: 0.92; margin-bottom: 14px; }
.progress-bar { background: rgba(255,255,255,0.10); border-radius: 999px; height: 16px;
                overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; width: 0%;
                 background: linear-gradient(90deg, #22d3ee 0%, #60a5fa 45%, #a78bfa 100%);
                 box-shadow: 0 0 14px rgba(96,165,250,0.7);
                 transition: width 0.3s; }
.progress-pct { font-size: 12px; opacity: 0.88; }

/* Success card */
.success-card { background: linear-gradient(135deg,#052e16 0%,#14532d 50%,#064e3b 100%);
                color: white; padding: 28px 32px; border-radius: 18px;
                box-shadow: 0 12px 32px rgba(5,46,22,0.35); margin-bottom: 16px; }
.big-title { font-size: 22px; font-weight: 900; margin-bottom: 10px; }

code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ===========================================================
   STEP 2 — Floating panels (actions left, compatibility right)
   =========================================================== */
#step-scenario { position: relative; }
.scenario-main { max-width: 640px; margin: 0 auto; }

.floating-left, .floating-right {
  position: fixed;
  top: 160px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  z-index: 10;
}
.floating-left {
  left: calc(50% - 620px);
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  padding: 14px;
}
.floating-right {
  right: auto;
  left: calc(50% + 340px);
  width: 300px;
}

.floating-left .btn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
}
.floating-left .panel-section-title {
  margin: 12px 0 8px 0;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.floating-left .panel-section-title:first-child { margin-top: 0; }

#run-optimize-btn { margin-top: 4px; }

/* Compatibility (permissible-combinations) toggle */
.spain-check-toggle {
  background: whitesmoke;
  border: 1px solid #b8c9e0;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(33, 60, 105, 0.08);
  transition: background 0.2s, border-color 0.2s;
}
/* When the checkbox is checked, shift to a light blue tint */
.spain-check-toggle:has(#restrict-to-spain:checked) {
  background: #ddeaf8;
  border-color: #6b9fd4;
}
.spain-check-toggle label.inline {
  font-weight: 700;
  margin-bottom: 0;
  font-size: 13px;
  color: #213c69;
  align-items: flex-start;
}
.spain-toggle-label {
  font-weight: 700;
  color: #213c69;
}
.spain-toggle-help {
  margin: 8px 0 0 0;
  color: #213c69;
  opacity: 0.9;
  line-height: 1.6;
  font-size: 13px;
}
.spain-toggle-help code {
  background: rgba(255,255,255,0.7);
  color: #213c69;
}


#spain-live-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}
#spain-live-feedback.neutral { background: #fff; border: 1px solid #e5e7eb; color: #475569; }
#spain-live-feedback.ok { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
#spain-live-feedback.bad { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.combo-chip {
  display: inline-block;
  padding: 3px 9px;
  margin: 2px 4px 2px 0;
  background: rgba(22,101,52,0.10);
  border: 1px solid rgba(22,101,52,0.25);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

/* When viewport is too narrow, drop floating panels back into the flow.
   Order: compatibility check (right) → main form → actions (left). */
@media (max-width: 1320px) {
  #step-scenario {
    display: flex;
    flex-direction: column;
  }
  .floating-left, .floating-right {
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
    margin: 0 0 16px 0;
  }
  .floating-right { order: 1; }
  .scenario-main { order: 2; max-width: 100%; }
  .floating-left { order: 3; }
}

/* ===========================================================
   STEP 4 — Scenario tabs + table
   =========================================================== */
.scenario-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 16px;
  padding-bottom: 6px;
}
.scenario-tab {
  padding: 8px 14px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-align: center;
  min-width: 110px;
  transition: all 0.15s;
}
.scenario-tab:hover { background: #e2e8f0; }
.scenario-tab.active {
  background: #4f46e5;
  color: white;
  border-color: #4f46e5;
}
.scenario-tab .tab-title { font-weight: 700; display: block; font-size: 13px; }
.scenario-tab .tab-sub { font-size: 11px; opacity: 0.85; font-weight: 500; }

.scenario-summary-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.scenario-table-wrapper {
  max-height: 600px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.scenario-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: white;
}
.scenario-table th {
  background: #f8fafc;
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #cbd5e1;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.scenario-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
.scenario-table tbody tr:hover td { background: #fafafa; }
.scenario-table td.changed {
  background: #dcfce7;
  font-weight: 600;
  color: #166534;
}
.scenario-table td:first-child,
.scenario-table th:first-child {
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
  font-weight: 600;
  box-shadow: 1px 0 0 #e2e8f0;
}
.scenario-table th:first-child { background: #f8fafc; z-index: 3; }
.scenario-table tbody tr:hover td:first-child { background: #fafafa; }

@media (max-width: 700px) {
  .function-grid { grid-template-columns: repeat(2, 1fr); }
  main { padding: 12px; }
  .stepper { padding: 12px; gap: 6px; }
  .step { padding: 6px 10px; font-size: 12px; }
  .scenario-tab { min-width: 90px; padding: 6px 10px; }
}

/* ============================================================
   Header — brand + research/author links
   ============================================================ */
.brand-group {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1 1 auto;
  min-width: 0;
}
.header-links {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.header-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #e2e8f0;
  transition: all 0.15s;
  white-space: nowrap;
}
.header-link:hover {
  background: #e0e7ff;
  color: #3730a3;
  border-color: #6366f1;
}
.header-link.paper {
  display: inline-block;
  background: #015438;
  border-color: #013d29;
  color: #ffffff !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.6;
}
.header-link.paper:hover {
  background: #013d29;
  border-color: #012a1c;
  color: #ffffff !important;
}

/* ============================================================
   Floating-left — Resources section (Reference / User Guide)
   ============================================================ */
.resource-btn {
  display: inline-block !important;
  width: auto;
  text-align: center;
  text-decoration: none !important;
  background: #ede9fe;
  color: #5b21b6 !important;
  border: 1px solid #c4b5fd;
}
.resource-btn:hover { background: #ddd6fe; }

/* Container for the two resource buttons in the upload card */
.upload-resources {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  background: #1e293b;
  color: #cbd5e1;
  padding: 18px 24px;
  text-align: center;
  font-size: 13px;
  margin-top: 40px;
}
.site-footer p { margin: 0; }
.site-footer a {
  color: #93c5fd;
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover {
  color: #bfdbfe;
  text-decoration: underline;
}

/* ============================================================
   Responsive — wrap header on narrow screens
   ============================================================ */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .brand-group { flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; }
  .header-links { width: 100%; }
  .header-link.paper { max-width: 100%; }
}


/* ──────────────────────────────────────────────────────────────
   Parcel-level Spain compatibility warning — banner
   (shown inside the Function Area Rules section)
   ────────────────────────────────────────────────────────────── */
.parcel-compat-banner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 4px solid #f97316;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: #7c2d12;
}

.parcel-compat-banner-icon {
  font-size: 18px;
  line-height: 1.4;
  flex-shrink: 0;
}

.parcel-compat-banner strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #9a3412;
}

.parcel-compat-banner-list {
  margin: 4px 0 6px 0;
  padding-left: 18px;
}

.parcel-compat-banner-list li {
  margin-bottom: 2px;
}

.parcel-compat-banner-note {
  margin: 0;
  font-size: 12px;
  color: #9a3412;
  opacity: 0.85;
}

/* ──────────────────────────────────────────────────────────────
   Parcel-level Spain compatibility — right-side panel section
   ────────────────────────────────────────────────────────────── */
.parcel-compat-panel-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  font-size: 13px;
}

.parcel-compat-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.parcel-compat-panel-icon {
  font-size: 15px;
}

.parcel-compat-panel-title {
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  flex: 1;
}

.parcel-compat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.parcel-compat-badge-ok {
  background: #dcfce7;
  color: #166534;
}

.parcel-compat-badge-err {
  background: #fee2e2;
  color: #991b1b;
}

.parcel-compat-panel-note {
  font-size: 12px;
  color: #64748b;
  margin: 0 0 8px 0;
  line-height: 1.5;
}

.parcel-compat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.parcel-compat-table th {
  text-align: left;
  font-weight: 600;
  color: #475569;
  padding: 4px 6px;
  border-bottom: 1px solid #e2e8f0;
}

.parcel-compat-conflict-row td {
  padding: 5px 6px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.parcel-compat-pid {
  font-family: monospace;
  font-size: 11px;
  color: #334155;
  font-weight: 600;
  white-space: nowrap;
}

.parcel-compat-pair {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.parcel-compat-fn {
  background: #fee2e2;
  color: #991b1b;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.parcel-compat-x {
  color: #dc2626;
  font-weight: 700;
  font-size: 12px;
}




/* ============================================================
   Form section ribbons  (#213c69 bar, white text)
   Applied via class="form-ribbon" on <h3> elements and
   class="form-ribbon-h2" on the Group editor <h2>.
   ============================================================ */
.form-ribbon {
  background: #213c69;
  color: #ffffff !important; 
  padding: 7px 14px;
  margin: 20px -24px 12px -24px;   /* bleeds to card edges */
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-left: 4px solid #3a5c99;  /* subtle left accent */
}

.form-ribbon-h2 {
  background: #213c69;
  color: #ffffff !important;
  padding: 9px 14px;
  margin: -20px -24px 16px -24px;  /* touches the card's top edge */
  font-size: 16px;
  font-weight: 700;
  border-radius: 12px 12px 0 0;    /* matches card top corners */
  border-bottom: 3px solid #3a5c99;
}