:root{
  --ink:#142033; --muted:#68758a; --paper:#fffdf8; --cream:#f6f0e4;
  --purple:#7657b7; --lav:#e9def7; --green:#dfeee3; --yellow:#f7e9a8;
  --border:#d8d8df;
}
*{box-sizing:border-box}
body{margin:0;font-family:Inter,ui-rounded,system-ui,-apple-system,sans-serif;color:var(--ink);background:var(--paper)}
button,input{font:inherit}
button{cursor:pointer}
.topbar{display:flex;justify-content:space-between;padding:18px 5vw;border-bottom:1px solid var(--border)}
.brand{font-weight:800;letter-spacing:.05em}.tiny,.micro,.hu{color:var(--muted)}
.hero{min-height:58vh;display:grid;grid-template-columns:330px 1fr;gap:5vw;align-items:center;max-width:1180px;margin:auto;padding:60px 4vw}
.hero h1{font-size:clamp(34px,5vw,68px);line-height:1.02;max-width:850px;margin:0 0 12px}
.hero .hu{font-size:18px;margin-bottom:30px}
.searchbar{display:flex;gap:10px;max-width:800px}
.searchbar input,.inline input,.modal input{flex:1;padding:18px 20px;border:2px solid var(--ink);border-radius:18px;background:white}
.searchbar button,.primary{border:0;border-radius:18px;padding:14px 22px;background:var(--purple);color:#fff;font-weight:800}
.bench-figure{height:280px;position:relative}
.head{width:72px;height:72px;border-radius:50%;background:#e8c3a4;position:absolute;left:95px;top:20px;border:3px solid var(--ink)}
.body{width:110px;height:120px;border-radius:55px 55px 20px 20px;background:#728861;position:absolute;left:72px;top:82px;border:3px solid var(--ink)}
.bag{width:75px;height:90px;border-radius:18px;background:#b98752;position:absolute;left:188px;top:128px;border:3px solid var(--ink)}
.bench{height:22px;width:280px;background:#c28b54;position:absolute;left:15px;top:205px;border:3px solid var(--ink);box-shadow:0 24px 0 -8px #c28b54}
.card{border:1px solid var(--border);border-radius:28px;background:white;box-shadow:0 10px 35px rgba(25,28,38,.06)}
.wide{max-width:1120px;margin:0 auto 32px;padding:30px}
.hidden{display:none!important}
.layer{margin:18px 0}.layer-title{font-weight:900;margin-bottom:10px}
.chips{display:flex;flex-wrap:wrap;gap:10px}
.chip{border:1px solid var(--border);border-radius:999px;padding:10px 14px;background:#fff}
.chip input{margin-right:7px}.layer.direct .chip{background:var(--lav)}.layer.search .chip{background:var(--yellow)}.layer.related .chip{background:var(--green)}
.match{display:grid;grid-template-columns:1fr auto;gap:18px;padding:20px 0;border-top:1px solid var(--border)}
.match:first-child{border-top:0}.match h3{margin:0 0 7px}.score{font-size:12px;color:var(--muted)}
.match button,.ghost,#crossBtn{border:1px solid var(--border);background:white;border-radius:14px;padding:10px 14px;font-weight:700}
.modal{position:fixed;inset:0;background:rgba(20,32,51,.45);display:grid;place-items:center;z-index:9}
.modal-card{width:min(520px,90vw);background:white;border-radius:30px;padding:36px;text-align:center;box-shadow:0 30px 90px rgba(0,0,0,.25)}
.modal-card input{width:100%;margin:20px 0}.lock{font-size:34px}.error{color:#a33;margin-top:12px}
.workspace{display:grid;grid-template-columns:160px 1fr;min-height:100vh;background:#f5f6f8}
.rail{background:#172237;color:white;padding:28px 18px;display:flex;flex-direction:column;gap:12px}
.rail button{border:0;background:transparent;color:#bfc7d6;text-align:left;padding:12px;border-radius:10px}.rail button.active{background:#293752;color:white}
.workspace main{padding:34px 4vw}.workspace-head{display:flex;justify-content:space-between;gap:30px;align-items:flex-start}.workspace-head h1{margin:4px 0}
.eyebrow{font-size:12px;letter-spacing:.12em;font-weight:900;color:var(--purple)}
.research-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:22px;margin-top:25px}.panel{background:white;border:1px solid var(--border);border-radius:22px;padding:24px}
table{border-collapse:collapse;width:100%}th,td{padding:9px 10px;border-bottom:1px solid #eee;text-align:left}
.inline{display:flex;gap:8px}.inline input{padding:11px 12px;border:1px solid var(--border);border-radius:12px}
.analysis-room{margin-top:25px;border-radius:28px;background:#ece7dc;padding:28px;border:1px solid #d3cbbd}
.wall-board{background:#243128;color:white;border:8px solid #a97b4e;border-radius:8px;padding:22px;min-height:150px}
.expert-row{display:grid;grid-template-columns:1fr 1fr;gap:22px;margin-top:22px}.expert{display:flex;gap:14px;align-items:flex-start}
.person{width:74px;height:90px;border-radius:30px 30px 18px 18px;display:grid;place-items:center;font-weight:900;border:3px solid var(--ink)}
.person.gur{background:white}.person.gy{background:#d9c7aa}
.bubble{background:white;border-radius:22px;padding:18px;flex:1;min-height:140px;position:relative}.bubble:before{content:"";position:absolute;left:-14px;top:28px;border:8px solid transparent;border-right-color:white}
.big{margin-top:22px}.disclaimer{font-size:12px;color:var(--muted)}
@media(max-width:800px){.hero{grid-template-columns:1fr}.bench-figure{display:none}.workspace{grid-template-columns:1fr}.rail{display:none}.research-grid,.expert-row{grid-template-columns:1fr}}


/* ---------- V0.2 research controls ---------- */

.table-controls,
.display-controls{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  margin:0 0 14px;
}

.display-controls label{
  padding:7px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:white;
}

.mini-btn{
  border:1px solid var(--border);
  background:white;
  border-radius:10px;
  padding:7px 10px;
  cursor:pointer;
}

.primary-mini{
  background:var(--purple);
  color:white;
  border-color:var(--purple);
}

.excluded-row{
  opacity:.4;
}

.category-selectors{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
  margin:15px 0;
}

.compact{
  margin-top:8px;
}

.compact .chip{
  padding:7px 10px;
  font-size:13px;
}

.table-wrap{
  overflow-x:auto;
}

.research-table th{
  font-weight:700;
}

.research-table td,
.research-table th{
  vertical-align:top;
}

.output-workspace{
  margin-top:25px;
  padding:26px;
  background:white;
  border:1px solid var(--border);
  border-radius:26px;
}

.output-card{
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:center;
  padding:16px 0;
  border-top:1px solid var(--border);
}

.output-card:first-child{
  border-top:0;
}

.output-actions{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
}

@media(max-width:800px){
  .category-selectors{
    grid-template-columns:1fr;
  }

  .output-card{
    flex-direction:column;
    align-items:flex-start;
  }
}


/* --- V0.2 layout safety: wide tables must not push the workspace wider --- */

.workspace main{
  min-width:0;
  overflow-x:hidden;
}

.research-grid,
.panel,
.analysis-room,
.output-workspace{
  min-width:0;
}

.table-wrap{
  width:100%;
  max-width:100%;
  overflow-x:auto;
}

.research-table{
  width:max-content;
  min-width:100%;
}

.workspace-head{
  position:sticky;
  top:0;
  z-index:20;
  background:#f5f6f8;
  padding-top:8px;
  padding-bottom:12px;
}

#backBtn{
  flex:0 0 auto;
  position:sticky;
  right:0;
  z-index:25;
}

/* =========================================================
   V0.3 – Distribution and crosstab vertically stacked
   ========================================================= */

/* Alapsor és kereszttábla mindig egymás alatt */
.research-grid{
    display:grid !important;
    grid-template-columns:minmax(0, 1fr) !important;
    gap:22px !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
}

/* Egyetlen panel sem növelheti az oldal szélességét */
.research-grid > .panel{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    box-sizing:border-box;
    overflow:hidden;
}

/* A széles táblázat csak a saját dobozában görgethető */
.table-wrap,
#distribution,
#crosstab{
    width:100%;
    max-width:100%;
    min-width:0;
    box-sizing:border-box;
}

.table-wrap{
    overflow-x:auto !important;
    overflow-y:visible;
    -webkit-overflow-scrolling:touch;
}

/* A táblázat lehet széles, de az oldal nem */
.research-table{
    width:max-content;
    min-width:100%;
    max-width:none;
    border-collapse:collapse;
}

/* Hosszú változó- és kategórianevek ne nyomják szét a panelt */
.research-table th,
.research-table td{
    max-width:320px;
    overflow-wrap:anywhere;
    word-break:normal;
}

/* Kereszttábla változóválasztója se lógjon ki */
#bgcol{
    min-width:0;
    max-width:100%;
    width:min(100%, 650px);
}

/* A select + gomb szükség esetén törhessen új sorba */
.inline{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    align-items:center;
    max-width:100%;
    min-width:0;
}


/* =========================================================
   V0.3b – Crosstab dropdown width fix
   ========================================================= */

.inline{
    display:flex !important;
    flex-wrap:wrap !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    box-sizing:border-box;
}

.inline > *{
    min-width:0 !important;
}

/* A háttérváltozó választó soha ne nyújtsa túl a panelt */
#bgcol{
    display:block;
    flex:1 1 420px;
    width:100% !important;
    max-width:650px !important;
    min-width:0 !important;
    box-sizing:border-box !important;

    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

/* A Create gomb maradjon mindig látható */
#crossBtn{
    flex:0 0 auto !important;
    max-width:100%;
}

/* A kereszttábla eredményének külső kerete se tudjon kilógni */
#crosstab{
    display:block;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow:hidden !important;
    box-sizing:border-box !important;
}

#crosstab > *{
    max-width:100%;
    min-width:0;
    box-sizing:border-box;
}

/* Maga a táblázat saját belső vízszintes scrollt kap */
#crosstab .table-wrap{
    display:block;
    width:100% !important;
    max-width:100% !important;
    overflow-x:auto !important;
    overflow-y:visible;
}


/* =========================================================
   V0.3c – definitive box overflow fix
   ========================================================= */

/* A width mindig tartalmazza a paddinget és border-t is */
*,
*::before,
*::after{
    box-sizing:border-box !important;
}

/* Az egész research rész nem nőhet túl a rendelkezésre álló helyen */
#researchView,
#researchView main,
.research-grid,
.research-grid > *,
.panel{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
}

/* A panel saját kerete sem lóghat ki */
.panel{
    overflow:hidden !important;
}

/* Minden közvetlen belső elem maradjon a panelen belül */
.panel > *{
    max-width:100% !important;
    min-width:0 !important;
}

/* Crosstab vezérlőterület */
#bgcol{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
}

/* A lenyíló + gomb inkább két sorba törjön, mint kilógjon */
#bgcol + #crossBtn{
    flex-shrink:0;
}

#crosstab{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow:hidden !important;
}

/* Csak a tényleges táblázat görgethető */
#crosstab .table-wrap{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    overflow-x:auto !important;
}

/* A táblázat lehet szélesebb, de kizárólag a scroll-dobozon belül */
#crosstab table{
    width:max-content !important;
    min-width:100% !important;
    max-width:none !important;
}


/* =========================================================
   Analysis readability
   ========================================================= */

.analysis-text{
  font-size:15px;
  line-height:1.65;
  max-width:100%;
}

.analysis-text p{
  margin:0 0 14px;
}

.analysis-heading{
  margin:24px 0 10px;
  padding-top:12px;
  border-top:1px solid var(--border);
  font-size:17px;
  line-height:1.3;
}

.analysis-heading:first-child{
  margin-top:0;
  padding-top:0;
  border-top:0;
}

.analysis-bullet{
  margin:7px 0 7px 18px;
  padding-left:4px;
}

.analysis-text strong{
  font-weight:700;
}

.analysis-text em{
  opacity:.85;
}


/* =========================================================
   Search limit panel
   ========================================================= */

.search-limit-card{
  max-width:680px;
  margin:20px auto;
  padding:28px;
  background:white;
  border:1px solid var(--border);
  border-radius:22px;
  text-align:center;
}

.search-limit-card h2{
  margin:8px 0;
}

.search-limit-actions{
  display:flex;
  justify-content:center;
  flex-wrap:wrap;
  gap:12px;
  margin:22px 0 14px;
}

.limit-demo-btn{
  cursor:default;
}


/* =========================================================
   Measurement level + scale summary
   ========================================================= */

.variable-meta{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
  margin:6px 0 8px;
}

.measure-badge,
.quantile-badge{
  display:inline-block;
  padding:4px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
  background:white;
}

.measure-scale{
  font-weight:800;
}

.quantile-badge{
  font-weight:500;
}

.summary-table{
  width:min(560px,100%);
}

.summary-table td:last-child,
.summary-table th:last-child{
  text-align:right;
}

.grouping-preview{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin-top:16px;
  padding-top:14px;
  border-top:1px solid var(--border);
}


/* =========================================================
   Scale variable: crosstab representation
   ========================================================= */

.crosstab-mode-box{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:14px;
  margin-top:18px;
  padding:14px 0 4px;
  border-top:1px solid var(--border);
}

.crosstab-mode-box label{
  display:flex;
  align-items:center;
  gap:5px;
  cursor:pointer;
}


/* 3D optional filter */

.filter-box{
  margin-top:14px;
  padding-top:12px;
  border-top:1px solid rgba(0,0,0,.10);
}

.filter-box .inline{
  margin-top:7px;
  flex-wrap:wrap;
}

#filterCol{
  min-width:240px;
}

#filterValue{
  min-width:160px;
}


/* Analysis card portraits */
.analysis-avatar{
  overflow:hidden;
  padding:0;
}

.analysis-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  border-radius:24px;
}

/* FIX: visible analysis portraits */
.analysis-card{
  display:flex !important;
  align-items:flex-start !important;
  gap:24px !important;
}

.analysis-avatar{
  width:180px !important;
  height:180px !important;
  min-width:180px !important;
  flex:0 0 180px !important;
  overflow:hidden !important;
  border-radius:24px !important;
  background:white !important;
}

.analysis-avatar img{
  width:180px !important;
  height:180px !important;
  object-fit:cover !important;
  display:block !important;
}

.analysis-card .bubble{
  flex:1 !important;
  min-width:0 !important;
}

@media(max-width:800px){
  .analysis-card{
    flex-direction:column !important;
  }
}

/* Smaller disable button */
.danger-mini{
  padding:5px 8px !important;
  font-size:11px !important;
  line-height:1.2 !important;
  border-radius:8px !important;
}

/* Match action buttons vertically */
.match-actions{
  display:flex !important;
  flex-direction:column !important;
  align-items:stretch !important;
  gap:6px !important;
  width:150px !important;
  flex:0 0 150px !important;
}

.match-actions button{
  width:100% !important;
  margin:0 !important;
  white-space:normal !important;
  line-height:1.2 !important;
}

@media(max-width:800px){
  .match-actions{
    width:100% !important;
    flex:1 1 auto !important;
  }
}

/* Match admin buttons same size */
.never-mini{
  padding:5px 8px !important;
  font-size:11px !important;
  line-height:1.2 !important;
  border-radius:8px !important;
}

/* Use variable button – same blue style as Refine results */
.match-actions > button:first-child{
  background:var(--purple) !important;
  color:white !important;
  border-color:var(--purple) !important;
  font-weight:700 !important;
}

/* Download report disabled state */
#downloadReportBtn:disabled{
  opacity:.38 !important;
  cursor:not-allowed !important;
  filter:grayscale(.35);
}

#downloadReportHuBtn:disabled{
  opacity:.38 !important;
  cursor:not-allowed !important;
  filter:grayscale(.35);
}
