:root{
  --bg:#f3f5f9;
  --surface:#ffffff;
  --surface-soft:#eef5ff;
  --surface-muted:#f8fafc;
  --line:#dbe3ef;
  --line-strong:#b7cef3;
  --text:#111827;
  --muted:#667085;
  --blue:#1567d8;
  --blue-2:#2f8cff;
  --blue-soft:#eaf3ff;
  --good:#1f8f62;
  --warn:#b7791f;
  --bad:#c24134;
  --shadow:0 16px 40px rgba(15,23,42,.08);
  --shadow-soft:0 8px 18px rgba(15,23,42,.06);
  --radius:22px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  min-height:100vh;
  background:
    radial-gradient(circle at top right,rgba(47,140,255,.10),transparent 22%),
    linear-gradient(180deg,#f8fbff 0%,var(--bg) 26%,#eef3f8 100%);
  color:var(--text);
  font:14px/1.5 "Segoe UI Variable Text","SF Pro Display","Segoe UI",Arial,sans-serif;
}
a{color:inherit}
button,input,select,textarea{font:inherit}
.app{max-width:1280px;margin:0 auto;padding:18px 14px calc(28px + env(safe-area-inset-bottom,0px))}
.topbar,.quickbar,.filters,.editor-actions,.card-actions,.editor-grid,.preview,.analysis-top{display:flex;gap:12px}
.topbar,.quickbar,.filters,.editor-actions{flex-wrap:wrap}
.topbar{align-items:flex-start;justify-content:space-between;margin-bottom:12px}
.brand h1{margin:0;font-size:28px;letter-spacing:-.03em;color:var(--blue)}
.brand p{margin:5px 0 0;color:var(--muted);max-width:620px}
.btn,.chip,select,input,textarea{
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--surface);
  color:var(--text);
}
.btn,.chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:48px;
  padding:11px 16px;
  text-decoration:none;
  cursor:pointer;
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease,background .18s ease;
}
.btn:hover,.chip:hover{transform:translateY(-1px);border-color:var(--line-strong);box-shadow:var(--shadow-soft)}
.btn{font-weight:700}
.btn.primary{
  background:linear-gradient(135deg,var(--blue),var(--blue-2));
  border-color:var(--blue);
  color:#fff;
}
.btn.alt{
  background:var(--blue-soft);
  color:var(--blue);
  border-color:#c9defc;
}
.btn.danger{
  background:#fff4f2;
  color:var(--bad);
  border-color:#f5c0b9;
}
.quickbar,.panel,.card,.summary-card,.editor,.empty{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.top-actions{gap:10px}
.quickbar{
  align-items:flex-end;
  justify-content:space-between;
  padding:14px;
}
.quickbar .grow{flex:1 1 320px}
.quickbar input,.quickbar select,.editor input,.editor select,.editor textarea{
  width:100%;
  min-height:54px;
  padding:14px 15px;
  outline:none;
  background:var(--surface);
}
.quickbar input:focus,.quickbar select:focus,.editor input:focus,.editor select:focus,.editor textarea:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 4px rgba(21,103,216,.12);
}
input::placeholder,textarea::placeholder{color:#98a2b3}
.editor textarea{min-height:110px;resize:vertical}
.field-block{display:flex;flex-direction:column;gap:8px;min-width:0}
.field-label{
  color:#6b7a90;
  font-size:11px;
  font-weight:800;
  letter-spacing:.14em;
  text-transform:uppercase;
}
.help{color:var(--muted);font-size:12px;margin-top:6px}
.summary{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  margin:14px 0;
}
.summary-filter{
  appearance:none;
  width:100%;
  min-height:118px;
  padding:18px 16px 16px;
  text-align:left;
  position:relative;
  overflow:hidden;
  cursor:pointer;
  background:linear-gradient(180deg,#fff 0%,#f8fbff 100%);
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease;
}
.summary-filter::before{
  content:"";
  position:absolute;
  top:0;left:0;right:0;
  height:4px;
  background:linear-gradient(90deg,var(--blue),#7cb9ff);
}
.summary-filter.active{
  border-color:var(--blue);
  box-shadow:0 0 0 2px rgba(21,103,216,.10),var(--shadow);
}
.summary-card span{
  display:block;
  color:#6b7a90;
  font-size:11px;
  font-weight:800;
  letter-spacing:.16em;
  text-transform:uppercase;
}
.summary-card strong{
  display:block;
  margin-top:16px;
  font-size:34px;
  line-height:1;
  letter-spacing:-.05em;
  color:#101828;
}
.filters{margin:0 0 14px;align-items:center}
.chips{display:flex;gap:10px;overflow:auto;padding:0 0 2px}
.chip{
  min-height:40px;
  padding:8px 13px;
  white-space:nowrap;
  color:#60708a;
  background:var(--surface);
}
.chip.active{
  background:var(--blue-soft);
  color:var(--blue);
  border-color:#c8ddfb;
}
.cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.card{
  padding:0;
  overflow:hidden;
}
.card-open{cursor:pointer;transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease}
.card-open:hover{transform:translateY(-2px);border-color:#bfd4f5}
.card-open:focus-visible{outline:none;box-shadow:0 0 0 2px rgba(21,103,216,.18),var(--shadow)}
.card-media{
  position:relative;
  background:#dfe7f2;
  min-height:220px;
}
.card-image{
  display:block;
  width:100%;
  height:220px;
  object-fit:cover;
}
.card-image-fallback{
  display:flex;
  align-items:flex-end;
  width:100%;
  height:220px;
  padding:18px;
  background:
    linear-gradient(180deg,rgba(0,0,0,.08) 0%,rgba(0,0,0,.42) 100%),
    linear-gradient(135deg,#d9e8ff 0%,#b5d4ff 42%,#8cbcff 100%);
}
.card-image-fallback span{
  color:#fff;
  font-size:20px;
  font-weight:800;
  letter-spacing:-.02em;
  max-width:180px;
}
.card-media-overlay{
  position:absolute;
  left:14px;
  right:14px;
  bottom:14px;
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:10px;
}
.card-media-source{
  padding:7px 11px;
  border-radius:999px;
  background:rgba(17,24,39,.72);
  color:#fff;
  font-size:12px;
  font-weight:700;
  backdrop-filter:blur(8px);
}
.card-shell{padding:16px}
.headline{align-items:flex-start;justify-content:space-between}
.headline h3,.card-shell h3{
  margin:10px 0 0;
  font-size:20px;
  line-height:1.24;
  letter-spacing:-.02em;
}
.sub{margin:6px 0 0;color:var(--muted)}
.card-price-label{
  font-size:11px;
  font-weight:800;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:#6b7a90;
}
.card-price-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-top:8px;
}
.card-price{
  font-size:30px;
  line-height:1;
  letter-spacing:-.05em;
  color:var(--blue);
}
.card-status-pill{
  padding:7px 11px;
  border-radius:999px;
  background:#f4f8fe;
  color:#2b4f83;
  border:1px solid #d8e5fa;
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}
.badge-row{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0 10px}
.badge{
  display:inline-flex;
  align-items:center;
  padding:7px 11px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#f8fafc;
  color:#516176;
  font-size:12px;
  font-weight:800;
  letter-spacing:.03em;
}
.decision-strong{background:#ebfff4;color:var(--good);border-color:#bfe8d3}
.decision-negotiate,.decision-borderline{background:var(--blue-soft);color:var(--blue);border-color:#c9defc}
.decision-walk,.decision-risk{background:#fff4f2;color:var(--bad);border-color:#f5c0b9}
.decision-draft{background:#f5f7fa;color:#5b667a;border-color:#d9e1ea}
.strategy-under{background:#ecfdf3;color:var(--good);border-color:#bfe8d3}
.strategy-close{background:#fff8eb;color:var(--warn);border-color:#f4dbab}
.strategy-over{background:#fff4f2;color:var(--bad);border-color:#f5c0b9}
.card-kpi-strip{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin:16px 0 12px;
}
.card-kpi{
  padding:12px;
  border-radius:16px;
  background:#f7fbff;
  border:1px solid #dbe8fa;
}
.card-kpi span{
  display:block;
  font-size:11px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:#6b7a90;
}
.card-kpi strong{
  display:block;
  margin-top:8px;
  font-size:16px;
  line-height:1.2;
  color:#101828;
}
.card-footnote{
  margin:0 0 14px;
  color:var(--muted);
  font-size:13px;
}
.card-actions{
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.card-actions .left,.card-actions .right{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.card-actions select{min-width:150px;padding:12px 12px}
.empty{padding:28px;text-align:center;color:var(--muted)}
.overlay{
  position:fixed;
  inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  padding:14px;
  background:rgba(17,24,39,.28);
  backdrop-filter:blur(10px);
  z-index:50;
}
.overlay.open{display:flex}
.editor{
  width:min(1140px,100%);
  max-height:calc(100dvh - 28px);
  overflow:auto;
  padding:0;
  background:#fff;
}
.settings-card{width:min(620px,100%)}
.editor-head{
  position:sticky;
  top:0;
  z-index:8;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:0;
  padding:18px 20px 14px;
  background:rgba(255,255,255,.96);
  border-bottom:1px solid var(--line);
}
.editor-head h2{margin:0;font-size:26px;letter-spacing:-.03em}
.editor-head p{margin:6px 0 0;color:var(--muted)}
.editor-grid{
  display:grid;
  grid-template-columns:1.08fr .92fr;
  gap:18px;
  padding:18px;
  background:var(--surface-muted);
}
.capture-panel,.result-panel{
  background:#fff;
  border:1px solid var(--line);
  box-shadow:none;
}
.result-panel{
  position:sticky;
  top:90px;
  align-self:start;
  background:linear-gradient(180deg,#f7fbff 0%,#fff 100%);
  border-color:#d6e5fb;
}
.panel{padding:18px}
.panel h4{
  margin:0 0 10px;
  font-size:12px;
  font-weight:800;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:#6b7a90;
}
.fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.quick-fields{grid-template-columns:repeat(3,minmax(0,1fr));margin-top:12px}
.fields .wide{grid-column:1/-1}
.analysis-top{flex-wrap:wrap;align-items:center;margin-bottom:12px}
.analysis-kpis{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.result-kpis{margin-top:14px}
.analysis-box{
  padding:14px;
  border-radius:18px;
  background:#fff;
  border:1px solid #dbe7f8;
}
.analysis-box span{
  display:block;
  font-size:11px;
  font-weight:800;
  letter-spacing:.12em;
  text-transform:uppercase;
  color:#6b7a90;
}
.analysis-box strong{
  display:block;
  margin-top:8px;
  font-size:18px;
  line-height:1.2;
  color:#101828;
}
.result-note{color:var(--muted);font-size:12px;margin-top:10px}
.reasons{margin:12px 0 0;padding-left:18px;color:var(--muted)}
.reasons li{margin:5px 0}
.preview{
  display:grid;
  grid-template-columns:120px 1fr;
  align-items:center;
  gap:14px;
  margin-top:12px;
  padding:12px;
  border-radius:18px;
  background:#f9fbff;
  border:1px solid #dbe7f8;
}
.preview img{
  width:120px;
  height:96px;
  object-fit:cover;
  border-radius:16px;
  border:1px solid var(--line);
  background:#dfe7f2;
}
.preview .muted{color:var(--muted)}
.address-quick{
  margin-top:14px;
  padding:14px;
  border-radius:18px;
  background:#f9fbff;
  border:1px solid #dbe7f8;
}
.address-quick.missing{
  background:#edf5ff;
  border-color:#cbdffb;
}
.address-quick-copy{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-bottom:10px;
}
.address-quick-copy strong{
  font-size:12px;
  font-weight:800;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:#6b7a90;
}
.address-fields{grid-template-columns:1.15fr .85fr}
details{
  margin-top:18px;
  padding-top:14px;
  border-top:1px solid var(--line);
}
summary{
  cursor:pointer;
  color:var(--blue);
  font-weight:800;
}
.section-divider{
  height:1px;
  background:var(--line);
  margin:18px 0 12px;
}
.editor-actions{
  justify-content:space-between;
  align-items:center;
  margin-top:0;
  padding:16px 18px calc(16px + env(safe-area-inset-bottom,0px));
  position:sticky;
  bottom:0;
  background:rgba(255,255,255,.96);
  border-top:1px solid var(--line);
  z-index:9;
}
.editor-actions .left,.editor-actions .right{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.comp-list{display:grid;gap:12px;margin:12px 0}
.comp-card{
  padding:14px;
  border-radius:18px;
  background:#fff;
  border:1px solid var(--line);
}
.comp-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.mini-summary{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
  margin-bottom:8px;
}
.mini-summary span{
  padding:8px 11px;
  border-radius:999px;
  background:#f7fbff;
  border:1px solid #dbe7f8;
  color:#5f6f87;
  font-size:12px;
  font-weight:700;
}
.empty-inline{
  padding:12px;
  border-radius:16px;
  background:#f8fafc;
  border:1px dashed var(--line);
  color:var(--muted);
  margin:12px 0;
}
@media (max-width:1024px){
  .summary{grid-template-columns:repeat(2,minmax(0,1fr))}
  .cards{grid-template-columns:1fr}
  .editor-grid{grid-template-columns:1fr}
  .result-panel{position:static}
}
@media (max-width:700px){
  .app{padding:12px 12px calc(22px + env(safe-area-inset-bottom,0px))}
  .topbar{
    position:sticky;
    top:0;
    z-index:18;
    padding:10px 0 0;
    background:linear-gradient(180deg,rgba(243,245,249,.96) 0%,rgba(243,245,249,.86) 100%);
    backdrop-filter:blur(12px);
  }
  .brand h1{font-size:22px}
  .brand p{font-size:13px}
  .top-actions{
    width:100%;
    overflow:auto;
    flex-wrap:nowrap;
    padding-bottom:2px;
  }
  .quickbar{
    position:sticky;
    top:104px;
    z-index:17;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
    padding:12px;
  }
  .quickbar .field-block.grow{grid-column:1/-1}
  .search-block{order:1}
  .quickbar .field-block.grow:not(.search-block){order:2}
  #importBtn{order:3}
  #newBtn{order:4}
  .summary{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
    margin-top:12px;
  }
  .summary-filter{
    min-height:102px;
    padding:14px;
    border-radius:20px;
  }
  .summary-card strong{
    margin-top:14px;
    font-size:30px;
  }
  .filters{margin-top:12px}
  .chips{gap:8px}
  .cards{grid-template-columns:1fr;gap:12px}
  .card-media,.card-image,.card-image-fallback{height:180px;min-height:180px}
  .card-image-fallback span{font-size:18px}
  .card-shell{padding:14px}
  .card-price{font-size:28px}
  .card-kpi-strip{grid-template-columns:1fr;gap:8px}
  .card-actions,.editor-actions{align-items:stretch}
  .card-actions .left,.card-actions .right,.editor-actions .left,.editor-actions .right{
    width:100%;
  }
  .card-actions .left{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:8px;
  }
  .card-actions .right select{width:100%}
  .overlay{padding:0}
  .editor{
    width:100%;
    height:100dvh;
    max-height:none;
    border-radius:0;
  }
  .editor-head{
    padding:14px 14px 12px;
  }
  .editor-grid{
    display:flex;
    flex-direction:column;
    gap:12px;
    padding:0;
    background:#fff;
  }
  .capture-panel,.result-panel{
    border:none;
    border-radius:0;
    box-shadow:none;
  }
  .capture-panel{order:1}
  .result-panel{
    order:2;
    background:#fff;
  }
  .panel{
    padding:14px;
    border-bottom:8px solid #f3f5f9;
  }
  .preview{
    grid-template-columns:1fr;
    padding:0;
    background:none;
    border:none;
    border-radius:0;
  }
  .preview img{
    width:100%;
    height:220px;
    border-radius:18px;
  }
  .fields,.quick-fields,.analysis-kpis,.address-fields{grid-template-columns:1fr}
  .editor-actions{
    padding:12px 12px calc(12px + env(safe-area-inset-bottom,0px));
  }
  .editor-actions .left>*,
  .editor-actions .right>*,
  .quickbar .btn{
    min-height:52px;
  }
}
