/* =========================================================================
   Építőipari tervező — közös designrendszer (mobile-first)
   ========================================================================= */

:root {
  /* Színek */
  --bg:            #12151f;
  --bg-elevated:   #1a1f2e;
  --bg-card:       #1e2433;
  --bg-input:      #151a26;
  --bg-hover:      #252c3d;

  --border:        rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text:          #e8ecf4;
  --text-muted:    #9aa4b8;
  --text-faint:    #6b7488;

  --accent:        #4fc3f7;
  --accent-dark:   #29b6f6;
  --accent-soft:   rgba(79, 195, 247, 0.12);

  --success:       #4caf50;
  --success-soft:  rgba(76, 175, 80, 0.14);
  --warning:       #ffa726;
  --warning-soft:  rgba(255, 167, 38, 0.14);
  --danger:        #ef5350;
  --danger-soft:   rgba(239, 83, 80, 0.14);
  --purple:        #ab47bc;

  /* Modul-színek */
  --mod-insulation: #ff9800;
  --mod-roofing:    #ef5350;
  --mod-utilities:  #26c6da;

  /* Méretek */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --touch:     46px;          /* minimális érintőfelület */
  --header-h:  56px;
  --bottomnav-h: 62px;
  --maxw:      1280px;

  --shadow:    0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 10px 32px rgba(0, 0, 0, 0.42);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
}

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

/* =========================================================================
   FEJLÉC
   ========================================================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.app-brand .logo { font-size: 1.25rem; }
.app-brand .brand-text { display: none; }

.header-nav { display: none; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Mentés-visszajelző */
.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  transition: color 0.2s, background 0.2s;
}
.save-state.saving { color: var(--warning); background: var(--warning-soft); }
.save-state.saved  { color: var(--success); background: var(--success-soft); }
.save-state.error  { color: var(--danger);  background: var(--danger-soft); }

/* =========================================================================
   ALSÓ NAVIGÁCIÓ (mobil)
   ========================================================================= */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 6px 2px;
  transition: color 0.15s;
}
.bottom-nav a .icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a:active { background: var(--bg-hover); }

/* =========================================================================
   ELRENDEZÉS
   ========================================================================= */

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 14px 24px;
}
.container.wide { max-width: 100%; }

.page-head { margin-bottom: 18px; }
.page-head h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.page-head .subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }

.section { margin-bottom: 26px; }
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 10px;
}

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

/* =========================================================================
   KÁRTYÁK
   ========================================================================= */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card.pad-0 { padding: 0; }
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 1rem;
}
.card-header .icon { font-size: 1.15rem; }

/* Kattintható modul-csempe */
.tile {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.tile:active { transform: scale(0.985); background: var(--bg-hover); }
.tile .tile-icon { font-size: 1.8rem; display: block; margin-bottom: 8px; }
.tile .tile-name { font-weight: 700; font-size: 1.05rem; }
.tile .tile-desc { color: var(--text-muted); font-size: 0.85rem; margin-top: 5px; }
.tile[data-module="INSULATION"] { border-left-color: var(--mod-insulation); }
.tile[data-module="ROOFING"]    { border-left-color: var(--mod-roofing); }
.tile[data-module="UTILITIES"]  { border-left-color: var(--mod-utilities); }

/* Statisztika-doboz */
.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  text-align: center;
}
.stat-box .value { font-size: 1.5rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-box .label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.stat-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.stat-line:last-child { border-bottom: none; }
.stat-line .label { color: var(--text-muted); }
.stat-line .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-line.highlight .value { color: var(--accent); font-size: 1.05rem; }

/* =========================================================================
   GOMBOK
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--touch);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06131c; }
.btn-success { background: var(--success); border-color: var(--success); color: #06170a; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #1a1000; }
.btn-danger  { background: var(--danger);  border-color: var(--danger);  color: #1a0505; }
.btn-ghost   { background: transparent; }
.btn-block   { width: 100%; }
.btn-sm      { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
.btn-icon    { min-height: 40px; width: 40px; padding: 0; }

/* =========================================================================
   ŰRLAPOK
   ========================================================================= */

.form-group { margin-bottom: 14px; }
.form-group > label,
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="number"], input[type="email"], input[type="tel"],
input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;          /* iOS: 16px alatt ránagyít a mezőre */
  transition: border-color 0.15s, background 0.15s;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}
input::placeholder { color: var(--text-faint); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%239aa4b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

input[type="range"] { width: 100%; height: 34px; accent-color: var(--accent); background: transparent; }
input[type="color"] { width: 46px; height: 40px; padding: 3px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit .unit { color: var(--text-faint); font-size: 0.85rem; white-space: nowrap; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch);
  cursor: pointer;
  font-size: 0.92rem;
}
.checkbox input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }

/* =========================================================================
   ÖSSZECSUKHATÓ SZEKCIÓ
   ========================================================================= */

details.collapsible {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
details.collapsible > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: var(--touch);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-faint);
  transition: transform 0.2s;
}
details.collapsible[open] > summary::after { transform: rotate(180deg); }
details.collapsible > .collapsible-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }

/* =========================================================================
   TÁBLÁZAT
   ========================================================================= */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 480px;
}
table.data th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; background: var(--bg-elevated); }

/* =========================================================================
   EGYÉB ELEMEK
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  background: var(--bg-hover);
  color: var(--text-muted);
}
.badge.accent  { background: var(--accent-soft);  color: var(--accent); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state .icon { font-size: 2.6rem; display: block; margin-bottom: 12px; opacity: 0.7; }
.empty-state h3 { font-size: 1.05rem; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 0.88rem; margin-bottom: 16px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  font-size: 0.88rem;
  color: var(--text);
}
.alert.warning { border-left-color: var(--warning); background: var(--warning-soft); }
.alert.danger  { border-left-color: var(--danger);  background: var(--danger-soft); }

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.86rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

footer.app-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.76rem;
  padding: 22px 14px 8px;
}

/* =========================================================================
   RESZPONZÍV — tablet és asztali
   ========================================================================= */

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .app-brand .brand-text { display: inline; }
  .container { padding: 20px 20px 28px; }
  .page-head h1 { font-size: 1.55rem; }
}

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }

  .grid-3 { grid-template-columns: repeat(3, 1fr); }

  .header-nav {
    display: flex;
    align-items: stretch;
    height: var(--header-h);
    margin-left: 18px;
    gap: 2px;
  }
  .header-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: color 0.15s, background 0.15s;
  }
  .header-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
  .header-nav a.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-soft); }

  .toast-host { bottom: 22px; }
  .container { padding: 26px 24px 32px; }
}

/* =========================================================================
   F1 — PROJEKTKEZELÉS ÉS ANYAGKATALÓGUS KOMPONENSEI
   ========================================================================= */

.breadcrumb { margin-bottom: 12px; font-size: 0.86rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.action-bar form { display: contents; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar input[type="search"] { flex: 2 1 190px; }
.filter-bar select { flex: 1 1 150px; }
.filter-bar .checkbox { flex: 0 0 auto; }
.nowrap { white-space: nowrap; }

.chip-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.input-title { font-size: 1.05rem !important; font-weight: 600; }

.tile-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.tile-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-faint);
}
.tile-meta .price { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

.muted-card { color: var(--text-muted); font-size: 0.88rem; }
.row-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }

.section-title .count { color: var(--text-faint); font-weight: 500; }

/* Modulválasztó az új projekt űrlapon */
.type-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.type-option input { position: absolute; opacity: 0; pointer-events: none; }
.type-option .type-icon { font-size: 1.3rem; }
.type-option .type-label { font-size: 0.88rem; font-weight: 600; line-height: 1.25; }
.type-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Anyagkatalógus sorok */
.mat-list { display: flex; flex-direction: column; gap: 6px; }
.mat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.mat-row.inactive { opacity: 0.5; }
.mat-row form { display: flex; }
.mat-main { flex: 1 1 190px; min-width: 0; }
.mat-name { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.mat-meta { font-size: 0.74rem; color: var(--text-faint); margin-top: 2px; }
.mat-price { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.mat-price input { width: 104px; min-height: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.mat-price .unit { font-size: 0.76rem; color: var(--text-faint); min-width: 44px; }
.mat-active { min-height: 40px; }
.mat-del { min-height: 40px; width: 34px; padding: 0; color: var(--text-faint); border-color: transparent; }
.mat-del:hover { color: var(--danger); }

@media (min-width: 640px) {
  .type-options { grid-template-columns: repeat(4, 1fr); }
  .type-option { flex-direction: column; justify-content: center; text-align: center; gap: 4px; min-height: 82px; }
}

/* =========================================================================
   F2 — SZIGETELÉS: 3D SZERKESZTŐ ÉS KALKULÁTOR
   ========================================================================= */

body:has(.editor-layout) .app-footer { display: none; }

.editor-layout { display: flex; flex-direction: column; }

.viewport-wrap {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--bg);
}
#viewport {
  height: 44vh;
  min-height: 240px;
  background: #8fc7e8;
  overflow: hidden;
}
#viewport canvas { display: block; width: 100% !important; height: 100% !important; }

.viewport-actions {
  position: absolute;
  left: 10px; right: 10px; top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.viewport-actions > * { pointer-events: auto; }
.viewport-stat {
  background: rgba(10, 14, 22, 0.72);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  backdrop-filter: blur(6px);
}
.viewport-actions .btn { background: rgba(10, 14, 22, 0.72); backdrop-filter: blur(6px); }
.viewport-hint {
  position: absolute;
  left: 10px; bottom: 8px;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(10, 14, 22, 0.55);
  padding: 4px 9px;
  border-radius: 999px;
}

.editor-side { padding: 12px 12px 20px; }
.editor-head { margin-bottom: 12px; }
.editor-head .row { margin-bottom: 10px; }

.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 14px;
  position: sticky;
  top: calc(var(--header-h) + 44vh);
  z-index: 30;
}
.tab-btn {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent-soft); color: var(--accent); }

.wall-card > summary { gap: 8px; }
.wall-card .wall-name { font-size: 0.92rem; }
.wall-card .badge { margin-left: auto; }

.opening-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}
.opening-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.opening-card .row { margin-bottom: 8px; }
.opening-card .form-group { margin-bottom: 8px; }

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.slider-row > span { font-size: 0.78rem; color: var(--text-muted); width: 52px; flex: none; }
.slider-row input[type="range"] { flex: 1; }
.slider-row input[type="number"] { width: 78px; flex: none; min-height: 38px; }

.target-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.target-card.on { border-left-color: var(--accent); background: var(--bg-hover); }
.target-card .target-body { display: none; padding-top: 6px; }
.target-card.on .target-body { display: block; }
.target-card .row { margin-bottom: 4px; }

/* Kalkulátor */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.result-card .result-label { font-size: 0.78rem; color: var(--text-muted); }
.result-card .result-value { font-size: 1.5rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.result-card .result-sub { font-size: 0.76rem; color: var(--text-faint); }
.result-card.warning { border-left-color: var(--warning); }
.result-card.success { border-left-color: var(--success); }
.result-card.success .result-value { color: var(--success); }
.result-card.purple { border-left-color: var(--purple); }
.result-card.roi { border-left-color: var(--accent); }

.chart-box { position: relative; height: 260px; }

.price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.price-row:last-child { border-bottom: none; }
.price-row > label { flex: 1 1 130px; font-size: 0.85rem; color: var(--text-muted); }
.price-row input { width: 96px; min-height: 40px; text-align: right; flex: none; }
.price-row .unit { font-size: 0.76rem; color: var(--text-faint); width: 46px; }

.calc-sticky {
  position: sticky;
  bottom: calc(var(--bottomnav-h) + 10px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  margin-top: 14px;
}

@media (min-width: 900px) {
  .editor-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    height: calc(100vh - var(--header-h));
  }
  .viewport-wrap { order: 2; position: relative; top: 0; height: 100%; }
  #viewport { height: 100%; }
  .editor-side { order: 1; overflow-y: auto; border-right: 1px solid var(--border); }
  .tab-bar { top: 0; }
  .calc-sticky { bottom: 16px; }
}

.mini-viewport {
  height: 220px;
  background: #8fc7e8;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  position: relative;
}
.mini-viewport canvas { display: block; width: 100% !important; height: 100% !important; }
.result-card small { font-size: 0.72rem; color: var(--text-faint); font-weight: 600; }

/* =========================================================================
   F4 — 2D ALAPRAJZ ÉS GÉPÉSZET
   ========================================================================= */

#viewport.floorplan-wrap { background: #10141f; height: 44vh; min-height: 240px; overflow: hidden; }
#floorplan { width: 100%; height: 100%; display: block; touch-action: none; }

.fp-grid line { stroke: rgba(255, 255, 255, 0.07); }
.fp-room { cursor: move; }
.fp-room .fp-label { fill: #fff; font-weight: 700; pointer-events: none; }
.fp-room .fp-size { fill: rgba(255, 255, 255, 0.65); pointer-events: none; }
.fp-room .fp-demand { fill: #ffd54f; font-weight: 700; pointer-events: none; }
.fp-room .fp-handle { fill: var(--accent); stroke: #0b0f18; stroke-width: 0.05; cursor: nwse-resize; opacity: 0.85; }
.fp-room.selected .fp-handle { opacity: 1; }

.nested-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.nested-row input[type="number"] { width: 72px; min-height: 38px; }
.nested-row .checkbox { min-height: 38px; font-size: 0.8rem; }

.room-card > summary { gap: 8px; }
.room-card .badge { margin-left: auto; }

table.data tr.group-row td { background: var(--bg-elevated); color: var(--text-muted); }

@media (min-width: 900px) {
  #viewport.floorplan-wrap { height: 100%; }
}

/* --- Gépészet: falak, nyílászárók és fűtőtestek szerkesztése --- */

.wall-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.wall-row:last-of-type { border-bottom: none; }
.wall-row .wall-name { flex: 0 0 108px; font-size: 0.82rem; color: var(--text-muted); }
.wall-row .wall-name small { color: var(--text-faint); }
.wall-row select { flex: 1; min-height: 38px; font-size: 0.85rem; }
.wall-row .wall-loss { flex: 0 0 52px; text-align: right; font-size: 0.78rem; color: var(--warning); font-variant-numeric: tabular-nums; }

.opening-row {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  margin-bottom: 7px;
}
.opening-row > select { min-height: 38px; font-size: 0.85rem; margin-bottom: 6px; }
.opening-fields { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.opening-fields label { font-size: 0.74rem; color: var(--text-faint); }
.opening-fields input[type="number"] { width: 68px; min-height: 36px; }
.opening-fields .checkbox { min-height: 36px; font-size: 0.78rem; gap: 5px; }

.radiator-row {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 7px;
}
.radiator-slot { font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; }
.radiator-slot small { font-weight: 400; color: var(--text-faint); }
.radiator-row select { min-height: 38px; font-size: 0.82rem; }
.radiator-chosen { font-size: 0.78rem; color: var(--accent); margin-top: 5px; font-weight: 600; }

.fp-wall { pointer-events: none; }
.fp-window, .fp-door { pointer-events: none; }
.fp-room .fp-handle { r: 0.28; }

/* =========================================================================
   BELÉPÉS, REGISZTRÁCIÓ ÉS FELHASZNÁLÓI MENÜ
   ========================================================================= */

body.auth-page { padding-bottom: 0; background: radial-gradient(circle at 50% 0%, #1b2438 0%, var(--bg) 60%); }

.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}
.auth-brand .logo { font-size: 1.6rem; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.4rem; }
.auth-card .subtitle { color: var(--text-muted); font-size: 0.88rem; margin: 4px 0 18px; }
.auth-switch { margin-top: 16px; text-align: center; font-size: 0.88rem; color: var(--text-muted); }
.auth-foot { font-size: 0.76rem; color: var(--text-faint); text-align: center; }

.user-menu { position: relative; }
.user-menu > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  padding: 5px 9px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 0.85rem;
  max-width: 190px;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu .user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #06131c;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.user-menu .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 300;
}
.user-dropdown .user-email {
  font-size: 0.75rem;
  color: var(--text-faint);
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  word-break: break-all;
}
.user-dropdown a, .user-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 8px;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  border-radius: 6px;
  cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-hover); }
.user-dropdown button { color: var(--danger); }

table.kv-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.kv-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
table.kv-table td:first-child { color: var(--text-muted); width: 45%; }
table.kv-table tr:last-child td { border-bottom: none; }

@media (min-width: 640px) {
  .user-menu .user-name { display: inline; }
}
