:root {
  color-scheme: dark;
  --bg: #080c10;
  --surface: #0d1117;
  --surface-2: #161b22;
  --surface-3: #1c2128;
  --border: #252c35;
  --border-strong: #35404c;
  --text: #e6edf3;
  --muted: #97a2ae;
  --muted-2: #66717f;
  --accent: #3fb950;
  --accent-dark: #04130a;
  --accent-soft: rgba(63, 185, 80, .15);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, .15);
  --warning: #d99e2b;
  --warning-soft: rgba(217, 158, 43, .16);
  --info: #58a6ff;
  --info-soft: rgba(88, 166, 255, .16);
  --violet: #a371f7;
  --violet-soft: rgba(163, 113, 247, .16);
  --radius: 15px;
  --pad: 16px;
  --nav-h: 66px;
  font-family: Inter, "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  color: inherit;
}

.splash,
.login-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 460px at 50% -10%, #173027 0%, transparent 64%),
    var(--bg);
}

.splash {
  gap: 10px;
}

.splash strong {
  font-size: 25px;
}

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

.brand-logo,
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 25px;
  box-shadow: 0 8px 30px var(--accent-soft);
}

.login-card {
  width: min(100%, 390px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(13, 17, 23, .96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand h1 {
  margin: 0;
  font-size: 25px;
}

.login-brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}

.textarea {
  min-height: 82px;
  resize: vertical;
}

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

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

.error-box {
  padding: 10px 12px;
  border: 1px solid rgba(248, 81, 73, .35);
  border-radius: 10px;
  background: var(--danger-soft);
  color: #ff8d87;
  font-size: 12px;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--pad);
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 16, .96);
  z-index: 10;
}

.topbar-title {
  min-width: 0;
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 750;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 800;
}

.topbar-brand .brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 20px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:active,
.btn:active,
.quick:active,
.nav-btn:active,
.row-btn:active {
  transform: scale(.97);
}

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

.icon {
  width: 21px;
  height: 21px;
  display: inline-block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.main::-webkit-scrollbar,
.chips::-webkit-scrollbar {
  display: none;
}

.section {
  padding: var(--pad) var(--pad) 0;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
}

.store-select {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}

.store-select .grow,
.grow {
  min-width: 0;
  flex: 1;
}

.tile-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.title {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-grid,
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.kpi {
  min-width: 0;
  overflow: hidden;
  padding: 14px 12px;
}

.kpi-label {
  color: var(--muted);
  font-size: 11px;
}

.kpi-value {
  margin-top: 7px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(15px, 4.7vw, 19px);
  font-weight: 800;
  letter-spacing: -.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-value small {
  margin-left: 2px;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 600;
}

.kpi-note {
  margin-top: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.rows {
  overflow: hidden;
}

.row,
.row-btn {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 0;
  background: transparent;
  text-align: left;
}

.row + .row,
.row-btn + .row-btn,
.row + .row-btn,
.row-btn + .row {
  border-top: 1px solid var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

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

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

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

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

.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.quick {
  min-width: 0;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.quick .tile-icon {
  width: 44px;
  height: 44px;
}

.quick span:last-child {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  min-height: var(--nav-h);
  display: flex;
  align-items: stretch;
  padding: 5px 2px max(5px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: #0b0f15;
  z-index: 12;
}

.nav-btn {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 700;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-btn .icon {
  width: 22px;
  height: 22px;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

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

.btn.danger {
  border-color: rgba(248, 81, 73, .25);
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.block {
  width: 100%;
}

.btn.small {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

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

.toolbar .input,
.toolbar .select {
  min-width: 0;
  flex: 1;
}

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 12px var(--pad) 2px;
}

.chip {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-dark);
}

.product-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
}

.product-card + .product-card {
  margin-top: 9px;
}

.product-card .title,
.product-card .sub {
  display: block;
}

.product-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: var(--surface-3);
  color: var(--info);
}

.price {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
}

.empty {
  padding: 34px 18px;
  color: var(--muted-2);
  text-align: center;
}

.empty .icon {
  width: 36px;
  height: 36px;
  margin-bottom: 8px;
}

.empty strong {
  display: block;
  color: var(--muted);
}

.empty p {
  margin: 5px 0 14px;
  font-size: 12px;
}

.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px 12px;
}

.cart-line + .cart-line {
  border-top: 1px solid var(--border);
}

.stepper {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
}

.stepper button {
  width: 34px;
  height: 34px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
}

.stepper span {
  min-width: 35px;
  text-align: center;
  font-weight: 800;
}

.total-card {
  padding: 14px;
  border-color: rgba(63, 185, 80, .45);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}

.total-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.total-line + .total-line {
  margin-top: 8px;
}

.total-line.big {
  padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 17px;
  font-weight: 800;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.action-btn {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.action-btn.in {
  color: var(--accent);
}

.action-btn.out {
  color: var(--danger);
}

.action-btn.transfer {
  color: var(--warning);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  min-height: 42px;
  flex: 1;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-2);
  font-weight: 700;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.chart-card {
  overflow: hidden;
  padding: 12px;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: hidden;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--accent);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  font-size: 24px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(3px);
}

.modal-backdrop {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  width: min(100%, 560px);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -25px 70px rgba(0, 0, 0, .5);
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head strong {
  flex: 1;
  font-size: 16px;
}

.modal-body {
  overflow-y: auto;
  padding: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.modal-actions .btn {
  flex: 1;
}

.drawer-backdrop {
  display: flex;
}

.drawer {
  width: min(82%, 330px);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 4px 20px;
  font-size: 20px;
  font-weight: 800;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.drawer-btn {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.drawer-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.drawer-foot {
  margin-top: auto;
  padding: 12px 4px 0;
  color: var(--muted-2);
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 18px);
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 15px 40px rgba(0, 0, 0, .5);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: .2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  border-color: rgba(248, 81, 73, .45);
  background: #2a1517;
  color: #ff9b96;
}

.loading-line {
  height: 3px;
  overflow: hidden;
  background: var(--surface-2);
}

.loading-line::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--accent);
  animation: loading 1s infinite ease-in-out;
}

@keyframes loading {
  from { transform: translateX(-110%); }
  to { transform: translateX(350%); }
}

@media (min-width: 700px) {
  :root {
    --pad: 22px;
  }

  .main {
    width: 100%;
    max-width: 720px;
    align-self: center;
  }

  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }

  .modal {
    border-bottom: 1px solid var(--border-strong);
    border-radius: 22px;
  }
}

@media (min-width: 900px) {
  :root {
    --pad: 22px;
    --nav-h: 100vh;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr);
  }

  .topbar {
    grid-column: 2;
    grid-row: 1;
    padding: 8px 24px;
  }

  .topbar > [data-action="drawer"] {
    display: none;
  }

  .main {
    width: 100%;
    max-width: none;
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    align-self: stretch;
    padding: 0 10px 28px;
  }

  .nav {
    grid-column: 1;
    grid-row: 1 / 3;
    min-height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 86px 12px 18px;
    border-top: 0;
    border-right: 1px solid var(--border);
    position: relative;
  }

  .nav::before {
    content: "B.Biz";
    position: absolute;
    top: 20px;
    left: 18px;
    color: var(--text);
    font-size: 21px;
    font-weight: 850;
  }

  .nav::after {
    content: "Do'kon boshqaruvi";
    position: absolute;
    top: 48px;
    left: 18px;
    color: var(--muted-2);
    font-size: 10px;
  }

  .nav-btn {
    min-height: 48px;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    font-size: 12px;
  }

  .nav-btn.active {
    background: var(--accent-soft);
  }

  .section {
    max-width: 1500px;
    margin-left: auto;
    margin-right: auto;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: repeat(4, minmax(140px, 1fr));
  }

  .quick {
    min-height: 110px;
  }

  .product-card {
    min-height: 84px;
  }

  .modal-backdrop {
    padding-left: 230px;
  }

  .toast {
    left: calc(50% + 115px);
    bottom: 24px;
  }
}

@media (max-width: 350px) {
  :root {
    --pad: 12px;
  }

  .quick-grid {
    gap: 6px;
  }

  .quick {
    min-height: 86px;
  }

  .quick .tile-icon {
    width: 40px;
    height: 40px;
  }

  .nav-btn {
    font-size: 8px;
  }

  .kpi {
    padding: 12px 9px;
  }
}
