/* =============================================
   VARIABLES & RESET
============================================= */
:root {
  --bg: #1c1710;
  --bg2: #241d13;
  --rail-bg: #150f09;
  --screen-bg: #130e07;
  --accent: #FC5C02;
  --accent-2: #ff8a4d;
  --accent-ink: #1c1710;
  --accent-dim: rgba(252,92,2,0.15);
  --accent-border: rgba(252,92,2,0.45);
  --gold: #c8a600;
  --gold-2: #e0bc00;
  --light: #efe2cc;
  --muted: rgba(226,206,174,0.62);
  --muted-2: rgba(226,206,174,0.42);
  --border: rgba(226,206,174,0.13);
  --border-strong: rgba(226,206,174,0.26);
  --card-bg: rgba(226,206,174,0.035);
  --input-bg: rgba(20,16,8,0.7);
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
  --sans: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --display: var(--sans);
  --radius: 8px;
  --radius-sm: 5px;
  --ok: rgba(80,200,80,0.9);
  --warn: rgba(243,197,83,0.9);
  --err: rgba(252,92,2,0.95);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html { font-size: 14px; }
body {
  font-family: var(--sans);
  background: linear-gradient(180deg, var(--bg), var(--bg2) 480px, var(--bg) 1200px) fixed;
  color: var(--light);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* =============================================
   LAYOUT
============================================= */
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* .app-shell opts a page into the sidebar-rail layout (pages with a .tab-nav / .tab-panel
   structure, currently index.html). Pages without that class keep normal block flow even
   though they share this stylesheet's header/card/input styling. */
@media (min-width: 1001px) {
  .wrap.app-shell {
    display: grid;
    grid-template-columns: minmax(260px, 300px) 1fr;
    grid-template-areas:
      "banner banner"
      "band   band"
      "rail   main"
      ".      footer";
    align-items: start;
    padding: 0 0 40px;
  }
  .wrap.app-shell #mobileWarningBanner { grid-area: banner; }
  .wrap.app-shell > header { grid-area: band; }
  .wrap.app-shell > .tab-nav { grid-area: rail; }
  .wrap.app-shell > .tab-panel { grid-area: main; min-width: 0; padding: 22px 24px 0; }
  .wrap.app-shell > footer { grid-area: footer; padding-left: 24px; padding-right: 24px; min-width: 0; }
}

/* =============================================
   HEADER — orange instrument control-band
============================================= */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: color-mix(in srgb, var(--accent) 46%, var(--bg) 54%);
  background: #7a3608;
  background: color-mix(in srgb, var(--accent) 46%, var(--bg) 54%);
  color: var(--light);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(0,0,0,0.25);
}
header::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(0,0,0,0.06) 0 2px, transparent 2px 14px);
  pointer-events: none;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: var(--bg);
  border: 1px solid rgba(226,206,174,0.18);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-logo svg { width: 22px; height: 22px; stroke: var(--accent-2); fill: none; }

h1 {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #fff;
  line-height: 1.25;
}

.subtitle {
  font-size: 11.5px;
  color: rgba(255,255,255,0.72);
  margin-top: 3px;
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid rgba(226,206,174,0.16);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--light);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4dff6e;
  box-shadow: 0 0 0 3px rgba(77,255,110,0.22);
  display: inline-block;
}

/* =============================================
   TAB NAVIGATION — desktop: vertical instrument rail
============================================= */
.tab-nav {
  display: flex;
  gap: 3px;
  padding: 6px;
  background: rgba(226,206,174,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

@media (min-width: 1001px) {
  .tab-nav {
    flex-direction: column;
    align-self: stretch;
    background: var(--rail-bg);
    border: 1px solid var(--border);
    border-radius: 0;
    border-top: none;
    padding: 10px 8px;
    margin-bottom: 0;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
    position: sticky;
    top: 0;
  }
  .tab-nav .tab-btn,
  .tab-nav .tab-dropdown-toggle,
  .tab-nav > a.tab-btn {
    width: 100%;
    justify-content: flex-start;
    padding: 9px 11px;
    font-size: 14px;
  }
  .tab-dropdown { width: 100%; }
  .tab-dropdown-menu { min-width: 200px; }
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
  white-space: nowrap;
  letter-spacing: 0.05px;
}

.tab-btn:hover {
  color: var(--light);
  background: rgba(226,206,174,0.06);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.tab-icon {
  font-size: 14px;
  opacity: 0.75;
  display: inline-flex;
  flex-shrink: 0;
}
.tab-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; }

/* Safety net: any inline icon with fill="none" but no explicit stroke inherits text color */
svg[fill="none"]:not([stroke]) { stroke: currentColor; }
.tab-btn.active .tab-icon { opacity: 1; }

/* =============================================
   TAB PANELS
============================================= */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeInUp 0.32s var(--ease) both; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   GRID LAYOUTS
============================================= */
.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 14px;
  align-items: start;
}

.single-card-layout {
  max-width: 820px;
}

@media (max-width: 1000px) {
  .panel-grid { grid-template-columns: 1fr; }
}

/* =============================================
   CARDS
============================================= */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 10px 28px rgba(0,0,0,0.16);
}

.scroll-card {
  /* Scrollable on small screens */
}

.preview-card {
  position: sticky;
  top: 14px;
  align-self: start;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1000px) {
  .preview-card { position: static; }
}

/* =============================================
   FLOWING FORM — no boxed card, section markers instead
============================================= */
.flow-form {
  background: transparent;
  border: none;
  box-shadow: none;
}
.flow-form .section {
  border-bottom: 2px solid rgba(226,206,174,0.32);
  padding: 6px 0 24px;
  margin-bottom: 22px;
}
.flow-form .section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.flow-form .section-h {
  background: transparent;
  border-bottom: none;
  padding: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flow-form .section-h .section-title { font-size: 13px; }
.flow-form .form-grid { padding: 0; }
.flow-form .form-actions { padding: 14px 0 0; }
.flow-form .field input,
.flow-form .field select,
.flow-form .field textarea {
  border: 1px solid rgba(226,206,174,0.38);
  border-radius: var(--radius-sm);
  background: rgba(226,206,174,0.05);
  padding: 9px 11px;
}
.flow-form .field input:focus,
.flow-form .field select:focus,
.flow-form .field textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.flow-form .field input.required,
.flow-form .field select.required {
  background: linear-gradient(135deg, rgba(252,92,2,0.08), var(--input-bg));
  border-color: rgba(252,92,2,0.55);
}

/* =============================================
   READOUT PANEL — instrument display, not a matching card
============================================= */
.readout-panel {
  background: var(--screen-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.readout-panel .preview-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.readout-panel .progress-label,
.readout-panel .progress-count { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.readout-panel .progress-fill { box-shadow: 0 0 8px rgba(252,92,2,0.5); }
.readout-panel #xmlOut,
.readout-panel textarea {
  background: transparent;
  border: 1px solid rgba(252,92,2,0.16);
  color: var(--accent-2);
  text-shadow: 0 0 6px rgba(252,92,2,0.18);
}
.readout-panel .preview-footer { border-top: 1px solid var(--border); }

/* =============================================
   SECTIONS (within cards)
============================================= */
.section {
  border-bottom: 1px solid rgba(226,206,174,0.28);
}
.section:last-child {
  border-bottom: none;
}

.section-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: rgba(226,206,174,0.05);
  border-bottom: 1px solid rgba(226,206,174,0.28);
}
.section-h .section-title {
  display: flex;
  align-items: center;
  gap: 9px;
}
.section-h .section-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(252,92,2,0.14);
}

.section-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.2px;
  color: var(--light);
}

.section-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* =============================================
   FORM ELEMENTS
============================================= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: 1; }
}

label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.req {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(252,92,2,0.35);
  background: rgba(252,92,2,0.08);
  color: rgba(226,206,174,0.9);
  font-size: 10px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(226,206,174,0.38);
  background: rgba(226,206,174,0.05);
  color: var(--light);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  outline: none;
  font-family: var(--sans);
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(252,92,2,0.12);
}

input.required,
select.required {
  border-color: rgba(252,92,2,0.55);
  background: linear-gradient(135deg, rgba(252,92,2,0.07), var(--input-bg));
  box-shadow: 0 0 0 2px rgba(252,92,2,0.10);
}

input.invalid,
select.invalid {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(252,92,2,0.22) !important;
}

select {
  background-color: #231e13;
  color: var(--light);
}
option { background: #231e13; }

textarea {
  min-height: 320px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  background: rgba(12,10,5,0.8);
}

.field-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.field-divider::before,
.field-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* =============================================
   BUTTONS
============================================= */
.btn-primary, .btn-ghost {
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
  letter-spacing: 0.1px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e0530a);
  border: 1px solid rgba(252,92,2,0.55);
  color: #fff;
  box-shadow: 0 3px 12px rgba(252,92,2,0.28);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(252,92,2,0.4);
  border-color: rgba(252,92,2,0.8);
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(252,92,2,0.3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--light);
  border-color: var(--border-strong);
  background: rgba(226,206,174,0.06);
}
.btn-ghost:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  flex-wrap: wrap;
}

/* =============================================
   STATUS PILL
============================================= */
.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.ok {
  border-color: rgba(80,200,80,0.35);
  color: var(--ok);
}
.status-pill.err {
  border-color: rgba(252,92,2,0.45);
  color: var(--err);
}

/* =============================================
   REPEATABLE LIST BUILDER
============================================= */
.repeat-list-section {
  padding: 2px 0;
}

.repeat-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.repeat-list-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.btn-add-item {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.btn-add-item:hover { color: var(--light); background: rgba(226,206,174,0.06); }

.repeat-items { display: grid; gap: 6px; }

.repeat-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.repeat-item input {
  flex: 1;
}

.btn-remove {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.btn-remove:hover { color: var(--err); border-color: rgba(252,92,2,0.35); }

/* =============================================
   PREVIEW (RIGHT PANEL)
============================================= */
.preview-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(226,206,174,0.03);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-block { display: flex; flex-direction: column; gap: 6px; }

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-label { font-size: 11px; color: var(--muted); }
.progress-count { font-size: 11px; font-weight: 800; color: var(--light); font-family: var(--mono); }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(226,206,174,0.08);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s var(--ease);
  border-radius: 999px;
}

.xml-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  text-align: center;
}
.xml-status.ok {
  color: var(--ok);
  border-color: rgba(80,200,80,0.3);
}
.xml-status.err {
  color: var(--err);
  border-color: rgba(252,92,2,0.3);
}

.preview-body {
  padding: 12px 14px;
  flex: 1;
}

.preview-body textarea {
  width: 100%;
  min-height: 300px;
}

.preview-footer {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.validation-box {
  padding: 0 14px 12px;
  font-size: 12px;
}

.validation-ok { color: var(--ok); }
.validation-err { color: var(--err); }
.validation-err ul { margin: 6px 0 0 16px; }
.validation-err li { margin-bottom: 3px; }

/* =============================================
   FILE DROP ZONE
============================================= */
.file-drop-zone {
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius);
  padding: 24px;
  background: rgba(252,92,2,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
  min-height: 120px;
  justify-content: center;
}

.file-drop-zone:hover {
  border-color: rgba(252,92,2,0.8);
  background: rgba(252,92,2,0.08);
  box-shadow: 0 0 0 4px rgba(252,92,2,0.1);
}
.file-drop-zone.drag {
  border-color: rgba(252,92,2,0.9);
  background: rgba(252,92,2,0.1);
  box-shadow: 0 0 0 4px rgba(252,92,2,0.14);
  transform: scale(1.01);
}

.drop-icon { line-height: 1; color: var(--muted); }
.drop-icon svg { width: 30px; height: 30px; stroke: currentColor; fill: none; }
.drop-text { font-weight: 700; font-size: 13px; color: var(--light); }
.drop-sub { font-size: 12px; color: var(--muted); }

.file-info-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: rgba(252,92,2,0.06);
}
.file-info-name { font-weight: 800; font-size: 13px; }
.file-info-size { font-size: 11px; color: var(--muted); }

/* =============================================
   XML CHECK REPORT
============================================= */
.check-report {
  padding: 14px;
  font-size: 12px;
  line-height: 1.6;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.check-item.ok { background: rgba(80,200,80,0.06); border: 1px solid rgba(80,200,80,0.18); }
.check-item.warn { background: rgba(243,197,83,0.06); border: 1px solid rgba(243,197,83,0.25); }
.check-item.err { background: rgba(252,92,2,0.06); border: 1px solid rgba(252,92,2,0.25); }

.check-item-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.check-item.ok .check-item-icon { color: var(--ok); }
.check-item.warn .check-item-icon { color: var(--warn); }
.check-item.err .check-item-icon { color: var(--err); }

.check-item-text { color: var(--light); }
.check-item-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

.legend-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
}
.pill-icon { width: 11px; height: 11px; stroke: currentColor; fill: none; flex-shrink: 0; }
.legend-pill.ok { border-color: rgba(80,200,80,0.3); color: var(--ok); }
.legend-pill.warn { border-color: rgba(243,197,83,0.35); color: var(--warn); }
.legend-pill.err { border-color: rgba(252,92,2,0.4); color: var(--err); }
.legend-pill.type { border-color: rgba(255,138,77,0.4); color: var(--accent-2); }
.legend-pill.dup { border-color: rgba(200,166,0,0.4); color: var(--gold); }
.legend-pill.other { border-color: var(--border-strong); color: var(--muted); }

/* =============================================
   IFC QUEUE & RESULTS
============================================= */
.file-queue {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
}

.empty-state {
  color: var(--muted);
  font-size: 12px;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(226,206,174,0.03);
}

.queue-item-name {
  font-weight: 700;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.type-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid;
}

.type-badge.ar {
  border-color: rgba(252,92,2,0.5);
  background: rgba(252,92,2,0.1);
  color: var(--light);
}

.type-badge.gp {
  border-color: rgba(95,252,2,0.3);
  background: rgba(95,252,2,0.06);
  color: var(--ok);
}

.type-badge.unknown {
  border-color: var(--border);
  color: var(--muted);
}

/* IFC progress */
.progress-wrap {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-wrap .progress-track {
  flex: 1;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

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

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  color: var(--light);
}

th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  background: rgba(226,206,174,0.04);
}

tr.row-warn { background: rgba(243,197,83,0.06); }
tr.row-err { background: rgba(252,92,2,0.06); }

.summaryBox {
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--light);
  border-bottom: 1px solid var(--border);
}
.summaryBox.empty { color: var(--muted); }

.note-text {
  padding: 10px 14px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Rules grid */
.rules-grid {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rule-category {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rule-cat-header {
  padding: 7px 10px;
  background: rgba(252,92,2,0.08);
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 12px;
  font-family: var(--mono);
  color: rgba(252,92,2,0.9);
}

.rule-pset {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.rule-pset:last-child { border-bottom: none; }

.rule-pset-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: var(--mono);
}

.rule-props {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rule-prop {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(226,206,174,0.04);
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
}

/* ── IFC check: sub-tab switch (АГР / МГЭ Реновация) ── */
.ifc-mode-switch {
  display: flex;
  gap: 6px;
  padding: 3px;
  margin-bottom: 14px;
  background: rgba(226,206,174,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: fit-content;
}
.ifc-mode-btn {
  padding: 7px 16px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.ifc-mode-btn:hover { color: var(--light); }
.ifc-mode-btn.active {
  background: rgba(252,92,2,0.14);
  color: var(--accent, #fc5c02);
}

.ifc-mode-switch--sub {
  margin-top: -6px;
  transform: scale(0.92);
  transform-origin: left center;
  background: rgba(226,206,174,0.03);
}
.ifc-mode-btn-sub {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.ifc-mode-btn-sub:hover { color: var(--light); }
.ifc-mode-btn-sub.active {
  background: rgba(252,92,2,0.12);
  color: var(--accent, #fc5c02);
}

/* ── MGE rules reference (grouped by Приложение) ── */
.mge-scope-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: rgba(226,206,174,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mge-appendix-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.mge-appendix-group + .mge-appendix-group { margin-top: 10px; }
.mge-appendix-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(252,92,2,0.08);
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 12px;
}
.mge-appendix-header::-webkit-details-marker { display: none; }
.mge-appendix-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--accent, #fc5c02);
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
}
.mge-appendix-title { color: var(--light); flex: 1; }
.mge-appendix-count { font-weight: 400; font-size: 11px; color: var(--muted); }
.mge-appendix-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mge-cat-id { font-family: var(--mono); color: var(--accent, #fc5c02); margin-right: 4px; }
.mge-cat-ifc {
  float: right;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

/* =============================================
   FOOTER
============================================= */
footer {
  margin-top: 40px;
  padding: 20px 0 10px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.footer-sep { opacity: 0.4; }

footer a {
  color: var(--accent);
  text-decoration: none;
}
footer a:hover { text-decoration: underline; }

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  padding: 8px 0 0;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 11px;
  color: var(--muted);
}
.footer-legal-label { opacity: 0.6; white-space: nowrap; }
.footer-legal-sep   { opacity: 0.3; }
.footer-legal-link  {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.footer-legal-link:hover { color: var(--light); text-decoration: underline; }
.footer-legal-icon  { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.65; }
@media (max-width: 480px) {
  .footer-legal-sep { display: none; }
  .footer-legal-link { width: 100%; }
}

/* =============================================
   HELP BUTTON & NAMING MODAL
============================================= */
.btn-help {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card-bg);
  color: var(--muted);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-help:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,8,4,0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.modal-overlay.open {
  opacity: 1; visibility: visible;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-width: 720px; width: 100%;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  transform: translateY(12px) scale(0.97);
  transition: transform .25s;
}
.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 15px; font-weight: 600;
  color: var(--light);
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: transparent;
  color: var(--muted); font-size: 16px;
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px;
}

/* Schema strip */
.modal-schema {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; flex-wrap: wrap;
  padding: 16px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.schema-field {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 14px; font-weight: 600;
  color: var(--accent);
  position: relative;
}
.schema-field::before {
  content: attr(data-label);
  position: absolute; top: -18px;
  font-family: var(--sans);
  font-size: 10px; font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.schema-field.opt {
  border-style: dashed;
  opacity: 0.7;
}
.schema-sep {
  font-family: var(--mono);
  font-size: 16px; font-weight: 700;
  color: var(--muted);
}

/* Modal table */
.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.modal-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border-strong);
}
.modal-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--light);
}
.modal-table td code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}

.modal-section-title {
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.modal-rule {
  font-size: 13px;
  color: var(--light);
  line-height: 1.6;
}
.modal-rule code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}
.modal-rule code.forbidden {
  background: rgba(252,92,2,0.08);
  color: var(--err);
  word-break: break-all;
}

.modal-examples {
  display: flex; flex-direction: column; gap: 8px;
}
.modal-example {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.modal-example code {
  font-family: var(--mono);
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.modal-example span {
  font-size: 12px;
  color: var(--muted);
}

/* ─── IFC TREE RESULTS ───────────────────────────────────────────── */

.tree-controls {
  display: flex;
  gap: 8px;
  padding: 10px 0 6px;
}
.tree-controls button {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--light);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tree-controls button:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.tree-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 100%;
}

/* Tree node base */
.tree-node {
  border-radius: 6px;
  overflow: hidden;
}

/* Toggle button (header of each node) */
.tree-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 6px;
  transition: background 0.12s;
  color: var(--light);
}
.tree-toggle:hover { background: var(--hover-bg, rgba(255,255,255,0.04)); }

/* Chevron */
.chevron {
  font-size: 9px;
  color: var(--muted);
  transition: transform 0.18s;
  flex-shrink: 0;
  width: 10px;
}
.tree-node.open > .tree-toggle .chevron { transform: rotate(90deg); }

/* Node label */
.node-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
}

/* Children container — hidden until .open */
.tree-children {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 4px 18px;
}
.tree-node.open > .tree-children { display: flex; }

/* Leaf (GUID) list */
.leaf-list {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 4px 28px;
}
.tree-node.open > .leaf-list { display: flex; }

.leaf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.02);
}
.leaf-item .guid {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}
.more-items { color: var(--accent); font-size: 11px; }

/* Depth backgrounds */
.tree-node.depth-0 > .tree-toggle {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: 2px;
  font-weight: 600;
}
.tree-node.depth-0 > .tree-toggle:hover { background: rgba(255,255,255,0.07); }

.tree-node.depth-1 > .tree-toggle {
  background: rgba(255,255,255,0.02);
  border-left: 2px solid var(--border-strong);
  border-radius: 0 5px 5px 0;
  padding-left: 10px;
  font-size: 12.5px;
}
.tree-node.depth-2 > .tree-toggle {
  padding-left: 8px;
  font-size: 12px;
  border-left: 2px solid transparent;
}
.tree-node.depth-2.badge-warn-node > .tree-toggle { border-color: rgba(243,197,83,0.4); }
.tree-node.depth-2.badge-err-node > .tree-toggle  { border-color: rgba(252,92,2,0.4); }

/* Node badges */
.node-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.badge-ok   { background: rgba(80,200,80,0.12);   color: var(--ok);   border: 1px solid rgba(80,200,80,0.25); }
.badge-warn { background: rgba(243,197,83,0.12);  color: var(--warn); border: 1px solid rgba(243,197,83,0.3); }
.badge-err  { background: rgba(252,92,2,0.10);    color: var(--err);  border: 1px solid rgba(252,92,2,0.3); }
.badge-name { background: rgba(252,92,2,0.10);    color: var(--err);  border: 1px solid rgba(252,92,2,0.3); }

/* Summary stats pills */
.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.stat-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
}
.warn-pill { background: rgba(243,197,83,0.12); color: var(--warn); border: 1px solid rgba(243,197,83,0.3); }
.err-pill  { background: rgba(252,92,2,0.10);   color: var(--err);  border: 1px solid rgba(252,92,2,0.3); }
.name-pill { background: rgba(252,92,2,0.10);   color: var(--err);  border: 1px solid rgba(252,92,2,0.3); }

/* ─── LOCKED / PROMO TABS ───────────────────────────────────────── */

/* Tab button — locked state */
.tab-btn-locked {
  opacity: 0.7;
}
.tab-btn-locked .tab-icon-paid {
  font-style: normal;
  font-weight: 700;
  color: var(--gold);
}
.tab-btn-locked:hover {
  opacity: 1;
}

/* Promo card layout */
.promo-card {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  background: var(--card-bg, #1a1a1e);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  max-width: 820px;
  margin: 32px auto;
}

/* Left: image block */
.promo-image-wrap {
  flex-shrink: 0;
  width: 200px;
}
.promo-image-placeholder {
  width: 200px;
  height: 160px;
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  font-family: var(--mono);
}
.promo-image-wrap img {
  width: 200px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}

/* Right: text content */
.promo-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.promo-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--light);
  line-height: 1.3;
}
.promo-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}

/* Locked note at bottom */
.promo-locked-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(200,166,0,0.07);
  border: 1px solid rgba(200,166,0,0.25);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 500;
}
.lock-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 600px) {
  .promo-card {
    flex-direction: column;
    padding: 24px 20px;
    margin: 16px;
  }
  .promo-image-wrap,
  .promo-image-wrap img,
  .promo-image-placeholder {
    width: 100%;
    height: 140px;
  }
}
