:root {
  --bg: #F3F5F2;
  --panel: #FFFFFF;
  --ink: #1D2A23;
  --muted: #66746C;
  --line: #E1E6E2;
  --brand: #2F6B4F;
  --brand-2: #3E8762;
  --brand-soft: #E5F0EA;
  --warn: #B7791F;
  --warn-soft: #FDF3E1;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --info: #2F5D8A;
  --info-soft: #E6EEF7;
  --violet: #5B4F9E;
  --violet-soft: #ECEAF6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 16px rgba(20, 40, 30, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background: linear-gradient(150deg, #1E4A36 0%, #2F6B4F 55%, #3E5E7A 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero h1 { font-size: 34px; margin-top: 18px; }
.login-hero p { opacity: .82; max-width: 460px; font-size: 15px; }
.login-steps { display: grid; gap: 10px; max-width: 420px; }
.login-steps div { display: flex; gap: 12px; align-items: center; background: rgba(255,255,255,.08); padding: 10px 14px; border-radius: 10px; }
.login-steps b { width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 12px; flex: none; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand img { width: 34px; height: 34px; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: #17362A; color: #D8E6DE; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .brand { color: #fff; padding: 4px 10px 18px; font-size: 15px; }
.side a.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #C9D9D0; font-weight: 600;
}
.side a.nav:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side a.nav.on { background: rgba(255,255,255,.12); color: #fff; }
.side a.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .count { margin-left: auto; background: #E9A23B; color: #1D2A23; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.side .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.side .me { margin-top: auto; padding: 12px; border-radius: 10px; background: rgba(255,255,255,.05); font-size: 12.5px; }
.side .me b { display: block; color: #fff; font-size: 13.5px; }
.side .me .links { display: flex; gap: 12px; margin-top: 8px; }
.side .me a { color: #A9D3BC; cursor: pointer; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px; }
.tile { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: default; }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--brand-2); }
.tile .v { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tile.accent { background: var(--brand); color: #fff; border-color: var(--brand); }
.tile.accent .l { color: rgba(255,255,255,.8); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.stack > *, .grid2 > *, .card { min-width: 0; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
.btn:hover { border-color: #C5CEC8; background: #FAFBFA; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #285D44; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: var(--warn-soft); border-color: #F0D7A8; color: #7A4F0E; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }

/* ---------- forms */
label.f { display: block; font-weight: 600; font-size: 13px; }
label.f > .inp, label.f > .input-btn { margin-top: 5px; }
label.f .req { color: var(--danger); }
label.f .hint { font-weight: 500; color: var(--muted); font-size: 12px; }
label.f .err { display: block; font-weight: 600; color: var(--danger); font-size: 12px; margin-top: 3px; }
label.f > .hint:last-child { display: block; margin-top: 3px; }
.inp, select.inp, textarea.inp {
  width: 100%; padding: 9px 11px; border: 1px solid #CFD7D2; border-radius: 9px; background: #fff; outline: none;
}
.inp:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(62,135,98,.15); }
.inp.bad { border-color: var(--danger); }
.inp[readonly], .inp:disabled { background: #F4F6F5; color: #4A5750; }
textarea.inp { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .span3 { grid-column: 1 / -1; }
.fieldset-title { grid-column: 1 / -1; font-weight: 800; font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.input-btn { display: flex; gap: 8px; }
.input-btn .inp { flex: 1; }
.filters { display: grid; grid-template-columns: 2fr repeat(6, 1fr); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 700; background: #FAFBFA; white-space: nowrap; position: sticky; top: 0; }
.tbl th.sort { cursor: pointer; user-select: none; }
.tbl th.sort:hover { color: var(--ink); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: #F6F9F7; }
.tbl tfoot td { font-weight: 800; background: #FAFBFA; }
.tbl tr.off td { color: #9AA59F; text-decoration: line-through; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { background: #EEF1EF; color: #4B5A52; }
.st-viloyat { background: var(--info-soft); color: var(--info); }
.st-respublika { background: var(--violet-soft); color: var(--violet); }
.st-approved { background: var(--brand-soft); color: var(--brand); }
.st-returned { background: var(--warn-soft); color: #8A5A12; }
.st-cancelled { background: var(--danger-soft); color: var(--danger); }
.st-pending { background: var(--warn-soft); color: #8A5A12; }
.st-applied { background: var(--brand-soft); color: var(--brand); }
.st-rejected { background: var(--danger-soft); color: var(--danger); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #EEF1EF; font-size: 12px; font-weight: 600; }
.plus { color: var(--brand); font-weight: 800; }
.minus { color: var(--danger); font-weight: 800; }

/* ---------- alerts */
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.warn { background: var(--warn-soft); border-color: #F0D7A8; color: #6B4510; }
.alert.danger { background: var(--danger-soft); border-color: #F5C2BD; color: #7A1C14; }
.alert.info { background: var(--info-soft); border-color: #C8D8EA; color: #22476B; }
.alert.ok { background: var(--brand-soft); border-color: #C3DDCD; color: #1F4D37; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- subject card */
.subject-head { padding: 18px; display: grid; gap: 12px; }
.subject-head .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; }
.subject-head .meta b { color: var(--ink); }
.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 4px; }
.flow div { position: relative; padding: 8px 10px 8px 34px; font-size: 12.5px; font-weight: 700; color: var(--muted); border-top: 3px solid var(--line); }
.flow div::before { content: attr(data-n); position: absolute; left: 6px; top: 7px; width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: var(--muted); display: grid; place-items: center; font-size: 11px; }
.flow div.done { color: var(--brand); border-color: var(--brand); }
.flow div.done::before { background: var(--brand); color: #fff; content: "✓"; }
.flow div.cur { color: var(--ink); border-color: var(--info); }
.flow div.cur::before { background: var(--info); color: #fff; }
.flow div.bad { color: var(--danger); border-color: var(--danger); }
.flow div.bad::before { background: var(--danger); color: #fff; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }
.tabs button:disabled { opacity: .4; cursor: not-allowed; }
.tabs button .n { display: inline-block; margin-left: 6px; font-size: 11px; background: #EEF1EF; padding: 0 6px; border-radius: 99px; }
.tab-body { padding: 18px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.doc-cat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.doc-cat.ok { border-color: #C3DDCD; background: #FAFDFB; }
.doc-cat.miss { border-color: #F0D7A8; background: #FFFCF6; }
.doc-cat .t { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.doc-cat .t b { min-width: 0; flex: 1 1 220px; }
.doc-cat .t b { font-size: 13.5px; }
.doc-file { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 6px 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.doc-file svg { width: 18px; height: 18px; flex: none; color: var(--brand); }
.doc-file .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding-bottom: 14px; position: relative; }
.tl::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-soft); border: 2px solid var(--brand-2); margin-top: 2px; }
.tl .dot.bad { background: var(--danger-soft); border-color: var(--danger); }
.tl .dot.info { background: var(--info-soft); border-color: var(--info); }
.tl .when { color: var(--muted); font-size: 12px; }
.diff { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.diff s { color: #A3ACA7; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* ---------- modal / toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 30, 22, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-b { padding: 18px 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #1D2A23; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: fade .15s; font-weight: 600; }
.toast.err { background: var(--danger); }
.guide h2 { margin: 18px 0 8px; }
.guide ol, .guide ul { padding-left: 20px; margin: 6px 0; }
.guide li { margin: 4px 0; }
.spinner { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- ochiq sahifalar */
.pub { min-height: 100vh; display: flex; flex-direction: column; }
.pub-head { background: #17362A; color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pub-head .brand { color: #fff; text-decoration: none; }
.pub-head .brand img { width: 30px; height: 30px; }
.pub-main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }
.pub-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 16px; border-top: 1px solid var(--line); }
.pub-hero { margin-bottom: 18px; }
.pub-hero p { color: var(--muted); max-width: 720px; }
.verify { text-align: center; padding: 28px 18px; border-radius: var(--radius); border: 1px solid; }
.verify.ok { background: var(--brand-soft); border-color: #C3DDCD; color: #1F4D37; }
.verify.bad { background: var(--danger-soft); border-color: #F5C2BD; color: #7A1C14; }
.verify-mark { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #fff; }
.verify.ok .verify-mark { background: var(--brand); }
.verify.bad .verify-mark { background: var(--danger); }
.verify p { max-width: 620px; margin: 8px auto; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 20px; }
  .login-hero h1 { font-size: 24px; }
  .login-steps { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .v { font-size: 20px; }
  .subject-head h1 { font-size: 19px; overflow-wrap: anywhere; }
  .sticky-actions { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 14px; }
  .sticky-actions > span { text-align: center; }
  .sticky-actions .btn { white-space: normal; }
  .page-head .row .btn { flex: 1; }
  .btn { white-space: normal; text-align: center; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #17362A; color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; padding: 4px; display: grid; }
  .topbar button svg { width: 22px; height: 22px; }
  .main { padding: 16px 16px 60px; }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .flow { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
