/* =====================================================================
   Baraka Micro — SPA stillari. Tashqi kutubxona yo'q (CDN'ga bog'liq emas),
   shuning uchun internet bo'lmasa ham interfeys to'liq ishlaydi.
   ===================================================================== */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --border: #e2e7ec;
  --text: #16202a;
  --text-muted: #65737f;
  --brand: #137a5f;
  --brand-soft: #e4f3ee;
  --brand-ink: #0c5944;
  --danger: #c23b3b;
  --danger-soft: #fbe9e9;
  --warn: #b57b14;
  --warn-soft: #fdf3e0;
  --info: #2a6fb0;
  --info-soft: #e8f1fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 42, .06), 0 8px 24px rgba(16, 32, 42, .06);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #11161b;
  --surface: #181f26;
  --surface-2: #1e262e;
  --border: #2a343d;
  --text: #e8edf2;
  --text-muted: #94a3b0;
  --brand: #32a37f;
  --brand-soft: #15302a;
  --brand-ink: #7fd3b7;
  --danger: #e06b6b;
  --danger-soft: #35201f;
  --warn: #d9a63f;
  --warn-soft: #332814;
  --info: #5a9ad4;
  --info-soft: #16293a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-muted); font-size: 13px; margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ----------------------------------------------------------- kirish ekrani */
.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  grid-template-rows: 1fr auto;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, var(--info-soft), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
  align-self: center;
}

.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }

.logo {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
  flex: none;
}

.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 6px; }
.login-form label span { font-size: 13px; font-weight: 550; color: var(--text-muted); }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color .15s, box-shadow .15s;
}

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

.form-error {
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.login-demo { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.demo-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

.login-footer { color: var(--text-muted); font-size: 12.5px; padding: 14px; text-align: center; }

/* ------------------------------------------------------------- karkas */
.app { display: grid; grid-template-columns: 252px 1fr; min-height: 100%; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.sidebar-brand-text { display: grid; min-width: 0; }
.sidebar-brand-text strong { font-size: 14.5px; }
.sidebar-brand-text span {
  font-size: 12.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
}
.sidebar-user-text { display: grid; flex: 1; min-width: 0; }
.sidebar-user-text strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text span { font-size: 12px; color: var(--text-muted); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 650; flex: none;
}

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

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 19px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.today-box {
  display: grid; text-align: right;
  padding: 6px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.today-box strong { font-size: 15px; font-variant-numeric: tabular-nums; }

.view { padding: 24px 26px 48px; display: grid; gap: 20px; align-content: start; }

/* -------------------------------------------------------------- tugmalar */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font: inherit; font-weight: 550; font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.btn-icon {
  width: 34px; height: 34px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); font-size: 15px;
  display: grid; place-items: center; flex: none;
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* ---------------------------------------------------------------- kartalar */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ------------------------------------------------------------------- KPI */
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: grid; gap: 7px;
}
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 550; }
.kpi-value { font-size: 23px; font-weight: 680; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-foot { font-size: 12.5px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }

.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--brand); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-muted); }

/* --------------------------------------------------------------- jadvallar */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted);
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--brand-soft); color: var(--brand-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------------------------------------------------------------- holatlar */
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-ico { font-size: 30px; opacity: .45; display: block; margin-bottom: 8px; }

.skeleton {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ filtr */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: none; background: var(--surface); color: var(--text-muted);
  padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 18, 24, .5);
  display: grid; place-items: center; padding: 20px; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-body { padding: 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--text-muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.checkbox input { width: auto; }

/* ------------------------------------------------------------------ toast */
.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 200;
  display: grid; gap: 9px; max-width: 360px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 11px 14px; font-size: 13.5px;
  animation: slide-in .2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide-in { from { transform: translateX(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* -------------------------------------------------------------------- POS */
.pos { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; align-items: start; }
.pos-list { max-height: 60vh; overflow-y: auto; }
.cart-line {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.cart-line:last-child { border-bottom: none; }
.cart-line input { width: 82px; text-align: right; }
.cart-title { font-size: 13.5px; font-weight: 550; }
.cart-sub { font-size: 12px; color: var(--text-muted); }

.totals { display: grid; gap: 7px; padding: 14px 18px; background: var(--surface-2); }
.totals div { display: flex; justify-content: space-between; font-size: 13.5px; }
.totals .grand { font-size: 18px; font-weight: 680; padding-top: 7px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ chart */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); padding: 0 18px 14px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.bar-row { display: grid; grid-template-columns: 1fr 72px; gap: 10px; align-items: center; padding: 7px 0; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.bar-label { font-size: 13px; display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }

/* ------------------------------------------------------------- moslashuv */
@media (max-width: 1080px) {
  .pos { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; border-right: none; border-bottom: 1px solid var(--border);
  }
  .nav { flex: 1 1 100%; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); display: grid; }
  .view { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
