:root {
  --green: #1D9E75;
  --green-soft: #E8F7F1;
  --red: #E24B4A;
  --red-soft: #FDECEC;
  --blue: #3B5BDB;
  --blue-soft: #E8EDFF;
  --purple: #534AB7;
  --purple-soft: #EFEDFB;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #15181E;
  --muted: #8A8F9B;
  --border: #ECEEF2;
  --sidebar-bg: #15181E;
  --sidebar-muted: #9196A1;
  --sidebar-active: #FFFFFF;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Sora", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-muted);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; }
.brand .dot { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--green), var(--purple)); flex-shrink: 0; }
.brand .name { color: #fff; font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.brand .sub { font-size: 10.5px; color: var(--sidebar-muted); }

.nav-group { margin-bottom: 2px; }
.nav-top {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  color: var(--sidebar-muted);
  user-select: none;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-top:hover { color: #cfd2d8; }
.nav-top.active { color: var(--sidebar-active); }
.nav-top .chev { margin-left: auto; font-size: 10px; transition: transform .15s; opacity: .6; }
.nav-group.open .nav-top .chev { transform: rotate(90deg); }
.nav-children { display: none; padding-left: 20px; }
.nav-group.open .nav-children { display: block; }
.nav-child {
  display: block; padding: 7px 10px; font-size: 13px;
  color: var(--sidebar-muted); border-radius: 8px; cursor: pointer;
  text-decoration: none;
}
.nav-child:hover { color: #cfd2d8; }
.nav-child.active { background: rgba(255,255,255,0.08); color: var(--sidebar-active); }
.nav-single.active { background: rgba(255,255,255,0.08); color: var(--sidebar-active); }

/* ===== Main ===== */
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px; background: var(--card); border-bottom: 1px solid var(--border);
}
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.ai-yordamchi {
  display: flex; align-items: center; gap: 7px; background: var(--purple-soft); color: var(--purple);
  border: none; border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.user-chip-wrap { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.user-chip-wrap .uname { font-size: 13.5px; font-weight: 700; color: var(--text); }
.user-chip {
  width: 32px; height: 32px; border-radius: 50%; background: var(--purple-soft);
  color: var(--purple); font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.content { padding: 24px 26px 60px; overflow-x: hidden; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.1px; color: #1A202C; }
.page-head .count { font-size: 13px; color: var(--blue); font-weight: 600; margin-left: 8px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-box {
  flex: 1; min-width: 220px; max-width: 420px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; display: flex; align-items: center; gap: 8px;
}
.search-box .search-ico { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; display: flex; }
.search-box .search-ico svg { width: 16px; height: 16px; }
.search-box input {
  border: none; outline: none; background: transparent; font-size: 13.5px;
  color: var(--text); padding: 9px 0; width: 100%; font-family: inherit;
}
.search-box input::placeholder { color: var(--muted); }
.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.ghost { color: var(--blue); border-color: var(--border); }
.icon-btn { display: inline-flex; align-items: center; gap: 7px; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-only { padding: 9px; display: inline-flex; }
.icon-only svg { width: 16px; height: 16px; }

/* ===== Greeting / icon buttons / banner ===== */
.greet-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.greet-head h1 { font-size: 30px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.4px; }
.greet-sub { font-size: 14px; color: var(--muted); }
.greet-sub b { color: var(--text); font-weight: 700; }
.greet-actions { display: flex; gap: 8px; }
.icon-circle-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); flex-shrink: 0;
}
.icon-circle-btn svg { width: 17px; height: 17px; }
.trend-banner {
  display: inline-flex; align-items: center; gap: 8px; background: var(--green-soft); color: var(--green);
  font-size: 13.5px; font-weight: 700; padding: 9px 16px; border-radius: 10px; margin-bottom: 18px;
}
.trend-banner svg { width: 14px; height: 14px; }

/* ===== KPI cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.kpi-label { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.kpi-value { font-size: 23px; font-weight: 800; }
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi-sub { font-size: 11.5px; color: var(--green); font-weight: 600; margin-top: 4px; }
.pct-badge { display: inline-flex; align-items: center; gap: 2px; border-radius: 6px; padding: 2px 6px; font-size: 11.5px; font-weight: 700; }
.pct-badge.pos { background: var(--green-soft); color: var(--green); }
.pct-badge.neg { background: var(--red-soft); color: var(--red); }
.pct-badge svg { width: 10px; height: 10px; }
.kpi-pct-row { display: flex; align-items: center; gap: 6px; margin: 8px 0 2px; font-size: 11.5px; color: var(--muted); }
.kpi-spark { height: 34px; margin-top: 6px; }

.seg2 { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--border); }
.seg2 button { border: none; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 700; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.seg2 button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.metric-tabs { display: flex; gap: 18px; }
.metric-tabs .mt { font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 8px 0; }
.metric-tabs .mt.active { color: var(--text); }

.rank-item2 { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rank-item2:last-child { border-bottom: none; }
.rank-num2 { width: 26px; height: 26px; border-radius: 8px; background: var(--purple-soft); color: var(--purple); font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-body2 { flex: 1; min-width: 0; }
.rank-name2 { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-tag2 { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.rank-bar-track2 { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.rank-bar-fill2 { height: 100%; border-radius: 3px; background: var(--blue); }
.rank-right2 { text-align: right; flex-shrink: 0; }
.rank-val2 { font-size: 13.5px; font-weight: 800; }

/* ===== Panels ===== */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; }
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* ===== Table ===== */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: #4A5568; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 15px 18px; border-bottom: 1px solid var(--border); background: #FAFBFC; white-space: nowrap; }
td { padding: 16px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 14px; }
td.wrap { white-space: normal; max-width: 260px; line-height: 1.4; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFBFD; }
.link { color: var(--blue); font-weight: 500; cursor: pointer; }
.link:hover { text-decoration: underline; }
.photo-ph {
  width: 38px; height: 38px; border-radius: 9px; background: var(--border);
  display: flex; align-items: center; justify-content: center; color: #C3C7CF; flex-shrink: 0;
}
.photo-ph svg { width: 18px; height: 18px; }
.rowcheck { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.tag { display: inline-block; background: var(--border); border-radius: 7px; padding: 4px 10px; font-size: 12.5px; color: var(--muted); font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.tabs-row { display: flex; gap: 2px; background: #F9FAFB; border: 1px solid #E2E5EB; border-radius: 6px; padding: 3px; width: fit-content; margin-bottom: 14px; }
.tabs-row .tab-item { padding: 6px 14px; border-radius: 4px; font-size: 12px; font-weight: 500; color: #6B7280; cursor: pointer; }
.tabs-row .tab-item.active { background: #FFFFFF; color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.status { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
.status.open { background: var(--blue-soft); color: var(--blue); }
.status.finished { background: var(--green-soft); color: var(--green); }
.status.expense { background: var(--red-soft); color: var(--red); }
.status.neutral { background: var(--border); color: var(--muted); }

.avatar-badge {
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.avatar-badge.c1 { background: #A9AFBC; }
.avatar-badge.c2 { background: var(--purple); }
.avatar-badge.c3 { background: var(--blue); }
.avatar-badge.c4 { background: #B91C1C; }
.avatar-badge.c5 { background: #C2410C; }
.avatar-badge.c6 { background: #7C2D12; }

/* ===== Finance: metric summary card (Accounts page) ===== */
.metric-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 14px; }
.entity-pill { display: inline-block; border-radius: 20px; padding: 3px 9px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.entity-pill.customer { background: var(--blue-soft); color: var(--blue); }
.entity-pill.supplier { background: var(--green-soft); color: var(--green); }
.mc-sub { font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 8px; }
.mc-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mc-icon svg { width: 17px; height: 17px; }
.mc-icon.customer { background: var(--blue-soft); color: var(--blue); }
.mc-icon.supplier { background: var(--green-soft); color: var(--green); }
.mc-split { display: flex; padding: 0 20px 16px; gap: 20px; }
.mc-split-item { flex: 1; }
.mc-split-item .lbl { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.mc-split-item .val { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.4px; }
.mc-split-item .val.red { color: var(--red); }
.mc-split-item .note { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.mc-split-item .note .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mc-split-item .note .dot.green { background: var(--green); }
.mc-split-item .note .dot.red { background: var(--red); }
.mc-bottom { display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; background: #FAFAFA; border-top: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--muted); }

/* ===== Finance: category pill, type select ===== */
.cat-pill { display: inline-block; background: #F9FAFB; border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--muted); }

/* ===== Statistics toggle cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.stat-card .lbl { font-size: 12px; font-weight: 500; color: #6B7280; margin-bottom: 6px; }
.stat-card .val { font-size: 20px; font-weight: 600; color: var(--text); }
.stat-card .val .unit { font-size: 11px; font-weight: 400; color: #6B7280; margin-left: 4px; }

/* ===== Square type/status tag (Sale, Damage, Return...) ===== */
.badge-sq { display: inline-block; border-radius: 6px; padding: 3px 9px; font-size: 12px; font-weight: 600; }
.badge-sq.green { background: #DCFCE7; color: #166534; }
.badge-sq.gray { background: var(--border); color: var(--muted); }
.badge-sq.red { background: var(--red-soft); color: var(--red); }

/* ===== Payment type pill (dot + label) ===== */
.pay-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 600; margin-right: 4px; white-space: nowrap; }
.pay-pill .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.pay-pill.pay-green { background: #F0FDF4; color: #166534; }
.pay-pill.pay-green .dot { background: #16A34A; }
.pay-pill.pay-orange { background: #FFF7ED; color: #C2410C; }
.pay-pill.pay-orange .dot { background: #EA580C; }
.pay-pill.pay-purple { background: var(--purple-soft); color: var(--purple); }
.pay-pill.pay-purple .dot { background: var(--purple); }

/* ===== Receipt # pill link (used in Sale / Deleted items) ===== */
.receipt-pill { display: inline-flex; align-items: center; gap: 4px; background: #EEF2FF; color: #4338CA; border: 1px solid #C7D2FE; border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.receipt-pill svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ===== Empty state with illustration (list placeholders) ===== */
.empty-block { text-align: center; padding: 70px 20px; }
.empty-block .ico { width: 56px; height: 56px; margin: 0 auto 16px; color: var(--blue); }
.empty-block .ico svg { width: 100%; height: 100%; }
.empty-block .t { font-size: 22px; font-weight: 700; color: var(--text); }

.stock-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.stock-dot.green { background: var(--green); }
.stock-dot.red { background: var(--red); }

.icon-actions { display: flex; gap: 6px; }
.icon-actions .ia {
  width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.icon-actions .ia svg { width: 14px; height: 14px; }
.icon-actions .ia.view { background: var(--border); color: var(--muted); }
.icon-actions .ia.edit { background: #FDF0DA; color: #C98A17; }
.icon-actions .ia.del { background: var(--red-soft); color: var(--red); }

.date-pill {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.date-pill svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }

.pagination { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; font-size: 13px; color: var(--muted); }
.page-nums { display: flex; align-items: center; gap: 6px; }
.page-arrow, .page-num, .page-dots {
  min-width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); color: var(--text);
}
.page-dots { border: none; cursor: default; color: var(--muted); }
.page-num.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-size { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10,12,16,.45);
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box { background: var(--card); border-radius: 16px; width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto; padding: 22px 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: none; background: var(--bg); width: 30px; height: 30px; border-radius: 9px; font-size: 15px; cursor: pointer; color: var(--muted); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field input::placeholder, .form-section-body textarea::placeholder, .mini-table input::placeholder, .filter-row input::placeholder, .search-box input::placeholder { color: #B7BBC5; opacity: 1; }
.field select:has(option:checked[value=""]) { color: #B7BBC5; }
.field input, .field select {
  width: 100%; border: 1px solid #E2E5EB; border-radius: 6px; padding: 9px 13px;
  font-size: 13px; font-family: inherit; color: var(--text); background: var(--card);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ===== Full-page form (Create/Edit product) ===== */
.form-page-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; max-width: 920px; }
.form-page-head h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; color: #111827; }
.form-page-head .sub { font-size: 13px; color: var(--muted); }
.form-section { background: var(--card); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 18px; overflow: hidden; max-width: 920px; }
.form-section-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.form-section-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--purple-soft); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.form-section-head .t { font-weight: 600; font-size: 14px; color: #1A1D23; }
.form-section-head .s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.form-section-body { padding: 20px 22px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-row-inline { display: flex; gap: 8px; align-items: flex-start; }
.form-row-inline .field { flex: 1; }
.btn-auto { background: var(--blue-soft); color: var(--blue); border: none; border-radius: 7px; padding: 6px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t { font-weight: 700; font-size: 13.5px; }
.toggle-row .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 22px; cursor: pointer; transition: background .15s; }
.switch .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(16px); }
.upload-box { border: 1.5px dashed var(--border); border-radius: 12px; padding: 30px 16px; text-align: center; color: var(--muted); cursor: pointer; }
.upload-box .cam { font-size: 24px; margin-bottom: 8px; }
.upload-box .t { font-weight: 700; font-size: 13px; color: var(--text); }
.upload-box .s { font-size: 11.5px; margin-top: 3px; }
.form-section-body textarea { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; font-size: 13.5px; font-family: inherit; color: var(--text); resize: vertical; min-height: 110px; }
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.qty-stepper button { width: 28px; height: 32px; border: none; background: var(--bg); color: var(--text); font-size: 14px; cursor: pointer; }
.qty-stepper input { width: 40px; height: 32px; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-size: 13.5px; font-family: inherit; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 0 10px 10px; }
.mini-table td { padding: 8px 10px; vertical-align: middle; }
.mini-table input[type=text], .mini-table input[type=number] { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 13px; font-family: inherit; }
.unit-suffix { display: flex; align-items: center; gap: 6px; }
.unit-suffix input { flex: 1; }
.unit-suffix span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.form-page-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; margin-bottom: 40px; max-width: 920px; }

/* ===== Filter popover (dynamic field/operator/value) ===== */
.filter-pop { position: absolute; top: calc(100% + 8px); left: 0; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(10,12,16,.12); padding: 16px; z-index: 40; width: 560px; }
.filter-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.filter-row select, .filter-row input { border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; font-size: 13px; font-family: inherit; color: var(--text); background: var(--card); }
.filter-row .f-field { flex: 1; }
.filter-row .f-op { flex: 1; }
.filter-row .f-val { flex: 1; }
.filter-row .f-del { width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--bg); color: var(--muted); cursor: pointer; flex-shrink: 0; }
.filter-add { background: none; border: none; color: var(--blue); font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 0; margin-bottom: 14px; }
.filter-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Sana oralig'i popoveri ===== */
.date-pop { position: absolute; top: calc(100% + 8px); right: 0; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgba(10,12,16,.14); z-index: 20; display: flex; overflow: hidden; }
.date-pop-presets { width: 140px; border-right: 1px solid var(--border); padding: 8px; flex-shrink: 0; }
.dpp { padding: 9px 10px; border-radius: 8px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; }
.dpp:hover { background: var(--bg); }
.date-pop-cal { padding: 14px 16px; width: 280px; }
.date-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 700; font-size: 13.5px; }
.cal-nav { border: none; background: var(--bg); width: 26px; height: 26px; border-radius: 7px; cursor: pointer; color: var(--text); font-size: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 10.5px; color: var(--muted); font-weight: 700; padding: 4px 0; }
.cal-day { text-align: center; font-size: 12.5px; padding: 7px 0; border-radius: 7px; cursor: pointer; }
.cal-day:hover { background: var(--bg); }
.cal-day.in-range { background: var(--blue-soft); border-radius: 0; }
.cal-day.end { background: var(--blue); color: #fff; border-radius: 7px; font-weight: 700; }

/* ===== Drawer (yon panel) ===== */
.drawer-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10,12,16,.35);
  z-index: 55; justify-content: flex-end;
}
.drawer-box {
  width: 100%; max-width: 520px; height: 100%; background: var(--card);
  border-radius: 16px 0 0 16px; overflow: hidden;
  box-shadow: -8px 0 30px rgba(0,0,0,.12); display: flex; flex-direction: column;
  animation: drawerIn .18s ease-out;
}
@keyframes drawerIn { from { transform: translateX(24px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-section { margin-bottom: 22px; }
.drawer-section .sec-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.drawer-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.drawer-row:last-child { border-bottom: none; }
.drawer-row .k { color: var(--muted); }
.drawer-row .v { font-weight: 600; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

.pd-card { display: flex; gap: 14px; padding: 16px; background: var(--bg); border-radius: 12px; margin-bottom: 16px; }
.pd-photo { width: 64px; height: 64px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: #C3C7CF; flex-shrink: 0; }
.pd-photo svg { width: 26px; height: 26px; }
.pd-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 10px; }
.pd-info-grid .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.pd-info-grid .val { font-size: 13.5px; font-weight: 700; }
.pd-info-grid .val.green { color: var(--green); }

.pd-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.pd-tabs .pt { display: flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 20px; padding: 6px 12px; font-size: 12px; font-weight: 500; color: #6B7280; cursor: pointer; }
.pd-tabs .pt .dot { width: 6px; height: 6px; border-radius: 50%; }
.pd-tabs .pt.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pd-tabs .pt.active .dot { background: #fff; }

.pd-hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pd-hist-head .t { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.pd-hist-head .c { font-size: 12px; color: var(--muted); }
.pd-tx { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid #E2E5EB; border-radius: 6px; background: #fff; margin-bottom: 7px; }
.pd-tx:last-child { margin-bottom: 0; }
.pd-tx-ico { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.pd-tx-ico.supply { background: var(--green-soft); }
.pd-tx-ico.sales { background: var(--blue-soft); }
.pd-tx-ico.other { background: var(--border); }
.pd-tx-body { flex: 1; min-width: 0; }
.pd-tx-ref { font-size: 13px; font-weight: 700; color: var(--blue); }
.pd-tx-meta { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pd-tx-right { text-align: right; flex-shrink: 0; }
.pd-tx-price { font-size: 13px; font-weight: 700; }
.pd-tx-qty { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; margin-top: 3px; display: inline-block; }
.pd-tx-qty.plus { background: var(--green-soft); color: var(--green); }
.pd-tx-qty.minus { background: var(--red-soft); color: var(--red); }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1115;
    --card: #191C22;
    --text: #ECEDEF;
    --muted: #8B9099;
    --border: #272B33;
    --green-soft: #113228;
    --red-soft: #3A1F20;
    --blue-soft: #16223F;
    --purple-soft: #231F3D;
  }
}
