/*
 * NB — rel/flyout tuzilmasi: #sidebar DOIM ixcham ikon-rel (52px, hech qachon
 * kengaymaydi/torraymaydi) — GIS platformalarida (ArcGIS kabi) odatiy uslub.
 * Loyihalar ro'yxati esa ALOHIDA #project-flyout elementi — rel yonida
 * suzuvchi panel sifatida ochiladi/yopiladi (js/panelResizer.js:toggleSidebar
 * endi shu elementga "open" klassini toggle qiladi).
 */
#app{
  display: grid;
  grid-template-columns: var(--rail-w) var(--map-real) 5px var(--map-topo);
  grid-template-rows: 1fr auto;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

#sidebar{ grid-row: 1 / span 2; }
#panel-real{ grid-row: 1; }
#panel-resizer{ grid-row: 1; }
#panel-topo{ grid-row: 1; }

/* ===== HISOBOT bo'limi — xarita/jadval o'rnini (rel'dan tashqari BUTUN
   qolgan maydonni) egallaydi. #sidebar BU YERDA HAM tegilmaydi — u alohida
   grid katakda, doim ixcham holda qoladi (js/report.js). ===== */
#panel-report{
  grid-column: 2 / 5;
  grid-row: 1 / span 2;
  display: none;
  min-width: 0;
  min-height: 0;
}
#app.report-mode #panel-real,
#app.report-mode #panel-resizer,
#app.report-mode #panel-topo,
#app.report-mode #panel-table{ display: none; }
#app.report-mode #panel-report{ display: flex; }

/* ===== Bitta umumiy jadval paneli — ikkala xarita ostida, to'liq enda ===== */
#panel-table{
  grid-column: 2 / 5;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  background: var(--color-panel);
  border-top: 1px solid var(--color-border);
  overflow: hidden;
  min-width: 0;
}

/* ===== Sidebar: default = ixcham ikon-rel (icon rail), ODATIY sahifa
   mavzusi (--color-panel/--color-border) bilan — alohida majburiy to'q
   palitra emas, shuning uchun yorug' rejimda ham yengil/nafis ko'rinadi va
   qorong'i rejimda tabiiy ravishda qorayadi. #sidebar.collapsed = to'liq
   ochilgan (expanded) holat, xuddi shu tokenlar bilan. ===== */
/* ===== REL — doim ixcham (52px), hech qachon kengaymaydi. ===== */
#sidebar{
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  padding: 14px 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-panel);
  z-index: 20;
  color: var(--color-text-muted);
}
#sidebar .brand-icon{
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, var(--color-primary-light), var(--color-primary-dark));
  border-radius: 11px;
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}

/* "Loyihalar" ikonkasi — flyout panelni ochadi/yopadi. */
.rail-icon-btn{
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s var(--ease);
}
.rail-icon-btn:hover{
  background: var(--color-bg);
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
}
.rail-icon-btn.active{
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ===== FLYOUT — rel yonida suzuvchi panel (loyihalar ro'yxati). Rel eni
   o'zgarmagani uchun karta joylashuviga TA'SIR QILMAYDI — faqat kartalar
   ustidan yengil soya bilan ochiladi/yopiladi. ===== */
#project-flyout{
  position: fixed;
  top: 0;
  left: var(--rail-w);
  width: min(280px, 82vw);
  height: 100vh;
  height: 100dvh;
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  z-index: 1100;
  color: var(--color-text);
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s var(--ease), opacity .18s var(--ease);
}
#project-flyout.open{
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* ===== "Hisobot" loyiha-tanlash flyouti — #project-flyout bilan bir xil
   joylashuv/ko'rinish, faqat o'z holati (open klassi) mustaqil. ===== */
#project-flyout .sidebar-section{
  animation: rail-content-in .22s var(--ease) both;
}
#project-flyout .sidebar-section:nth-of-type(2){ animation-delay: .03s; }
#project-flyout .sidebar-section:nth-of-type(3){ animation-delay: .06s; }
@keyframes rail-content-in{
  from{ opacity: 0; transform: translateX(-4px); }
  to{ opacity: 1; transform: none; }
}

.sidebar-brand{
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding-bottom: 16px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--color-border);
}
.brand-text{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.brand-title{
  font-family: Georgia, "Palatino Linotype", "Segoe UI", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.005em;
  line-height: 1.15;
}
.brand-subtitle{
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .035em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section-title{
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--color-text-faint);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.layers-tree{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.layer-item{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  transition: background .12s ease;
}
.layer-item:hover{ background: var(--color-bg); }
.layer-item input{ cursor: pointer; }
.layers-subtitle{
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 8px 0 2px;
  padding-left: 4px;
}

.sidebar-list-empty{
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 8px 0;
}

.project-item{
  border: 1px solid var(--color-border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  overflow: hidden;
  background: var(--color-panel-alt);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  animation: rail-content-in .18s var(--ease) both;
}
.project-item:hover{ border-left-color: var(--color-border-strong); background: var(--color-bg); }
.project-item-header{
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
}
.project-item-header::before{
  content: '🚏';
  font-size: 13px;
  flex-shrink: 0;
}
.project-layers{
  padding: 3px 10px 6px 10px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.project-layers .layer-item{
  font-weight: 500;
  padding: 3px 4px;
  font-size: 12px;
}
.project-layers .layer-item-all{
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 3px;
  padding-bottom: 5px;
}
.project-item.active{
  border-color: var(--color-primary);
  border-left-color: var(--color-accent);
  background: var(--color-panel);
  box-shadow: var(--shadow-xs);
}
.project-item-main{
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.project-item-name{
  white-space: nowrap;
  flex-shrink: 0;
}
.project-item-dept{
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Kontekst menyu (o'ng tugma) ===== */
.context-menu{
  position: absolute;
  z-index: 2000;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
}
.context-menu-item{
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-text);
  transition: background .12s ease;
}
.context-menu-item:hover{ background: var(--color-bg); }
.context-menu-item.danger{ color: var(--color-danger); }

/* ===== "Yangi loyiha" modali ===== */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(10, 13, 20, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modal-fade .15s ease;
}
@keyframes modal-fade{ from{ opacity: 0; } to{ opacity: 1; } }
.modal-card{
  width: min(360px, calc(100vw - 32px));
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  animation: modal-pop .18s var(--ease);
}

/* ===== "Qo'shimcha belgi" — ikonka tanlash modali ===== */
.marker-icon-modal{ width: min(380px, calc(100vw - 32px)); }
.marker-icon-grid{
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0 4px;
}
.marker-icon-option{
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  font-size: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  transition: border-color .12s ease, transform .1s var(--ease), background .12s ease;
  font-family: "Segoe UI Emoji", "Noto Color Emoji", "Apple Color Emoji", sans-serif;
}
.marker-icon-option:hover{ border-color: var(--color-primary); transform: translateY(-1px); }
.marker-icon-option.selected{ border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 12%, var(--color-panel)); }

/* ===== "Koordinatani import qilish" — manba obyekt tanlash ro'yxati ===== */
.geom-import-list{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 4px;
  max-height: 220px;
  overflow-y: auto;
}
.geom-import-option{
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  transition: border-color .12s ease, background .12s ease;
}
.geom-import-option:hover{ border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 10%, var(--color-panel)); }
@keyframes modal-pop{ from{ opacity: 0; transform: translateY(6px) scale(.98); } to{ opacity: 1; transform: none; } }
.modal-title{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: 4px;
}

/* ===== Belgilangan obyektlarni ommaviy o'chirish modali ===== */
.bulk-delete-modal{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  background: var(--color-panel);
  border-radius: var(--radius-lg);
  padding: 24px 20px 20px;
  border-top: 4px solid var(--color-danger);
  box-shadow: var(--shadow-lg);
}
.bulk-delete-icon{
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(229,72,77,.12);
  color: var(--color-danger);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.bulk-delete-title{
  font-size: 17px;
  font-weight: 700;
}
.bulk-delete-count{
  font-size: 13px;
  color: var(--color-danger);
  font-weight: 600;
  background: rgba(229,72,77,.1);
  padding: 3px 10px;
  border-radius: 20px;
}
.bulk-delete-text{
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 4px 0 10px;
}
.bulk-delete-actions{
  display: flex;
  gap: 8px;
  width: 100%;
}
.bulk-delete-actions button{ flex: 1; }

.btn-danger{
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(229,72,77,.28);
  transition: background .15s ease, transform .12s var(--ease), box-shadow .15s ease;
}
.btn-danger:hover{ background: #c93a3e; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(229,72,77,.35); }
.btn-danger:active{ transform: translateY(0); }

.new-project-form{
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--color-panel);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.form-hint{
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: -4px;
}
.form-hint em{ font-style: normal; color: var(--color-text); }

/* ===== "Bekatlarni Excel'dan yuklash" modali ===== */
#excel-import-form{ width: 420px; max-width: calc(100vw - 40px); }
.excel-import-preview{
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.excel-import-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.excel-import-table th{
  position: sticky;
  top: 0;
  background: var(--color-panel-alt);
  padding: 4px 6px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.excel-import-table td{
  padding: 3px 6px;
  border-top: 1px solid var(--color-border);
}
.excel-import-table tr.excel-row-invalid{ background: color-mix(in srgb, var(--color-danger, #e5484d) 10%, transparent); color: var(--color-danger, #e5484d); }

.form-input{
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 13px;
  color: var(--color-text);
  width: 100%;
  transition: border-color .12s ease, background .12s ease;
}
.form-input:hover{ border-color: var(--color-border-strong); }
.form-input:focus{ outline: none; border-color: var(--color-primary); background: var(--color-panel); }

/* ===== REAL XARITA / TOPOLOGIK SXEMA panellari ===== */
.gis-panel{
  background: var(--color-panel);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 4px;
  min-width: 0;
  min-height: 0;
  position: relative;
}
#panel-topo{ box-shadow: var(--shadow-panel); z-index: 5; }

/* MUHIM: sarlavha (js/tools/toolPanel.js orqali) endi to'g'ridan-to'g'ri
   .map-wrap ICHIGA ko'chiriladi (xuddi style-edit-panel/road-form kabi) —
   shu sabab ANIQ xarita ustida, chap-yuqori burchakda suzuvchi (floating)
   kichik yorliq bo'lib turadi (position:absolute endi .map-wrap'ga nisbatan). */
.gis-panel-title{
  position: absolute;
  top: 8px;
  left: 16px;
  z-index: 700;
  padding: 4px 10px 4px 8px;
  background: color-mix(in srgb, var(--color-panel) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

/* Asbob tugmalari qatori (#instrument-menu) ham map-wrap ichiga ko'chirilgan
   (js/tools/toolPanel.js) — xarita ustida, gorizontal markazda, YUQORIDA
   suzuvchi ixcham panel. */
.instrument-grid-overlay{
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
}

/* "Excel'dan bekat yuklash" — chizish asboblaridan ALOHIDA. DOIM ko'rinmaydi
   (yashirin), faqat "Bekat" asbobi tanlanganda (.visible) paydo bo'ladi —
   xaritaning o'ng-yuqori burchagida, boshqa ixcham tugmalar bilan bir xil
   uslubda (kichik, dumaloq ikonka), qo'pol katta pill EMAS. */
.excel-import-fab{
  position: absolute;
  top: 8px;
  right: 16px;
  z-index: 700;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  background: color-mix(in srgb, var(--color-panel) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s var(--ease), border-color .15s ease, background .15s ease;
}
.excel-import-fab.visible{
  display: flex;
  animation: excel-import-fab-in .18s var(--ease) forwards;
}
@keyframes excel-import-fab-in{
  from{ opacity: 0; transform: translateY(-4px); }
  to{ opacity: 1; transform: translateY(0); }
}
.excel-import-fab:hover{
  border-color: var(--color-primary);
  background: var(--color-panel);
}
.excel-import-fab-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}
.excel-import-fab-label{ display: none; }

.map-wrap{
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}
.gis-map{
  position: absolute;
  inset: 0;
}
/* TOPOLOGIK SXEMA — bazaviy (tayl) xaritasiz, sxematik oq fon */
.gis-map-topo{
  background: #fafbfc;
}
:root[data-theme="dark"] .gis-map-topo{ background: #20232b; }
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]) .gis-map-topo{ background: #20232b; }
}

/* ===== O'ng panelni sudrab o'lchamini o'zgartirish tutqichi ===== */
#panel-resizer{
  cursor: col-resize;
  background: var(--color-border);
  position: relative;
  transition: background .15s ease;
}
#panel-resizer:hover,
#panel-resizer.resizing{
  background: var(--color-primary);
}
#panel-resizer::after{
  content: '';
  position: absolute;
  inset: 0 -3px;
}

/* ===== Right panel ===== */
#right-panel{
  background: var(--color-panel);
  border-left: 1px solid var(--color-border);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-panel);
  z-index: 5;
}

.panel-title{
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.panel-tabs{
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
  gap: 4px;
  flex-shrink: 0;
}
#panel-table .panel-tabs{ gap: 2px; }
.table-clear-btn{
  margin-left: auto;
  align-self: center;
  margin-right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.table-clear-btn:hover{ background: rgba(229,72,77,.1); color: var(--color-danger); border-color: var(--color-danger); }
.tab-btn{
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .12s ease, background .12s ease;
}
.tab-btn:hover{ color: var(--color-text); background: var(--color-bg); }
.tab-btn.active{
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.panel-table-wrap{
  flex: 0 0 220px;
  height: 220px;
  min-height: 0;
  overflow: auto;
}
#panel-table .table-section{ padding: 3px 16px 4px; }
#panel-table .tab-btn{ padding: 4px 10px; font-size: 12px; }
/* MUHIM: xaritalar MAKSIMAL kattalikda bo'lishi kerak — jadval ESA kamida
   3 ta qator ko'rinadigan, lekin imkon qadar kam joy egallaydigan qilib
   ixchamlashtirildi (sarlavha+3 qator taxminan 110px). */
#panel-table .panel-table-wrap{ flex-basis: var(--table-panel-height, 128px); height: var(--table-panel-height, 128px); }

/* ===== Jadval balandligini sudrab o'zgartirish (vaqtincha, sessiya davomida) ===== */
#table-height-resizer{
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 5;
}
#table-height-resizer:hover{ background: color-mix(in srgb, var(--color-primary) 25%, transparent); }
#panel-table{ position: relative; }

/* ===== Jadval bo'limini yopish/ochish — sidebar bilan bir xil doimiy mantiq ===== */
.table-toggle{
  flex-shrink: 0;
  width: 100%;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-faint);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  position: relative;
  transition: color .15s ease, transform .2s var(--ease);
}
.table-toggle::before{
  content: '';
  position: absolute;
  top: -1px;
  width: 30px;
  height: 1.5px;
  border-radius: 0 0 2px 2px;
  background: var(--color-border-strong);
  transition: background .15s ease;
}
.table-toggle:hover{ color: var(--color-primary); }
.table-toggle:hover::before{ background: var(--color-primary); }

.table-section{
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
}
.table-section.collapsed{
  flex: 0 0 0;
  height: 0;
}
.table-section.collapsed .panel-tabs,
.table-section.collapsed .panel-table-wrap{
  display: none;
}
.table-toggle.collapsed{ transform: rotate(180deg); }

.table-empty-msg{
  padding: 24px 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* ===================================================== */
/* ============ Tor ekranlar (mobil/planshet) =========== */
/* ===================================================== */
@media (max-width: 860px){
  html, body{ overflow-x: hidden; }

  /* Rel doim ko'rinadi (52px), qolgan joy bitta ustunga tushadi;
     kartalar va jadval endi gorizontal emas, vertikal qatorlarga taqsimlanadi. */
  #app{
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: minmax(240px, 42vh) minmax(240px, 42vh) auto;
  }

  #sidebar{ grid-row: 1 / span 3; grid-column: 1; }
  #panel-real{ grid-row: 1; grid-column: 2; }
  #panel-resizer{ display: none; }
  #panel-topo{ grid-row: 2; grid-column: 2; }
  #panel-table{ grid-row: 3; grid-column: 2; }

  /* Flyout kichik ekranlarda ham xuddi shunday (rel yonida suzuvchi panel) —
     faqat eni ekran kengligiga moslashadi. */
  #project-flyout{ width: min(82vw, 300px); }

  .table-toggle{ height: 22px; }

  /* Bosiladigan elementlar uchun qulayroq teginish maydoni. */
  .tab-btn{ padding: 10px 12px; }
  .create-option{ width: 38px; height: 38px; }
  .basemap-toggle{ padding: 6px; }
  .basemap-toggle .swatch{ width: 26px; height: 26px; }

  /* Jadval — ustunlar gorizontal skroll bilan, sahifa o'zi kengaymaydi. */
  #panel-table .panel-table-wrap{
    flex-basis: 200px;
    height: 200px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-section{ min-width: 0; }
  .panel-table-wrap{ width: 100%; }
}

/* ===== HISOBOT bo'limi ichki tuzilmasi — chapda "list"lar (A4 kichraytirilgan
   ko'rinishi) ustunchasi, o'ngda tanlangan listning katta A4 sahifasi
   (o'rtada, kulrang fonda, skrollanadigan). ===== */
.report-panel{
  background: var(--color-bg);
  overflow: hidden;
}
#report-list-panel{
  width: 220px;
  flex-shrink: 0;
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.report-project-title{
  padding: 12px 14px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-panel.report-no-project .report-project-title{ color: var(--color-text-faint); font-weight: 500; font-style: italic; }
.report-empty-hint{
  padding: 20px 14px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--color-text-faint);
}
.report-add-btn:disabled{ opacity: .4; cursor: not-allowed; }
.report-add-btn:disabled:hover{ background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }

.report-paper-size-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.report-paper-size-row select{
  padding: 3px 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--color-panel);
  cursor: pointer;
}
.report-list-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}
.report-add-btn{
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 15px;
  line-height: 1;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.report-add-btn:hover{ background: var(--color-bg); color: var(--color-primary); border-color: var(--color-primary); }

.report-list-items{ padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.report-list-item{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.report-list-thumb-wrap{ position: relative; width: 100%; }
.report-list-thumb{
  width: 100%;
  aspect-ratio: 210 / 297;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 3px;
  box-shadow: var(--shadow-xs);
  transition: border-color .12s ease;
}
.report-list-item.active .report-list-thumb{ border-color: var(--color-danger); }
.report-list-item:hover .report-list-thumb{ border-color: var(--color-primary); }
.report-list-name{
  width: 100%;
  text-align: center;
  font-size: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}
.report-list-name:hover, .report-list-name:focus{ border-color: var(--color-border); background: var(--color-bg); }
/* MUHIM: position:absolute + o'ziga xos z-index — avvalgi manfiy-margin
   usuli ba'zan tagida qolib, bosib bo'lmay qolardi (keyingi ro'yxat
   elementi ustidan bosilardi). Endi doim thumbnail burchagida, ishonchli
   bosiladigan holatda. */
.report-list-delete{
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  border-radius: 50%;
  border: none;
  background: var(--color-danger);
  color: #fff;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.report-list-item:hover .report-list-delete{ display: flex; }

#report-canvas-wrap{
  flex: 1;
  min-width: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 40px 24px;
  background: repeating-linear-gradient(45deg, var(--color-bg), var(--color-bg) 12px, var(--color-panel-alt) 12px, var(--color-panel-alt) 13px);
}
/* MUHIM: bu konteynerning HAQIQIY o'lchami (width/height) JS orqali
   (js/report.js -> updateReportPreviewScale) PASAYTIRILGAN (ekranga mos)
   qiymatga o'rnatiladi — ICHIDAGI `#report-canvas-scroll` esa TO'LIQ
   (formatga mos) o'lchamda qoladi, faqat CSS `transform:scale()` bilan
   vizual ravishda kichraytiriladi. Shu ikki qatlamli usul orqali: ekranda
   har doim bir xil, ko'rinadigan hajm saqlanadi, LEKIN DOM'ning haqiqiy
   piksel o'lchami (demak — PDF suratga olish sifati) hech qachon
   pasaymaydi. */
#report-canvas-scale-box{ overflow: hidden; }
#report-canvas-scroll{ display: flex; flex-direction: column; align-items: center; transform-origin: top center; }
/* MUHIM: sahifa o'lchami endi QOG'OZ FORMATI TANLOVCHISIGA (A4/A3/A2/A1)
   qarab JS orqali (js/report.js -> applyReportPaperSize) shu ikkita CSS
   o'zgaruvchiga yoziladi — standart qiymat A3 (297x420mm @96dpi). */
:root{
  --report-page-w: 1123px;
  --report-page-h: 1587px;
}
.report-page-title{
  width: var(--report-page-w);
  max-width: 100%;
  margin-bottom: 16px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.25;
  color: var(--color-text);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.report-page-a4{
  width: var(--report-page-w);
  min-height: var(--report-page-h);
  background: #fff;
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Xarita turidagi list — sahifa TO'LIQ xarita bilan qoplanadi, klipланган. */
.report-page-a4.report-page-map{ height: var(--report-page-h); padding: 0; }
.report-map-embed-inner{ width: 100%; height: 100%; transition: transform .25s ease; transform-origin: center center; }

/* Professional kartografik "neatline" — burchak koordinatalari (topografik
   xarita varaqlarida bo'lgani kabi), faqat sun'iy yo'ldosh/OSM turidagi
   hisobot xarita sahifalarida, xaritaning joriy ko'rinishidan avtomatik. */
.report-map-corner-tick{
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(31,36,48,.55);
  pointer-events: none;
  z-index: 5;
}
.report-map-corner-tick-nw{ top: 6px; left: 6px; border-right: none; border-bottom: none; }
.report-map-corner-tick-ne{ top: 6px; right: 6px; border-left: none; border-bottom: none; }
.report-map-corner-tick-sw{ bottom: 6px; left: 6px; border-right: none; border-top: none; }
.report-map-corner-tick-se{ bottom: 6px; right: 6px; border-left: none; border-top: none; }

.report-map-corner{
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 6px;
  margin: 10px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 9px;
  line-height: 1.3;
  color: #1f2430;
  background: rgba(255,255,255,.82);
  border-radius: 3px;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
}
.report-map-corner-ne, .report-map-corner-se{ text-align: right; align-items: flex-end; }

/* "Shartli belgilar" — topo_fonsiz oldindan ko'rishda, xarita ustida bo'sh
   joyga suzib joylashadigan karta (js/reportContent.js -> renderReportMapLegendOverlay). */
.report-map-legend{
  position: absolute;
  z-index: 6;
  background: #fff;
  border: 1px solid #a3a3a3;
  border-radius: 4px;
  padding: 6px 9px;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  pointer-events: none;
  white-space: nowrap;
}
.report-map-legend-title{
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #1e1e1e;
  margin-bottom: 4px;
}
.report-map-legend-cols{ display: flex; gap: 12px; }
.report-map-legend-col{ display: flex; flex-direction: column; gap: 3px; }
.report-map-legend-row{
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 8.5px;
  line-height: 1.2;
  color: #1f2430;
}
.report-map-legend-glyph{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  flex-shrink: 0;
  font-size: 10px;
}

/* Jadval/matn turidagi list'lar — odatiy hujjat kabi ichki bo'shliq bilan. */
/* MUHIM (TUZATILDI — "katta formatlarda (A2/A1) titul sahifasi yuqorida
   qolib, pastida katta bo'sh joy qolib ketayapti" xatosi): `.report-cover`
   ichida `height:100%` bilan vertikal markazlanadi — lekin bu FAQAT ota
   konteynerining ANIQ (min-height emas, balki height) o'lchami bo'lsa
   ishlaydi. Avval bu yerda faqat `min-height` (asosiy `.report-page-a4`
   qoidasidan meros) bor edi — shu sabab `height:100%` "auto" ga teng bo'lib,
   mazmun o'z tabiiy (kichik) balandligida sahifa YUQORISIDA qolib ketardi.
   Endi aniq `height` beriladi. */
.report-page-a4.report-page-doc{ height: var(--report-page-h); padding: 36px; box-sizing: border-box; color: #1f2430; }

.report-content-table{ width: 100%; border-collapse: collapse; font-size: 13px; }
.report-content-table th, .report-content-table td{
  border: 1px solid #d8dbe3;
  padding: 6px 10px;
  text-align: left;
}
.report-content-table th{ background: #f4f5f7; font-weight: 700; }

.report-summary{ max-width: 480px; }
.report-summary-title{ font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.report-summary-row{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e8e9ee;
  font-size: 14px;
}

.report-cover{
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
}
.report-cover-badge{ font-size: 48px; margin-bottom: 12px; }
.report-cover-title{ font-size: 26px; font-weight: 800; max-width: 80%; }
.report-cover-dept{ font-size: 15px; color: #5b6472; }
.report-cover-date{ font-size: 13px; color: #8b93a1; margin-top: 40px; }

/* ===== "Excel"ga o'xshash jadval — belgilangan kataklar (js/tools/excelGrid.js) ===== */
#data-table-body td{ cursor: cell; user-select: none; }
/* ===== Xaritani aylantirish "kompasi" — 8 segment + markaz (js/map/mapInteraction.js) =====
   Nozik/nafis, qo'pol bo'lmagan ranglar: och kulrang segmentlar, oq bo'shliqlar,
   joriy burchak esa asosiy rangda YENGIL urg'ulanadi. */
#map-rotate-controls{
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  transform-origin: right center;
  z-index: 900;
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 2px 6px rgba(16,24,40,.12));
  /* MUHIM: odatiy holatda 50% shaffof (kamroq chalg'itish uchun) — sichqoncha
     ustiga olib borilganda to'liq TINIQ bo'ladi VA 50% KATTALASHADI, sichqoncha
     olinsa yana avvalgi (shaffof, kichik) holatga qaytadi. */
  opacity: .5;
  transition: opacity .18s ease, transform .18s ease;
}
#map-rotate-controls:hover{
  opacity: 1;
  transform: translateY(-50%) scale(1.5);
}
#compass-ring{ width: 100%; height: 100%; overflow: visible; }
.compass-segment{
  fill: #dde1e8;
  stroke: none;
  cursor: pointer;
  transition: fill .15s ease;
}
.compass-segment:hover{ fill: #c9cfd9; }
.compass-segment.active{ fill: color-mix(in srgb, var(--color-primary) 45%, #dde1e8); }
.compass-label{
  font-size: 7.5px;
  font-weight: 600;
  fill: #7b8290;
  text-anchor: middle;
  dominant-baseline: middle;
  cursor: pointer;
  pointer-events: none;
  user-select: none;
}
#compass-center{
  fill: var(--color-panel);
  stroke: #dde1e8;
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill .15s ease, stroke .15s ease;
}
#compass-center:hover{ fill: #f2f4f7; }
#compass-center.active{ stroke: var(--color-primary); }
#compass-center-label{
  font-size: 9px;
  font-weight: 700;
  fill: var(--color-text-muted);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}
/* MUHIM: aylantirilganda to'rtburchak xarita konteynerining burchaklarida
   BO'SH (oq) uchburchaklar ko'rinib qolmasligi uchun — xarita bir oz
   KATTALASHTIRILADI (scale, js/map/mapInteraction.js -> setMapRotation),
   shu bilan istalgan 30°lik burchakda ham konteynerning HAR JOYINI to'liq
   qoplaydi (.map-wrap'dagi overflow:hidden ortiqchasini kesib tashlaydi). */
.gis-map{ transition: transform .25s ease; transform-origin: center center; }

/* ===== Hisobotni PDF qilib yuklash tugmasi (js/reportPdf.js) ===== */
#btn-report-download-pdf{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 901;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
#btn-report-download-pdf:hover{ transform: translateY(-1px); box-shadow: var(--shadow-lg); }
#btn-report-download-pdf:disabled{ opacity: .6; cursor: progress; transform: none; }

/* ===== PDF eksport uchun list tanlash modal oynasi ===== */
.report-pdf-modal{ position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.report-pdf-modal-backdrop{ position: absolute; inset: 0; background: rgba(20,22,28,.45); }
.report-pdf-modal-box{
  position: relative;
  width: 360px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--color-panel);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.report-pdf-modal-title{ padding: 16px 18px 10px; font-size: 15px; font-weight: 800; color: var(--color-text); }
.report-pdf-modal-all-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.report-pdf-modal-list{ flex: 1; overflow-y: auto; padding: 6px 0; }
.report-pdf-modal-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
}
.report-pdf-modal-row:hover{ background: var(--color-panel-alt); }
.report-pdf-modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--color-border);
}
.report-pdf-modal-btn-secondary, .report-pdf-modal-btn-primary{
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  cursor: pointer;
}
.report-pdf-modal-btn-secondary{ background: var(--color-panel-alt); color: var(--color-text); }
.report-pdf-modal-btn-primary{ background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ===== Hisobot xaritasi uchun qo'lda masshtab/saqlash boshqaruvi ===== */
.report-view-toolbar{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 14px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--color-text);
}
.report-view-toolbar label{ font-weight: 600; white-space: nowrap; }
.report-view-toolbar input[type="number"]{
  width: 56px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}
.report-view-toolbar button{
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-panel-alt);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease;
}
.report-view-toolbar button:hover{ background: var(--color-primary-bg, #e8f0fe); }
#btn-report-view-save{ color: #15803d; border-color: #15803d; }

#data-table-body td.excel-cell-selected{
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  position: relative;
  z-index: 1;
}

/* ===== Loyihalar ro'yxati: ijrochi, holat, yakunlanganlar sus ===== */
.project-item-header{ align-items: flex-start; }
.project-item-header::before{ margin-top: 2px; }
.project-item .pi-body{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.project-item .pi-top{ display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.project-item .project-item-name{ white-space: normal; flex-shrink: 1; line-height: 1.25; }
.project-item .pi-bottom{ display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.project-item .pi-exec{ font-size: 11px; font-weight: 600; color: var(--color-primary); white-space: nowrap; background: color-mix(in srgb, var(--color-primary) 9%, transparent); padding: 1px 7px; border-radius: 999px; }
.project-item .pi-exec.none{ color: var(--color-text-muted); background: transparent; font-weight: 500; font-style: italic; }
.project-item .pi-status{ font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.pi-status.ps-progress{ background: #e3edff; color: #1c4fd1; }
.pi-status.ps-new{ background: #fff2cf; color: #8a5a00; }
.pi-status.ps-done{ background: #e7e9ee; color: #6b7280; }
.project-item .pi-arrow{ margin-top: 2px; color: var(--color-text-muted); }
.project-item .pi-actions{ display: flex; gap: 6px; padding: 0 10px 8px 31px; flex-wrap: wrap; }
.pi-act{ border: 1px solid var(--color-border-strong, #cfd6e4); background: #fff; border-radius: 7px; padding: 3px 9px; font-size: 11px; font-weight: 700; cursor: pointer; color: #33415c; font-family: inherit; }
.pi-act:hover{ background: #f1f5ff; border-color: var(--color-primary); color: var(--color-primary); }
.pi-act.ok{ color: #0b6b36; border-color: #b9e3c9; background: #f0faf4; }
.pi-act.ok:hover{ background: #e0f4e8; border-color: #0b6b36; color: #0b6b36; }
/* Yakunlangan loyiha: rangi sus, "yopilgan" ko'rinish — lekin bosib ochish va ishlash mumkin */
.project-item.is-done{ opacity: .68; filter: saturate(.25); background: #f1f2f5; border-style: dashed; }
.project-item.is-done:hover, .project-item.is-done.active{ opacity: 1; filter: none; }
.project-item.is-done .project-item-name{ color: #6b7280; }
.project-item.is-done.active{ background: var(--color-panel); border-style: solid; }
.badge.badge-muted{ background: #e7e9ee; color: #6b7280; }

/* Loyiha kartasida ariza tugmasi */
.project-item .pi-app{ border: 1px solid #cfdcff; background: #f3f7ff; color: #1d4fd8; border-radius: 999px; padding: 1px 8px; font-size: 10.5px; font-weight: 800; cursor: pointer; font-family: inherit; white-space: nowrap; }
.project-item .pi-app:hover{ background: #1d4fd8; color: #fff; border-color: #1d4fd8; }
.project-item .pi-bottom{ flex-wrap: wrap; }

/* NATIJA REJIMI (tashkilot havolasi): faqat hisobot ko'rinadi, boshqaruv tugmalari yashirin */
html.result-mode #sidebar button, html.result-mode #project-flyout, html.result-mode .au-user, html.result-mode #apps-panel,
html.result-mode .tool-panel-embed, html.result-mode #report-new-btn{ display: none !important; }
