:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #0f1b2d; --ink-2: #334155; --muted: #6b7a90; --line: #e5e9ef; --line-2: #eef1f5;
  --accent: #0f766e; --accent-2: #14b8a6; --accent-soft: #e7f5f3; --accent-ink: #fff;
  --warn: #b45309; --warn-soft: #fff4e5; --bad: #c0362c; --bad-soft: #fdecea; --good: #047857; --good-soft: #e6f6ef;
  --side: #0c1f22; --side-2: #12302f;
  --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 1px 3px rgba(15, 27, 45, .06);
  --shadow-lg: 0 12px 32px rgba(15, 27, 45, .14);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--bad); margin-top: 8px; white-space: pre-wrap; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 24px; font-weight: 700; margin: 0 0 18px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 { font-size: 15px; font-weight: 650; margin: 26px 0 10px; color: var(--ink-2); }

/* ---------- kirish ---------- */
.login { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 10% -10%, #d5efe9 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #dfe9f7 0, transparent 60%), var(--bg); }
.login .card { width: 360px; display: grid; gap: 14px; padding: 32px; box-shadow: var(--shadow-lg); border: 0; }
.login .card::before { content: ""; width: 44px; height: 44px; border-radius: 12px; display: block; margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) center/22px no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9l1.5-5h15L21 9'/%3E%3Cpath d='M4 9v11h16V9'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E"), linear-gradient(135deg, var(--accent), var(--accent-2)); }
.login button.primary { height: 42px; font-size: 15px; }

/* ---------- elementlar ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
input, select, textarea { font: inherit; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 8px 12px; }
input[type=checkbox] { height: 18px; width: 18px; accent-color: var(--accent); }
input[type=file] { padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(20, 184, 166, .18); }
button { font: inherit; font-weight: 550; height: 38px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: 0 1px 1px rgba(15, 27, 45, .03); }
button:hover { background: #f7f9fb; border-color: #d5dbe3; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); box-shadow: 0 1px 2px rgba(15, 118, 110, .25); }
button.primary:hover { background: #0d6961; }
button.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; box-shadow: none; }
button.soft:hover { background: #d5eeea; }
button.danger { color: var(--bad); border-color: #f3cdc9; }
button.danger:hover { background: var(--bad-soft); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; height: auto; box-shadow: none; font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: .5; cursor: default; }

/* ---------- karkas ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
aside { background: linear-gradient(180deg, var(--side-2), var(--side)); color: #b8c7c9; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; color: #fff; padding: 22px 20px 18px; font-size: 16px; letter-spacing: -.01em; display: flex; flex-direction: column; gap: 2px; }
.brand::before { content: ""; width: 34px; height: 34px; border-radius: 10px; margin-bottom: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 9l1.5-5h15L21 9'/%3E%3Cpath d='M4 9v11h16V9'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E") center/18px no-repeat, linear-gradient(135deg, var(--accent), var(--accent-2)); }
nav { padding: 4px 12px; display: grid; gap: 2px; overflow-y: auto; }
nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: inherit; text-decoration: none; border-radius: 8px; font-weight: 500; transition: background .15s, color .15s; }
nav a svg { width: 18px; height: 18px; flex: none; opacity: .75; }
nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
nav a.active { background: rgba(20, 184, 166, .16); color: #fff; }
nav a.active svg { opacity: 1; color: #5eead4; }
.me { margin-top: auto; padding: 16px 20px; font-size: 13px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; grid-template-columns: 36px 1fr; gap: 0 10px; align-items: center; }
.me::before { content: attr(data-initials); grid-row: span 3; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .1); color: #fff; font-weight: 650; font-size: 13px; }
.me br { display: none; }
#meName { color: #fff; font-weight: 600; }
#meRole { font-size: 12px; color: #8fa5a8; }
.me .link { justify-self: start; color: #5eead4; font-size: 12px; margin-top: 2px; }
main { padding: 28px 36px 48px; overflow-x: auto; min-width: 0; }

/* ---------- panel va filtrlar ---------- */
.bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.bar .grow { flex: 1; min-width: 220px; }
.bar > button:not(.primary) + button.primary, .bar > button.primary + button:not(.primary) { }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; line-height: 1.5; }

/* ---------- jadval ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; white-space: nowrap; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: #f8fafb; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #f6fbfa; }
tfoot td { font-weight: 700; background: #f8fafb; border-top: 1px solid var(--line); border-bottom: 0; }
td input { width: 100%; }
td input.n, input.n { width: 110px; text-align: right; }
td .hint { margin: 2px 0 0; font-size: 12px; }

/* ---------- belgilar ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef1f5; color: var(--ink-2); white-space: nowrap; letter-spacing: 0; text-transform: none; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.posted { background: var(--good-soft); color: var(--good); }
.badge.in_transit { background: var(--warn-soft); color: var(--warn); }
.badge.draft { background: #eef1f5; color: var(--muted); }
.badge.cancelled, .badge.reversed { background: var(--bad-soft); color: var(--bad); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.grid2 > div:not(.card) { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 14px; font-weight: 550; }
.grid2 > div .muted { font-size: 12px; font-weight: 500; margin-bottom: 3px; }
.card .grid2 > div, .card .grid2 label { background: none; border: 0; padding: 0; }

.scan { display: flex; gap: 8px; margin: 14px 0; position: relative; }
.scan input { flex: 1; height: 46px; font-size: 15px; padding-left: 42px; border-radius: 10px; box-shadow: var(--shadow);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6v12M8 6v12M11 6v12M15 6v12M18 6v12M20 6v12'/%3E%3C/svg%3E") 14px center/18px no-repeat; }
.suggest { position: absolute; top: 52px; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; z-index: 5; max-height: 300px; overflow: auto; box-shadow: var(--shadow-lg); padding: 4px; }
.suggest div { padding: 9px 12px; cursor: pointer; border-radius: 6px; } .suggest div:hover { background: var(--accent-soft); }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.result { margin-top: 16px; }
.result .ok { color: var(--good); font-weight: 600; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  font-size: 12.5px; font-weight: 500; color: var(--muted); position: relative; overflow: hidden; }
.kpi b { display: block; font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.kpi .hint { margin: 6px 0 0; font-size: 12px; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent-2); opacity: 0; }
.kpis:first-of-type .kpi::after { opacity: 1; }
a.link-card { color: var(--muted); text-decoration: none; transition: border-color .15s, transform .15s; }
a.link-card:hover { border-color: var(--accent-2); transform: translateY(-1px); }

.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
table.pnl tr.strong td { font-weight: 700; background: #f8fafb; }
table.pnl tr.pct td { color: var(--muted); font-size: 12px; padding-top: 4px; padding-bottom: 8px; }

/* bo'lim tugmalari (tab) */
h2 + .bar > button, .tabs > button { border-radius: 999px; height: 34px; padding: 0 14px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #0f1b2d; color: #fff; padding: 12px 18px; border-radius: 10px; max-width: 440px; white-space: pre-wrap;
  box-shadow: var(--shadow-lg); font-weight: 500; z-index: 50; animation: toastIn .2s ease-out; }
.toast.bad { background: var(--bad); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { padding: 12px 16px; flex-direction: row; align-items: center; gap: 10px; } .brand::before { margin: 0; }
  nav { display: flex; flex-wrap: wrap; padding: 0 8px 8px; } .me { display: none; }
  main { padding: 20px 16px; }
}
@media print { aside, .actions, .bar, .hint, .toast { display: none !important; } .shell { display: block; } main { padding: 0; } }
