/* ===========================================================================
   Alshib CRM — dizayn tizimi
   Minimalist, mobil-birinchi, dark (default) va light rejimlar
   ======================================================================== */

:root {
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --topbar-h: 58px;
  --speed: 140ms;
  --accent: #14b8a6;
  --accent-2: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --accent-line: rgba(20, 184, 166, 0.38);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.13);
}

:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0f16;
  --bg-soft: #0d141d;
  --surface: #111823;
  --surface-2: #17202d;
  --surface-3: #1d2836;
  --line: #202b3a;
  --line-soft: #1a2331;
  --text: #e8eef6;
  --muted: #8a9cb0;
  --muted-2: #62748a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --topbar-bg: rgba(10, 15, 22, 0.86);
  --scrim: rgba(4, 8, 13, 0.72);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg-soft: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --line: #e0e6ef;
  --line-soft: #eaeef4;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #8b9ab0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --scrim: rgba(15, 23, 42, 0.42);
  --accent-soft: rgba(20, 184, 166, 0.12);
}

/* ---------------------------------------------------------------- reset -- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

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

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

@media (min-width: 900px) {
  body {
    font-size: 14.5px;
  }
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
  background-clip: content-box;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ----------------------------------------------------------------- boot -- */
.boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  z-index: 200;
}

.boot__logo {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--accent), #0d9488);
  position: relative;
  animation: bootPulse 1.4s ease-in-out infinite;
}

.boot__logo::after {
  content: '';
  position: absolute;
  inset: 15px 18px;
  border-radius: 3px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.92) 0 2px,
    transparent 2px 5px
  );
}

.boot__text {
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@keyframes bootPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.94);
    opacity: 0.7;
  }
}

/* ----------------------------------------------------------------- app --- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 12px 96px;
}

@media (min-width: 900px) {
  .content {
    padding: 20px 20px 40px;
  }
}

/* -------------------------------------------------------------- topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
}

.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(160deg, var(--accent), #0f766e);
  position: relative;
  flex: none;
}

.brand__mark::after {
  content: '';
  position: absolute;
  inset: 7px 8px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0 1.5px, transparent 1.5px 3.5px);
  border-radius: 1px;
}

.brand__sub {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
}

.topbar__spacer {
  flex: 1;
}

.topbar__search {
  flex: 1;
  max-width: 380px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.crumbs button {
  background: none;
  border: 0;
  padding: 2px 4px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}

.crumbs button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.crumbs__sep {
  color: var(--muted-2);
}

/* --------------------------------------------------------------- inputs -- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.label__req {
  color: var(--danger);
}

.label__hint {
  margin-left: auto;
  font-weight: 500;
  font-size: 11px;
  color: var(--muted-2);
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 42px;
  transition: border-color var(--speed), box-shadow var(--speed), background var(--speed);
  appearance: none;
}

.textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--surface-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%238a9cb0' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.is-error,
.input.is-error,
.select.is-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px var(--danger-soft) !important;
}

.field__error {
  font-size: 12.5px;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 5px;
}

.field__help {
  font-size: 12px;
  color: var(--muted-2);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row > .input {
  flex: 1;
  min-width: 0;
}

/* -------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: 42px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--speed), background var(--speed), border-color var(--speed), opacity var(--speed);
  user-select: none;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--surface-3);
}

.btn:active {
  transform: scale(0.975);
}

.btn[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04211d;
}

.btn--primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.btn--danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn--sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn--icon {
  width: 42px;
  padding: 0;
  flex: none;
}

.btn--icon.btn--sm {
  width: 34px;
}

.btn--block {
  width: 100%;
}

.btn__icon {
  width: 17px;
  height: 17px;
  flex: none;
}

.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------- chips --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.badge--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--surface-2);
  color: var(--muted);
}

/* ------------------------------------------------------------- sections -- */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 4px 0 14px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.015em;
}

.page-head__meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section {
  margin-bottom: 22px;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.section__title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.section__count {
  font-size: 12px;
  color: var(--muted-2);
  font-family: var(--mono);
}

/* ---------------------------------------------------------- group shelf -- */
.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

@media (min-width: 700px) {
  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 12px;
  }
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  transition: transform var(--speed), border-color var(--speed), box-shadow var(--speed);
}

.tile:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.tile:active {
  transform: scale(0.985);
}

.tile__media {
  aspect-ratio: 16 / 11;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.tile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__media svg {
  width: 34px;
  height: 34px;
  color: var(--muted-2);
  opacity: 0.5;
}

.tile__code {
  position: absolute;
  top: 7px;
  right: 7px;
  background: rgba(6, 10, 16, 0.72);
  color: #d9f7f2;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

:root[data-theme='light'] .tile__code {
  background: rgba(15, 23, 42, 0.72);
}

.tile__body {
  padding: 9px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile__name {
  font-weight: 620;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile__sub {
  font-size: 11.5px;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile--add {
  border-style: dashed;
  border-color: var(--line);
  background: transparent;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  color: var(--muted);
  gap: 7px;
  padding: 14px;
  font-weight: 600;
  font-size: 13px;
}

.tile--add:hover {
  border-color: var(--accent-line);
  color: var(--accent-2);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------- product --- */
.list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.list__head {
  display: none;
}

.item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px 8px 8px;
  cursor: pointer;
  transition: border-color var(--speed), background var(--speed);
}

.item:hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
}

.item__thumb {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: none;
}

.item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item__thumb svg {
  width: 20px;
  height: 20px;
  color: var(--muted-2);
  opacity: 0.55;
}

.item__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item__name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted-2);
  flex-wrap: wrap;
}

.item__code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

.item__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Telefonda ortiqcha ustunlar ko'rinmaydi (ma'lumot meta qatorida bo'ladi) */
.item__cell {
  display: none;
}

@media (min-width: 860px) {
  .list__head {
    display: grid;
    grid-template-columns: 52px minmax(0, 2.2fr) minmax(0, 1.1fr) 120px 96px 40px;
    gap: 10px;
    padding: 0 10px 4px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted-2);
    font-weight: 600;
  }

  .item {
    grid-template-columns: 52px minmax(0, 2.2fr) minmax(0, 1.1fr) 120px 96px 40px;
    padding: 8px 10px 8px 8px;
  }

  .item__thumb {
    width: 52px;
    height: 52px;
  }

  .item__cell {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
  }

  .item__cell {
    display: block;
  }

  .item__right {
    justify-content: flex-end;
  }
}

/* Tor ekranda brend nomi yashiriladi */
@media (max-width: 640px) {
  .brand__name {
    display: none;
  }
  .crumbs {
    order: 3;
    width: 100%;
  }
  .topbar__inner {
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------- empty / skel -- */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.empty svg {
  width: 38px;
  height: 38px;
  opacity: 0.4;
  margin-bottom: 10px;
}

.empty h3 {
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}

.empty p {
  font-size: 13px;
  margin-bottom: 14px;
}

.skeleton {
  height: 62px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* --------------------------------------------------------- bottom bar ---- */
.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  gap: 8px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

@media (min-width: 900px) {
  .bottombar {
    left: auto;
    right: 26px;
    bottom: 26px;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
  }

  .bottombar .btn {
    box-shadow: var(--shadow);
  }
}

/* --------------------------------------------------------------- sheet --- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  background: var(--bg);
  animation: sheetIn var(--speed) ease-out;
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (min-width: 900px) {
  .sheet {
    align-items: center;
    justify-content: center;
    padding: 26px;
    background: var(--scrim);
    backdrop-filter: blur(3px);
  }
}

.sheet__panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 900px) {
  .sheet__panel {
    flex: none;
    width: min(1020px, 100%);
    max-height: 92vh;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: panelIn 160ms ease-out;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}

.sheet__title {
  font-weight: 660;
  font-size: 15.5px;
  letter-spacing: -0.01em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet__subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 14px 22px;
}

@media (min-width: 900px) {
  .sheet__body {
    padding: 20px 22px 24px;
  }
}

.sheet__foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

@media (min-width: 900px) {
  .sheet__foot {
    padding: 13px 22px;
  }
}

.sheet__foot .spacer {
  flex: 1;
}

.sheet__hint {
  font-size: 12px;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------------------------------------- field grid --- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

@media (min-width: 820px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
  }
}

.field--wide {
  grid-column: 1 / -1;
}

/* Majburan bitta ustun (masalan, kirish formasi) */
.field-grid--single {
  grid-template-columns: 1fr !important;
}

.form-block + .form-block {
  margin-top: 22px;
}

.form-block__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 650;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

/* -------------------------------------------------------------- smart ---- */
.smart {
  position: relative;
}

.smart__menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 264px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
}

.smart__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}

.smart__item:hover,
.smart__item[aria-selected='true'] {
  background: var(--accent-soft);
}

.smart__item mark {
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
}

.smart__idx {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}

.smart__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart__use {
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--mono);
}

.smart__empty {
  padding: 10px;
  font-size: 13px;
  color: var(--muted-2);
  text-align: center;
}

.smart__prompt {
  margin-top: 8px;
  border: 1px dashed var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 10px 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  animation: sheetIn 160ms ease-out;
}

.smart__prompt-text {
  flex: 1;
  min-width: 160px;
  font-size: 13px;
  color: var(--text);
}

.smart__prompt-text b {
  color: var(--warn);
  font-weight: 700;
}

.smart__prompt-actions {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.smart__ok {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ok);
}

/* -------------------------------------------------------------- image ---- */
.image-picker {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.image-picker__preview {
  width: 96px;
  height: 96px;
  flex: none;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
}

.image-picker__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-picker__preview svg {
  width: 24px;
  height: 24px;
  color: var(--muted-2);
}

.image-picker__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.path-box {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 8px;
}

.path-box svg {
  width: 14px;
  height: 14px;
  flex: none;
  opacity: 0.6;
}

/* ----------------------------------------------------------- detail ------ */
.detail-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.detail-hero__media {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
  flex: none;
}

.detail-hero__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-hero__media svg {
  width: 40px;
  height: 40px;
  color: var(--muted-2);
  opacity: 0.5;
}

.detail-hero__info {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-name {
  font-size: 21px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.detail-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.kv {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.kv__k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  font-weight: 650;
}

.kv__v {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.kv__v--mono {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.barcode-display {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.16em;
  font-weight: 700;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  overflow-x: auto;
  white-space: nowrap;
}

/* --------------------------------------------------------------- login --- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(1000px 520px at 50% -12%, var(--accent-soft), transparent 62%),
    var(--bg);
}

.login__card {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: 4px;
}

.login__logo {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: linear-gradient(160deg, var(--accent), #0f766e);
  position: relative;
}

.login__logo::after {
  content: '';
  position: absolute;
  inset: 12px 14px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.92) 0 2px, transparent 2px 4.5px);
  border-radius: 2px;
}

.login__title {
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.login__sub {
  font-size: 13px;
  color: var(--muted);
}

/* -------------------------------------------------------------- toasts --- */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(94vw, 460px);
}

@media (min-width: 900px) {
  .toasts {
    bottom: 26px;
  }
}

.toast {
  pointer-events: auto;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  animation: toastIn 180ms ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.toast svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.toast--error {
  border-color: rgba(248, 113, 113, 0.42);
}
.toast--error svg {
  color: var(--danger);
}
.toast--ok svg {
  color: var(--ok);
}
.toast--info svg {
  color: var(--accent-2);
}
.toast--warn svg {
  color: var(--warn);
}

/* ------------------------------------------------------------- netbar ---- */
.netbar {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 130;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

/* ------------------------------------------------------------- switch ---- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13.5px;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  position: relative;
  transition: background var(--speed), border-color var(--speed);
  flex: none;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--speed), background var(--speed);
}

.switch input:checked + .switch__track {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.switch input:checked + .switch__track::after {
  transform: translateX(17px);
  background: var(--accent);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ chips row -- */
.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--speed);
}

.chip:hover {
  border-color: var(--accent-line);
}

.chip[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-2);
}

.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform var(--speed);
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch[aria-pressed='true'] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface);
}

/* -------------------------------------------------------------- layout --- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

@media (min-width: 1000px) {
  .layout {
    grid-template-columns: 274px minmax(0, 1fr);
    gap: 22px;
  }

  .content {
    max-width: 1400px;
  }

  /* Guruh ochilganda: ro'yxat yig'iladi, guruh butun kenglikni egallaydi */
  .layout--full {
    grid-template-columns: minmax(0, 1fr);
  }

  .tree {
    position: sticky;
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + 14px);
    max-height: calc(100dvh - var(--topbar-h) - 46px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.content-pane {
  min-width: 0;
}

/* ---------------------------------------------------------- guruh daraxti -- */
.tree {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-width: 0;
}

.tree__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 9px;
  margin-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
}

.tree__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree__node {
  min-width: 0;
}

.tree__row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.tree__toggle {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted-2);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
}

.tree__toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree__toggle svg {
  width: 13px;
  height: 13px;
  transition: transform var(--speed);
}

.tree__toggle[aria-expanded='true'] svg {
  transform: rotate(90deg);
}

.tree__item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 0;
  background: none;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  transition: background var(--speed), color var(--speed);
}

.tree__item:hover {
  background: var(--surface-2);
}

.tree__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 650;
}

.tree__children {
  margin-left: 12px;
  padding-left: 5px;
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree__icon {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--muted-2);
}

.tree__code {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-2);
  flex: none;
}

.tree__count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
  flex: none;
}

.tree__item.is-active .tree__count {
  background: rgba(20, 184, 166, 0.18);
  color: var(--accent-2);
}

.tree__collapse {
  display: inline-flex;
}

/* Guruh ochilganda sahifa sarlavhasi yirikroq ko'rinadi */
.page-head h1 {
  flex: 1;
  min-width: 140px;
}

/* ------------------------------------------------------------- utility --- */
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row--wrap {
  flex-wrap: wrap;
}
.spread {
  justify-content: space-between;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-8 {
  margin-bottom: 8px;
}
.hidden {
  display: none !important;
}
.grow {
  flex: 1;
  min-width: 0;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
