/* ═══════════════════════════════════════════════
   UYSAVDO — asosiy uslublar
   ═══════════════════════════════════════════════ */

:root {
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --brand-light: #eef7f5;
  --matn: #1e293b;
  --matn-och: #64748b;
  --chegara: #e2e8f0;
  --fon: #f8fafc;
  --oq: #fff;
  --yashil: #10b981;
  --sariq: #f59e0b;
  --kok: #0ea5e9;
  --qizil: #ef4444;
  --binafsha: #8b5cf6;
  --soya: 0 1px 3px rgba(0, 0, 0, .08);
  --soya-katta: 0 10px 30px rgba(0, 0, 0, .12);
  --radius: 12px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--fon);
  color: var(--matn);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--brand); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ KIRISH SAHIFASI ═══════════ */

.kirish-fon {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #0f766e 60%, #0f172a 100%);
  padding: 20px;
}
.kirish-karta {
  background: var(--oq);
  border-radius: 20px;
  box-shadow: var(--soya-katta);
  padding: 40px 34px;
  width: 100%; max-width: 380px;
}
.kirish-logo { text-align: center; margin-bottom: 28px; }
.kirish-logo h1 { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.kirish-logo h1 span { color: var(--brand); }
.kirish-logo p { color: var(--matn-och); font-size: 13px; margin-top: 4px; }

/* ═══════════ TARKIB (LAYOUT) ═══════════ */

.tarkib { display: flex; height: 100vh; overflow: hidden; }

.yon-panel {
  width: 232px; flex-shrink: 0;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
}
.yon-logo { padding: 20px; border-bottom: 1px solid #1e293b; }
.yon-logo h1 { color: #fff; font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.yon-logo h1 span { color: #34d399; }
.yon-logo p { font-size: 11px; color: #64748b; margin-top: 2px; }

.yon-menyu { flex: 1; overflow-y: auto; padding: 10px 8px; }
.yon-menyu a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: #cbd5e1; font-size: 14px; font-weight: 500;
  margin-bottom: 2px; transition: .15s; cursor: pointer;
}
.yon-menyu a:hover { background: #1e293b; color: #fff; }
.yon-menyu a.aktiv { background: var(--brand); color: #fff; }
.yon-menyu a .ikon { font-size: 17px; width: 20px; text-align: center; }

.yon-user {
  padding: 12px; border-top: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.yon-user-matn { flex: 1; min-width: 0; }
.yon-user-matn b { color: #fff; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yon-user-matn span { font-size: 11px; color: #64748b; }

.asosiy { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.tepa {
  height: 56px; background: var(--oq); border-bottom: 1px solid var(--chegara);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; flex-shrink: 0;
}
.qidiruv-quti { flex: 1; max-width: 420px; position: relative; }
.qidiruv-quti input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--chegara); border-radius: 9px;
  background: var(--fon); font-size: 13px;
}
.qidiruv-quti input:focus { outline: none; border-color: var(--brand); background: #fff; }
.qidiruv-quti::before { content: '🔍'; position: absolute; left: 11px; top: 8px; font-size: 13px; opacity: .5; }

.tarkib-ichi { flex: 1; overflow-y: auto; padding: 22px; }

/* ═══════════ ELEMENTLAR ═══════════ */

.karta {
  background: var(--oq); border: 1px solid var(--chegara);
  border-radius: var(--radius); box-shadow: var(--soya);
}
.karta-ichi { padding: 18px; }

.sarlavha { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.sarlavha h2 { font-size: 20px; font-weight: 700; }
.sarlavha .ong { margin-left: auto; display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

.tugma {
  padding: 9px 16px; border: none; border-radius: 9px;
  background: var(--brand); color: #fff;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.tugma:hover { background: var(--brand-dark); }
.tugma:disabled { opacity: .5; cursor: not-allowed; }
.tugma.ikkilamchi { background: var(--oq); color: var(--matn); border: 1px solid var(--chegara); }
.tugma.ikkilamchi:hover { background: var(--fon); }
.tugma.qizil { background: var(--qizil); }
.tugma.qizil:hover { background: #dc2626; }
.tugma.kichik { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.tugma.toliq { width: 100%; }

.maydon { display: block; margin-bottom: 12px; }
.maydon > span { display: block; font-size: 13px; font-weight: 500; color: var(--matn-och); margin-bottom: 5px; }
.maydon input, .maydon select, .maydon textarea, input.kiritish, select.kiritish {
  width: 100%; padding: 9px 12px;
  border: 1px solid #cbd5e1; border-radius: 9px;
  background: var(--oq); font-size: 14px;
}
.maydon input:focus, .maydon select:focus, .maydon textarea:focus, input.kiritish:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, .1);
}

.qator { display: flex; gap: 10px; flex-wrap: wrap; }
.qator > * { flex: 1; min-width: 140px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid4 { grid-template-columns: repeat(2, 1fr); } .grid3 { grid-template-columns: 1fr; } }

/* Statistika kartasi */
.stat {
  background: var(--oq); border: 1px solid var(--chegara);
  border-radius: var(--radius); padding: 15px; box-shadow: var(--soya);
}
.stat .nom { font-size: 11px; color: var(--matn-och); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.stat .qiymat { font-size: 23px; font-weight: 800; margin-top: 4px; }
.stat .izoh { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Jadval */
table.jadval { width: 100%; border-collapse: collapse; }
table.jadval th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  color: var(--matn-och); font-weight: 700; letter-spacing: .3px;
  padding: 11px 14px; background: var(--fon); border-bottom: 1px solid var(--chegara);
  white-space: nowrap;
}
table.jadval td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; }
table.jadval tr.bosiladi { cursor: pointer; }
table.jadval tr.bosiladi:hover { background: var(--fon); }
.jadval-quti { overflow-x: auto; }

/* Nishon (badge) */
.nishon {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.nishon.yashil { background: #d1fae5; color: #065f46; }
.nishon.sariq { background: #fef3c7; color: #92400e; }
.nishon.kok { background: #e0f2fe; color: #075985; }
.nishon.qizil { background: #fee2e2; color: #991b1b; }
.nishon.kulrang { background: #f1f5f9; color: #475569; }
.nishon.binafsha { background: #ede9fe; color: #5b21b6; }

/* ═══════════ SHAXMATKA ═══════════ */

.shaxmatka { display: flex; flex-direction: column; gap: 6px; min-width: fit-content; }
.shaxmatka-qator { display: flex; align-items: center; gap: 6px; }
.qavat-raqam {
  width: 30px; text-align: right; font-size: 11px;
  font-weight: 700; color: #94a3b8; flex-shrink: 0;
}
.xonadon {
  width: 88px; height: 66px; flex-shrink: 0;
  border-radius: 9px; border: 1px solid;
  padding: 6px 7px; cursor: pointer; text-align: left;
  transition: .12s; position: relative; background: none;
}
.xonadon:hover { transform: translateY(-2px); box-shadow: var(--soya-katta); }
.xonadon .raq { font-size: 12px; font-weight: 700; display: block; }
.xonadon .kich { font-size: 10px; opacity: .8; display: block; }
.xonadon .nrx { font-size: 10px; font-weight: 600; display: block; margin-top: 1px; }
.xonadon .qarzdor-nuqta {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #dc2626; border: 2px solid #fff;
}

.x-bosh { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.x-bosh:hover { background: #a7f3d0; }
.x-bron { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.x-bron:hover { background: #fde68a; }
.x-shartnoma { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.x-shartnoma:hover { background: #bae6fd; }
.x-sotilgan { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.x-sotilgan:hover { background: #fecaca; }
.x-yopiq { background: #e2e8f0; border-color: #cbd5e1; color: #64748b; }

.legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; align-items: center; }
.legenda span { display: inline-flex; align-items: center; gap: 6px; color: var(--matn-och); }
.nuqta { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ═══════════ BLOKLAR XARITASI (qurilish joylashuvi) ═══════════ */

.xarita-kanvas {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background:
    linear-gradient(#eef2f5 1px, transparent 1px) 0 0 / 100% 5%,
    linear-gradient(90deg, #eef2f5 1px, transparent 1px) 0 0 / 5% 100%,
    linear-gradient(135deg, #fafbfc, #f1f4f7);
  border: 1px solid var(--chegara);
  border-radius: 16px;
  overflow: hidden;
}
.xarita-kanvas.tahrir {
  background:
    linear-gradient(#e2e8f0 1px, transparent 1px) 0 0 / 100% 5%,
    linear-gradient(90deg, #e2e8f0 1px, transparent 1px) 0 0 / 5% 100%,
    #f8fafc;
  cursor: default;
}

.xarita-blok {
  position: absolute;
  border: 2px solid rgba(15, 118, 110, .35);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  box-sizing: border-box;
  transition: box-shadow .15s, filter .15s;
  user-select: none;
  overflow: hidden;
}
.xarita-blok.bosiladi { cursor: pointer; }
.xarita-blok.bosiladi:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(15, 118, 110, .3);
  z-index: 5;
}
.xarita-kanvas.tahrir .xarita-blok { cursor: grab; border-style: dashed; }
.xarita-blok.sudralmoqda { cursor: grabbing; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 10; opacity: .9; }
.xarita-blok.tanlangan {
  border-color: #f59e0b; border-style: solid; border-width: 3px;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .25); z-index: 8;
}

.xb-nomi { font-size: clamp(13px, 2.2vw, 22px); font-weight: 800; letter-spacing: -.3px; line-height: 1.1; }
.xb-stat { font-size: clamp(10px, 1.3vw, 13px); font-weight: 600; opacity: .85; margin-top: 3px; }

.xb-resize {
  position: absolute; right: -8px; bottom: -8px;
  width: 18px; height: 18px;
  background: var(--brand); border: 2px solid #fff;
  border-radius: 4px; cursor: nwse-resize; z-index: 4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
/* Burish tutqichi — tepada, aylantirish belgisi */
.xb-rotate {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px;
  background: #f59e0b; color: #fff; border: 2px solid #fff;
  border-radius: 50%; cursor: grab; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.xb-rotate:active { cursor: grabbing; }

/* Podezd ajratish (shaxmatkada) */
.podezd-ajratgich { width: 18px; flex-shrink: 0; }
.podezd-sarlavha {
  font-size: 11px; font-weight: 700; color: var(--matn-och);
  text-transform: uppercase; letter-spacing: .5px;
  padding-bottom: 4px; border-bottom: 2px solid var(--chegara);
  text-align: center; flex-shrink: 0;
}

/* Blok tablar */
.tablar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 8px 15px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--chegara); background: var(--oq);
  font-size: 13px; font-weight: 600; color: var(--matn-och);
}
.tab:hover { border-color: var(--brand); }
.tab.aktiv { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ═══════════ MODAL VA PANEL ═══════════ */

.modal-fon {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--oq); border-radius: 16px;
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--soya-katta);
}
.modal.keng { max-width: 820px; }
.modal-tepa {
  padding: 16px 20px; border-bottom: 1px solid var(--chegara);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--oq); border-radius: 16px 16px 0 0; z-index: 2;
}
.modal-tepa h3 { font-size: 16px; font-weight: 700; }
.modal-yop {
  border: none; background: none; font-size: 20px; cursor: pointer;
  color: var(--matn-och); line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.modal-yop:hover { background: var(--fon); }
.modal-ichi { padding: 20px; }

/* O'ng panel (drawer) */
.panel-fon { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 90; }
.panel {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 95;
  width: 100%; max-width: 430px; background: var(--oq);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .15); overflow-y: auto;
}

/* ═══════════ XABARLAR ═══════════ */

.xato { background: #fef2f2; color: #b91c1c; padding: 10px 13px; border-radius: 9px; font-size: 13px; margin: 10px 0; }
.ogoh { background: #fffbeb; color: #92400e; padding: 10px 13px; border-radius: 9px; font-size: 13px; margin: 10px 0; border: 1px solid #fde68a; }
.info { background: #eff6ff; color: #1e40af; padding: 10px 13px; border-radius: 9px; font-size: 13px; margin: 10px 0; border: 1px solid #bfdbfe; }
.muvaf { background: #f0fdf4; color: #166534; padding: 10px 13px; border-radius: 9px; font-size: 13px; margin: 10px 0; }

.bosh-holat { text-align: center; padding: 50px 20px; color: var(--matn-och); }
.bosh-holat .ikon { font-size: 42px; margin-bottom: 10px; }

.yuklanmoqda { display: flex; justify-content: center; padding: 40px; }
.spinner {
  width: 32px; height: 32px; border: 3px solid var(--brand-light);
  border-top-color: var(--brand); border-radius: 50%;
  animation: aylan .7s linear infinite;
}
@keyframes aylan { to { transform: rotate(360deg); } }

/* Toast xabar */
.toast-quti { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 13px; box-shadow: var(--soya-katta);
  animation: kirish .25s ease;
  max-width: 380px;
}
.toast.xato { background: #b91c1c; }
.toast.muvaf { background: #047857; }
@keyframes kirish { from { transform: translateX(40px); opacity: 0; } }

/* ═══════════ KANBAN ═══════════ */

.kanban { display: flex; gap: 11px; overflow-x: auto; padding-bottom: 12px; }
.kanban-ustun {
  width: 250px; flex-shrink: 0; background: #f1f5f9;
  border-radius: var(--radius); border-top: 3px solid;
}
.kanban-tepa { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; }
.kanban-tepa b { font-size: 13px; color: var(--matn); }
.kanban-ichi { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 7px; max-height: 64vh; overflow-y: auto; }
.lead-karta {
  background: var(--oq); border-radius: 9px; padding: 11px;
  box-shadow: var(--soya); cursor: pointer; border: 1px solid transparent; text-align: left;
}
.lead-karta:hover { border-color: var(--brand); }
.lead-karta b { font-size: 13px; display: block; }
.lead-karta small { color: var(--matn-och); font-size: 12px; }

/* ═══════════ STEPPER ═══════════ */

.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 20px;
  background: #f1f5f9; color: #94a3b8; font-size: 13px; font-weight: 600;
  border: none; cursor: default;
}
.step.aktiv { background: var(--brand); color: #fff; }
.step.tugagan { background: var(--brand-light); color: var(--brand); cursor: pointer; }
.step .num {
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255, 255, 255, .25);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.step.tugagan .num, .step:not(.aktiv) .num { background: rgba(0, 0, 0, .07); }

/* Foiz/summa almashtirish tugmasi */
.rejim-tugma { display: inline-flex; border: 1px solid var(--chegara); border-radius: 7px; overflow: hidden; }
.rejim-tugma button {
  padding: 4px 11px; border: none; background: var(--oq);
  font-size: 12px; cursor: pointer; color: var(--matn-och); font-weight: 600;
}
.rejim-tugma button.aktiv { background: var(--brand); color: #fff; }

.tez-foiz { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.tez-foiz button {
  padding: 3px 9px; border: none; border-radius: 6px;
  background: #f1f5f9; font-size: 11px; cursor: pointer; font-weight: 600; color: var(--matn-och);
}
.tez-foiz button:hover { background: var(--brand-light); color: var(--brand); }

/* Rasm yuklash */
.rasm-yuk {
  width: 100%; height: 165px; border: 2px dashed #cbd5e1; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--matn-och); cursor: pointer; background: none; gap: 4px;
}
.rasm-yuk:hover { border-color: var(--brand); color: var(--brand); }
.rasm-korish { position: relative; }
.rasm-korish img { width: 100%; height: 165px; object-fit: contain; background: var(--fon); border-radius: 10px; border: 1px solid var(--chegara); }
.rasm-tugmalar { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; }
.rasm-tugmalar button {
  background: rgba(255, 255, 255, .95); border: none; border-radius: 7px;
  padding: 4px 9px; font-size: 11px; cursor: pointer; box-shadow: var(--soya); font-weight: 600;
}
.galereya { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.galereya .rasm { position: relative; aspect-ratio: 1; }
.galereya .rasm img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--chegara); }
.galereya .rasm button {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border: none; border-radius: 6px; background: rgba(255, 255, 255, .95);
  color: var(--qizil); cursor: pointer; font-size: 12px; box-shadow: var(--soya);
}

/* Progress bar */
.progress { height: 8px; background: #e2e8f0; border-radius: 10px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 10px; transition: width .3s; }

/* Kvitansiya (chek) */
.chek { font-family: 'Courier New', monospace; font-size: 13px; padding: 22px; }
.chek .markaz { text-align: center; }
.chek hr { border: none; border-top: 1px dashed #cbd5e1; margin: 11px 0; }
.chek .qator { display: flex; justify-content: space-between; gap: 10px; margin: 3px 0; }

@media print {
  body * { visibility: hidden; }
  .chop, .chop * { visibility: visible; }
  .chop { position: absolute; left: 0; top: 0; width: 100%; }
}
