:root {
  --brand: #2f5bd3; --brand2: #e8eefc; --ink: #16202e; --muted: #687385; --line: #e5e8ee; --bg: #f6f7f9;
  --ok: #138a4b; --okbg: #e6f6ed; --bad: #c2352b; --badbg: #fdecea; --warn: #b25e00; --warnbg: #fff4e0;
  --r: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* Kirish */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #fff; }
.login .card { width: 100%; max-width: 360px; text-align: center; box-shadow: none; border: 1px solid var(--line); padding: 28px 24px; }
.login h1 { font-size: 22px; margin: 12px 0 4px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login input { text-align: center; font-size: 22px; letter-spacing: 6px; }
.logo { width: 56px; height: 56px; border-radius: 14px; display: inline-block; }

/* Asosiy tuzilma */
header.top { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line); }
.topin { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand .logo { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; }
nav.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; position: relative; }
nav.tabs a.on { background: var(--brand2); color: var(--brand); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 90px; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
.muted { color: var(--muted); }
.show-m { display: none; }
.small { font-size: 13px; }

.card { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.kpi { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi.sale .v { color: var(--ok); } .kpi.exp .v { color: var(--bad); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips input[type=date] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; }

.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.btn:hover { background: #f3f5f8; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { filter: brightness(.95); }
.btn.dang { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input.i, select.i, textarea.i { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
input.i:focus, select.i:focus, textarea.i:focus { outline: 2px solid var(--brand2); border-color: var(--brand); }
textarea.i { min-height: 70px; resize: vertical; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }

/* Jadval */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #fafbfc; }
.tbl tr.fresh td { background: #f2f7ff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-bottom: none; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef0f3; color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--okbg); color: var(--ok); } .tag.unc { background: var(--warnbg); color: var(--warn); }
.tag.tg { background: #e7f3fb; color: #1d7ab8; }
.raw { font-size: 13px; color: var(--muted); margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Kunlar */
.day { border-top: 1px solid var(--line); padding: 12px 0; }
.day:first-child { border-top: none; padding-top: 0; }
.day .dh { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.day .dh b { font-size: 16px; }
.day ul { margin: 6px 0 0; padding-left: 18px; }
.day li { margin: 2px 0; }
.pos { color: var(--ok); font-weight: 600; } .neg { color: var(--bad); font-weight: 600; }

/* Modal */
.ov { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 18px 18px 14px; }
.modal .mh { display: flex; align-items: center; margin-bottom: 12px; } .modal .mh h3 { margin: 0; flex: 1; font-size: 17px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.calc { background: var(--brand2); color: var(--brand); padding: 8px 12px; border-radius: 9px; font-size: 14px; margin-bottom: 10px; }
.note { background: var(--warnbg); color: var(--warn); padding: 10px 12px; border-radius: 9px; font-size: 14px; margin-bottom: 10px; }
.note.ok { background: var(--okbg); color: var(--ok); }
ol.steps { padding-left: 20px; margin: 6px 0; } ol.steps li { margin: 4px 0; }
code { background: #f1f3f6; padding: 1px 5px; border-radius: 5px; font-size: 13px; }

#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 99; }
#toast div { background: #16202e; color: #fff; padding: 10px 16px; border-radius: 10px; margin-top: 6px; box-shadow: var(--shadow); }
#toast div.err { background: var(--bad); }

/* Mobil */
@media (max-width: 760px) {
  .topin { padding: 10px 12px; }
  nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; z-index: 20; }
  nav.tabs a { padding: 6px 6px; font-size: 12px; text-align: center; flex: 1; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 18px; }
  main { padding: 12px 10px 90px; }
  .hide-m { display: none; }
  .show-m { display: inline; }
  .badge { position: absolute; top: 0; right: 2px; margin: 0; }
  .tbl td, .tbl th { padding: 8px 6px; }
  .f3 { grid-template-columns: 1fr 1fr; }
}
.login input::placeholder { letter-spacing: normal; font-size: 16px; }
