:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #111214;
  --muted: #62666d;
  --line: #e3e5df;
  --lime: #b5e655;
  --lime-ink: #18200a;
  --lime-soft: #eef8d9;
  --ok: #1f7a3d;  --ok-bg: #e7f5ec;
  --warn: #8a5a00; --warn-bg: #fff4dc;
  --bad: #b3261e;  --bad-bg: #fdeceb;
  --dark: #0b0c0e;
  --radius: 14px;
  --gap: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #6d8f1f; outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--dark); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand b { color: #6d8f1f; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--dark); color: var(--lime); font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #c9ccc4; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.btn-primary:hover { background: #a7d94a; }
.btn-dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-danger { color: var(--bad); border-color: #f0c7c4; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }

input, select, textarea { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
textarea { min-height: 80px; resize: vertical; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 14px; }

/* Kirish */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--dark); }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 28px; display: grid; gap: 16px; }
.login-card h1 { font-size: 22px; }

/* Yuqori panel */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--dark); color: #fff; }
.topbar .brand b { color: var(--lime); }
.topbar .brand-mark { background: var(--lime); color: var(--dark); }
.tabs { order: 3; width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: #c9ccd2; cursor: pointer; font-weight: 600; }
.tabs button[aria-selected="true"] { background: #23262b; color: #fff; box-shadow: inset 0 -3px 0 var(--lime); }
.count:empty { display: none; }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: var(--lime); color: var(--dark); font-size: 12px; }
.me { margin-left: auto; display: flex; gap: 4px; }
.me .btn { color: #e8eaed; }
#me-button { max-width: 220px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 40px; }
a { color: #4b6a10; }
@media (min-width: 900px) { .tabs { order: 0; width: auto; flex: 1; } .me { margin-left: 0; } }

main { padding: 16px; max-width: 1240px; margin: 0 auto; display: grid; gap: var(--gap); }
main:focus { outline: none; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.toolbar > label { flex: 1 1 160px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--dark); color: #fff; border-color: var(--dark); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px; text-align: left; width: 100%; cursor: pointer; }
.item:hover { border-color: #c9ccc4; }
.item .title { font-weight: 700; }
.item .sub { color: var(--muted); font-size: 13px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-muted { background: #eef0ec; color: var(--muted); }
.b-lime { background: var(--lime-soft); color: #4b6a10; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 800; }

/* Yon oyna */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(10, 11, 13, .55); }
.drawer { margin: 0 0 0 auto; width: min(640px, 100vw); max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; background: var(--bg); }
.drawer-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; }
.drawer-body { padding: 16px; display: grid; gap: 14px; }
.section { padding: 14px; display: grid; gap: 10px; }
.section h3 { font-size: 15px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.doc { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.doc:first-of-type { border-top: 0; }
.doc .actions, .row-end, .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.problems { margin: 0; padding-left: 18px; color: var(--warn); }
.history { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.history li { padding: 8px 10px; background: #f8f9f6; border-radius: 10px; }

.viewer { width: min(960px, 100vw); height: min(92vh, 1000px); max-width: 100vw; border-radius: 16px; background: var(--surface); }
.viewer-body { height: calc(100% - 60px); display: grid; place-items: center; background: #1b1d21; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.prompt { width: min(440px, calc(100vw - 32px)); border-radius: 16px; background: var(--surface); }
.prompt form { padding: 20px; display: grid; gap: 12px; }
.prompt h2 { font-size: 18px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 16px;
  border-radius: 12px; background: var(--dark); color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }
.toast.error { background: var(--bad); }
.loading { padding: 32px; text-align: center; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
