:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #1f5fd1; --accent-ink: #fff; --kirim: #11823b; --chiqim: #b4271f;
  --ok-bg: #e7f6ec; --ok: #11823b; --warn-bg: #fff6e0; --warn: #8a5a00; --bad-bg: #fdecea; --bad: #b4271f;
  --blue-bg: #e8f0fd;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
code { font: 12px ui-monospace, Consolas, monospace; background: #f0f2f5; padding: 1px 4px; border-radius: 4px; }
h1, h2, h3 { margin: 0 0 8px; } h2 { font-size: 18px; } h3 { font-size: 14px; margin-top: 18px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 12px; } .r { text-align: right; } .nowrap { white-space: nowrap; } .center { text-align: center; }
.kirim { color: var(--kirim); } .chiqim { color: var(--chiqim); } .ok { color: var(--ok); } .bad { color: var(--bad); }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: #16213a; color: #fff; }
.top .brand { color: #fff; font-weight: 700; font-size: 16px; }
.top nav { display: flex; gap: 18px; flex: 1; } .top nav a { color: #c9d4ee; } .top nav a:hover { color: #fff; }
.top nav a.muted { margin-left: auto; }
main { max-width: 1200px; margin: 20px auto; padding: 0 16px; } main.wide { max-width: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 16px; }
.flash { padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; background: var(--ok-bg); color: var(--ok); }
.flash.xato { background: var(--bad-bg); color: var(--bad); } .flash.warn { background: var(--warn-bg); color: var(--warn); }

.btn { font: inherit; padding: 7px 14px; border-radius: 7px; border: 1px solid #cfd5df; background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: #9aa5b8; } .btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: #f0b8b3; } .btn.sm { padding: 4px 9px; font-size: 12px; }
input, select { font: inherit; padding: 5px 7px; border: 1px solid #cfd5df; border-radius: 6px; background: #fff; max-width: 100%; }
input:focus, select:focus { outline: 2px solid #b9cdf5; border-color: var(--accent); }
label { display: block; color: var(--muted); font-size: 13px; }
label > input:not([type=checkbox]), label > select { display: block; width: 100%; margin-top: 3px; color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; } .actions form { margin: 0; } .actions .right { margin-left: auto; }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { width: 340px; display: grid; gap: 12px; } .login h1 { font-size: 22px; }

.upload .drop { display: grid; place-items: center; border: 2px dashed #c6cedb; border-radius: 10px; padding: 26px; margin: 12px 0; cursor: pointer; background: #fafbfc; }
.upload .drop input { margin-bottom: 8px; }
.org { padding: 6px 0; border-bottom: 1px solid var(--line); margin-bottom: 8px; }

table { border-collapse: collapse; width: 100%; }
table.list th, table.list td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th.r, table.list td.r { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover { background: #f7f9fc; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef0f4; color: var(--muted); margin: 1px 2px 1px 0; white-space: nowrap; }
.badge.h-yozildi, .h-yozildi .badge.h-yozildi { background: var(--ok-bg); color: var(--ok); }
.badge.h-tasdiqlangan { background: var(--blue-bg); color: var(--accent); }
.badge.h-tayyor { background: #eef7e9; color: #3d7a1c; }
.badge.h-tekshirish, .badge.h-yangi { background: var(--warn-bg); color: var(--warn); }
.badge.h-xato { background: var(--bad-bg); color: var(--bad); }

.head .headrow { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.totals { display: flex; gap: 24px; } .totals div { display: grid; text-align: right; } .totals b { font-size: 17px; }
pre.check { white-space: pre-wrap; font: 13px/1.5 inherit; font-family: inherit; background: #f7f8fa; border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
pre.check.ok { background: var(--ok-bg); } pre.check.bad { background: var(--bad-bg); }
.status { margin-top: 8px; color: var(--muted); min-height: 1em; }
.status.run { color: var(--accent); font-weight: 600; } .status.run::before { content: "⏳ "; }

.tabs { display: flex; gap: 4px; margin: 0 0 -1px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0; background: #eceff3; color: var(--muted); }
.tab span { background: #fff; border-radius: 9px; padding: 0 7px; margin-left: 4px; font-size: 12px; }
.tab.on { background: #fff; color: var(--ink); font-weight: 600; }
.tablewrap { background: #fff; border: 1px solid var(--line); border-radius: 0 10px 10px 10px; overflow-x: auto; }
table.ops th { position: sticky; top: 0; background: #f7f8fa; font-size: 12px; color: var(--muted); text-align: left; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.ops td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.ops td input:not([type=checkbox]), table.ops td select { width: 100%; margin-bottom: 4px; font-size: 13px; }
table.ops td.bank { min-width: 220px; max-width: 320px; }
table.ops .maqsad { font-size: 12px; color: #3a4252; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }
table.ops select.tur { min-width: 160px; font-weight: 600; }
table.ops td:last-child { position: sticky; right: 0; background: inherit; }
table.ops tbody tr { background: #fff; }
table.ops td.extra { min-width: 170px; } table.ops td.state { min-width: 140px; max-width: 200px; }
table.ops .row2 { display: flex; gap: 4px; } table.ops .row2 input.w-no { flex: 0 0 64px; width: 64px; } table.ops .row2 input[type=date] { flex: 1 1 auto; min-width: 0; } .w-inn { max-width: 140px; } .w-sch { max-width: 90px; display: inline-block !important; }
tr.h-yozildi { background: #f6fbf7; } tr.h-tasdiqlangan { background: #f5f8fe; } tr.h-xato { background: #fff8f7; }
tr.saving { opacity: .55; }
.settings h3:first-of-type { margin-top: 8px; } .settings label { margin-bottom: 10px; }

/* schyot-fakturalar */
.badge.h-mavjud { background: #efe9fb; color: #5b3aa8; }
tr.h-mavjud { background: #faf8fe; }
.warn { color: var(--warn); }
.tab .warnnum { background: var(--warn-bg); color: var(--warn); }
.tabs.sub { margin-top: 0; } .tabs.sub .tab { padding: 6px 12px; font-size: 13px; }
.pad { padding: 10px 12px 0; margin: 0; }
table.grp td.names { min-width: 260px; max-width: 360px; }
table.grp td.nomcell { min-width: 240px; max-width: 320px; } table.grp td.newcell { min-width: 220px; max-width: 280px; }
table.grp .mx { max-width: 170px; white-space: normal; }
ul.variants { margin: 6px 0 0; padding-left: 16px; } ul.variants li { margin-bottom: 4px; }
ul.variants form.move { display: inline; } ul.variants form.move select { width: auto; max-width: 150px; font-size: 11px; padding: 1px 4px; margin: 0; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
input.q { font-size: 12px !important; }
td.lines { min-width: 260px; max-width: 380px; } td.lines .ln { margin-bottom: 5px; } td.kontr { min-width: 190px; }
.w-no2 { flex: 0 0 120px !important; width: 120px !important; }
.sf-kirim h2 { color: var(--kirim); } .sf-chiqim h2 { color: var(--chiqim); }

/* yordamchi */
.chat { display: flex; flex-direction: column; }
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.msgs { max-height: calc(100vh - 290px); min-height: 240px; overflow-y: auto; padding: 8px 2px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; max-width: 100%; }
.msg.user { align-items: flex-end; } .msg.ai { align-items: flex-start; }
.msg .bubble { padding: 9px 13px; border-radius: 12px; max-width: min(1050px, 100%); overflow-x: auto; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.ai .bubble { background: #f1f3f7; border-bottom-left-radius: 3px; }
.msg .txt { white-space: pre-wrap; }
.msg .when { margin: 2px 6px 0; }
.hint { color: var(--muted); } .hint ul { margin: 4px 0; }
form.ask { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
form.ask textarea { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid #cfd5df; border-radius: 8px; resize: vertical; }
table.stock { margin-top: 8px; background: #fff; border-radius: 8px; font-size: 13px; }
table.stock th { text-align: left; font-size: 12px; color: var(--muted); padding: 5px 8px; border-bottom: 1px solid var(--line); }
table.stock td { padding: 4px 8px; border-bottom: 1px solid #f0f2f5; vertical-align: top; } table.stock tr.gsum td { background: #f7f9fc; }
table.stock .r, table.dlines .r { text-align: right; }
.draft { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 760px; }
.draft.h-yozildi { border-color: #bfe3cb; } .draft .dhead { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.grid-d { display: grid; grid-template-columns: 2fr 1.4fr 0.8fr; gap: 10px; }
.grid-d label > span.row2 { display: flex; gap: 4px; margin-top: 4px; }
table.dlines { margin-top: 10px; font-size: 13px; } table.dlines th { font-size: 12px; color: var(--muted); text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.dlines td { padding: 4px 6px; border-bottom: 1px solid #f0f2f5; }
table.dlines input { width: 100%; } table.dlines input.num { text-align: right; max-width: 130px; } input.need { border-color: var(--bad); }
table.dlines td:first-child { min-width: 260px; }
table.list tr.sel td { background: #eef4ff; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
