:root {
  --bg: #f3f4f6; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --primary: #1d4ed8; --primary-ink: #fff; --danger: #dc2626; --danger-bg: #fef2f2; --danger-line: #fecaca;
  --ok: #15803d; --ok-bg: #f0fdf4; --head: #1f2a37; --head-ink: #f9fafb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1016; --card: #151c24; --text: #e5e7eb; --muted: #9ca3af; --line: #26303b;
    --primary: #3b82f6; --danger: #f87171; --danger-bg: #2a1215; --danger-line: #5b1d22;
    --ok: #4ade80; --ok-bg: #0f2418; --head: #0f151c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--head); color: var(--head-ink); display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
header.top h1 { font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top .btn { background: rgba(255,255,255,.12); color: var(--head-ink); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card h2 { font-size: 18px; margin-bottom: 12px; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; min-height: 48px; cursor: pointer; font-weight: 600; background: var(--line); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { font-size: 19px; padding: 16px 22px; }
.btn:disabled { opacity: .5; }

/* Qizil ogohlantirish (masalan bo'lim sozlanmagan) */
.alarm { background: var(--danger-bg); border: 2px solid var(--danger); border-radius: 14px; padding: 14px 16px; animation: pulse 2s ease-in-out infinite; }
.alarm h2 { color: var(--danger); font-size: 19px; margin-bottom: 8px; }
.alarm-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--danger-line); }
.alarm-item:first-of-type { border-top: 0; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 18%, transparent); } }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } }
.allgood { background: var(--ok-bg); color: var(--ok); border-radius: 14px; padding: 12px 16px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 14px; }
td.r, th.r { text-align: right; }
.tablewrap { overflow-x: auto; }

.stages { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stage-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; text-align: left; }
.stage-card.bad { border: 2px solid var(--danger); background: var(--danger-bg); }
.stage-card .n { font-size: 13px; color: var(--muted); }
.stage-card .name { font-size: 18px; font-weight: 700; }
.stage-card .badge { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 600; }
.stage-card.bad .badge { color: var(--danger); }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tabs .btn { white-space: nowrap; }
.tabs .btn.on { background: var(--primary); color: var(--primary-ink); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.pill.open { background: var(--danger-bg); color: var(--danger); }
.pill.resolved { background: var(--ok-bg); color: var(--ok); }

/* Kirish */
.login { max-width: 420px; margin: 10vh auto; padding: 16px; }
.login .card { display: grid; gap: 14px; padding: 24px; }
label { display: grid; gap: 6px; font-size: 15px; color: var(--muted); }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px; font-size: 17px; }
.err { color: var(--danger); min-height: 1em; margin: 0; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 14px; padding: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 14px; min-height: 48px; cursor: pointer; }
.chips button.on { background: var(--danger); color: #fff; border-color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input { width: auto; flex: 1; min-width: 140px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }

/* ---- Ishlab chiqarish ---- */
:root { --okbtn: #15803d; --warn: #b45309; --warn-bg: #fffbeb; }
@media (prefers-color-scheme: dark) { :root { --okbtn: #16a34a; --warn: #fbbf24; --warn-bg: #2a2110; } }
.btn.ok { background: var(--okbtn); color: #fff; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 15px; }
.pill.demo { background: #fde68a; color: #78350f; }
.alarm-mini { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--danger-bg); border: 1px solid var(--danger); color: var(--danger); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.route { color: var(--muted); font-size: 15px; margin: -4px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-height: 104px; cursor: pointer; display: grid; gap: 6px; align-content: start; }
.tile:active { transform: scale(.98); }
.tile .t-name { font-size: 18px; font-weight: 700; }
.tile .t-sub { font-size: 14px; color: var(--muted); }
.tile.short { border-color: var(--warn); }
.tile.short .t-sub.w { color: var(--warn); }
.qty { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; }
.qty input { text-align: center; font-size: 32px; font-weight: 700; padding: 8px; }
.qbtn { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; font-size: 30px; font-weight: 700; cursor: pointer; }
td.w, .w { color: var(--warn); font-weight: 600; }
.status-done { color: var(--ok); font-weight: 600; }
.status-failed { color: var(--danger); font-weight: 600; }
.status-canceled { color: var(--muted); text-decoration: line-through; }
.status-pending { color: var(--muted); }
details.card > summary { cursor: pointer; font-weight: 700; font-size: 18px; list-style: none; }
details.card > summary::after { content: '▾'; float: right; color: var(--muted); }
details.card[open] > summary { margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--okbtn); color: #fff; padding: 14px 22px; border-radius: 14px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--danger); }
.total-row td { font-weight: 700; border-bottom: 0; }

/* ---- Bo'lim ekrani v2: oynalar, qidiruv, ixcham ro'yxat ---- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { border: 0; background: transparent; border-radius: 10px; min-height: 48px; font-weight: 700; font-size: 17px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--primary); color: var(--primary-ink); }
.search { font-size: 19px; padding: 14px 16px; border-radius: 12px; }
.small-search { font-size: 16px; padding: 10px 12px; margin-bottom: 8px; }
.route { margin: 10px 0 8px; }
.sub { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 6px; }
.rows { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; background: var(--card); border: 0; border-top: 1px solid var(--line); padding: 14px 16px; min-height: 56px; cursor: pointer; font-size: 17px; }
.row:first-child { border-top: 0; }
.row:active { background: var(--bg); }
.row .r-main { display: grid; gap: 2px; min-width: 0; }
.row .r-name { font-weight: 600; overflow-wrap: anywhere; }
.row .r-warn { font-size: 13px; }
.row .r-side { white-space: nowrap; font-size: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.stock-rows { max-height: 60vh; overflow: auto; }
.srow { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.srow:first-child { border-top: 0; }
.srow[hidden] { display: none; }
tr.status-canceled td { color: var(--muted); text-decoration: line-through; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }
.rows-head { display: flex; justify-content: space-between; gap: 12px; padding: 8px 16px; font-size: 13px; color: var(--muted); background: var(--bg); }

/* ---- Katalog ---- */
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.pcard { display: grid; grid-template-rows: auto 1fr auto; gap: 8px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; min-height: 220px; }
.pcard:active { transform: scale(.98); }
.pcard:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.pimg { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: hsl(var(--h) 55% 88%); }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pini { font-size: 34px; font-weight: 800; letter-spacing: .02em; color: hsl(var(--h) 45% 32%); }
@media (prefers-color-scheme: dark) { .pimg { background: hsl(var(--h) 30% 22%); } .pini { color: hsl(var(--h) 60% 78%); } }
.pname { font-weight: 700; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.pmeta { display: grid; gap: 2px; font-size: 13px; }
.pok { color: var(--ok); }
@media (max-width: 520px) { .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .pcard { min-height: 200px; } }
.dhead { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.dhead h2 { margin-bottom: 6px; }
.dhead p { margin: 0; }
.dimg { width: 120px; }
.dimg .pini { font-size: 40px; }
@media (max-width: 520px) { .dhead { grid-template-columns: 84px 1fr; } .dimg { width: 84px; } .dimg .pini { font-size: 28px; } }
/* "Omborda bor" tavsiyasi o'ng tomonda — o'ng qo'l bilan bosishga qulay */
#produce-quick { justify-content: flex-end; }
/* Xomashyo tahrirlash (1-bo'lim) */
.mats .mat-in { width: 96px; text-align: right; padding: 8px 10px; font-size: 17px; }
.mats .mat-in.changed { border-color: var(--warn); background: var(--warn-bg); }
.xbtn { border: 1px solid var(--line); background: transparent; border-radius: 10px; width: 40px; height: 40px; font-size: 22px; cursor: pointer; color: var(--muted); }
.addmat { margin-top: 10px; display: grid; gap: 8px; justify-items: end; }
.addmat #addmat-box { width: 100%; }
.addmat-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.srow.pick { width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer; padding: 12px; font-size: 16px; }
.srow.pick:first-child { border-top: 0; }
dialog { max-height: calc(100vh - 32px); overflow: auto; }
.target { font-size: 14px; }
.target select { font-size: 17px; padding: 12px; }
.target select.changed { border-color: var(--warn); background: var(--warn-bg); }
/* Qayerdan → Qayerga */
.flow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.flow-box { display: grid; gap: 6px; min-width: 0; }
.flow-lbl { font-size: 13px; color: var(--muted); }
.flow-from { display: flex; align-items: center; min-height: 50px; padding: 0 14px; border-radius: 10px; background: var(--line); font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.flow select { font-size: 17px; font-weight: 600; min-height: 50px; padding: 0 12px; }
.flow select.changed { border-color: var(--warn); background: var(--warn-bg); }
.flow-arrow { font-size: 30px; font-weight: 700; color: var(--primary); padding-bottom: 6px; }
/* Dialog ichidagi elementlar oynadan kengayib ketmasin (telefon) */
dialog form > * { min-width: 0; }
.flow select { width: 100%; min-width: 0; }
@media (max-width: 520px) {
  .flow { grid-template-columns: 1fr; gap: 6px; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; padding: 0; line-height: 1; }
  .mats .mat-in { width: 72px; }
}

/* ---- Kirish sahifasi ---- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; margin: 0 auto; padding: 24px 16px; max-width: 460px; }
.login-card { width: 100%; gap: 18px; padding: 28px 24px; border-radius: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
.login-head { text-align: center; display: grid; gap: 6px; justify-items: center; }
.login-head h1 { font-size: 26px; }
.login-head p { margin: 0; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 34px; background: var(--primary); color: var(--primary-ink); margin-bottom: 6px; }
.fld { display: grid; gap: 8px; }
.fld-lbl { font-size: 15px; font-weight: 600; color: var(--text); }
.phone-grp, .pass-grp { display: flex; align-items: stretch; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); overflow: hidden; }
.phone-grp:focus-within, .pass-grp:focus-within { border-color: var(--primary); }
.phone-grp input, .pass-grp input { border: 0; background: transparent; border-radius: 0; font-size: 22px; padding: 14px 12px; min-width: 0; flex: 1; letter-spacing: .03em; }
.phone-grp input:focus, .pass-grp input:focus { outline: none; }
.phone-pre { display: grid; place-items: center; padding: 0 12px 0 16px; font-size: 22px; font-weight: 700; color: var(--muted); border-right: 1px solid var(--line); background: var(--card); }
.eye { border: 0; border-left: 1px solid var(--line); background: var(--card); width: 60px; font-size: 22px; cursor: pointer; }
.login-err { min-height: 1.4em; text-align: center; font-weight: 600; }
.login-btn { width: 100%; min-height: 58px; font-size: 20px; }
.phone-grp input, .pass-grp input { color: var(--text); font-weight: 600; }
.phone-grp input::placeholder, .pass-grp input::placeholder { color: var(--muted); font-weight: 400; opacity: .7; }
/* Ish haqi */
.pay { color: var(--ok); font-weight: 600; }
.pcard .pay { font-size: 13px; }
.paybox { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); }
.paybox .pay-total { font-size: 22px; }
.paybox .pay-names { grid-column: 1 / -1; font-size: 13px; }
#produce-title:focus { outline: none; }
.unit { font-size: .85em; color: var(--muted); font-weight: 400; }
td.w .unit { color: inherit; }

/* Bo'lim ish haqi */
.earn { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px 24px; padding: 14px 18px; margin-bottom: 12px; border-radius: 14px; background: var(--ok-bg); color: var(--ok); }
.earn > div { display: flex; flex-direction: column; }
.earn-lbl { font-size: 14px; font-weight: 600; opacity: .85; }
.earn-big { font-size: 30px; line-height: 1.15; }
.earn-month { text-align: right; }
.earn-month b { font-size: 18px; }
.stage-card .pay { margin-top: 6px; font-size: 14px; }
.payhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.payhead h2 { margin: 0; }
@media (max-width: 520px) {
  .adm-today { font-size: 13px; }
  .adm-today th, .adm-today td { padding-left: 4px; padding-right: 4px; }
  .adm-today .task-no, .adm-today .unit-som { display: none; }
}

/* Sozlamalar */
.settings { display: grid; gap: 16px; }
.settings form.card, .settings section.card { display: grid; gap: 10px; }
.settings h2 { margin: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.kv { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 12px; margin: 0; display: grid; gap: 10px; }
.kv legend { font-weight: 700; padding: 0 6px; }
.kv-row { display: grid; gap: 6px; }
.kv-lbl { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.settings .inline input { min-width: 0; }
#s-hook { font-size: 14px; flex: 1 1 260px; }
.hook-last { margin: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } .facts dt { margin-top: 6px; } }
@media (max-width: 520px) {
  .hook-table thead { display: none; }
  .hook-table, .hook-table tbody, .hook-table tr, .hook-table td { display: block; width: 100%; }
  .hook-table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .hook-table td { border: 0; padding: 2px 0; }
  .hook-table td:first-child { color: var(--muted); font-size: 13px; }
}

/* Bo'lim ekrani: yig'ma satr, 3 tab, katalog sahifalash */
.seg.seg3 { grid-template-columns: 1.3fr 1fr 1fr; }
.seg .cnt { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 99px; background: rgba(127,127,127,.18); font-size: 14px; }
.seg .cnt:empty { display: none; }
.seg button.on .cnt { background: rgba(255,255,255,.25); }
.sumbar { width: 100%; min-height: 52px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; padding: 10px 16px; margin: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--ok-bg); color: var(--text); font-size: 17px; text-align: left; cursor: pointer; }
.sumbar .sum-side { font-size: 14px; }
.searchbar { position: sticky; top: 64px; z-index: 3; background: var(--card); padding: 6px 0; margin-top: -6px; }
.more { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 14px; }
.more .btn { min-height: 52px; width: min(100%, 420px); }
.empty { text-align: center; padding: 24px 8px; }
.today-t .btn.small { min-height: 44px; }
@media (max-width: 520px) {
  .seg button { font-size: 15px; padding: 0 4px; }
  .sumbar { font-size: 15px; padding: 10px 12px; }
  .today-t thead { display: none; }
  .today-t, .today-t tbody, .today-t td { display: block; }
  .today-t tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "time name name" "qty pay status" "act act act"; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .today-t td { border: 0; padding: 0; text-align: left; }
  .today-t td:nth-child(1) { grid-area: time; }
  .today-t td:nth-child(2) { grid-area: name; }
  .today-t td:nth-child(3) { grid-area: qty; }
  .today-t td:nth-child(4) { grid-area: pay; text-align: right; }
  .today-t td:nth-child(5) { grid-area: status; text-align: right; }
  .today-t td:nth-child(6) { grid-area: act; }
  .today-t td:empty { display: none; }
  .today-t td:nth-child(6) .btn { width: 100%; }
  .today-t .total-row { border-bottom: 0; }
}


/* Oylik hisobot */
.monthnav { display: flex; gap: 6px; align-items: center; }
.monthnav input { width: auto; min-height: 48px; padding: 8px 10px; }
.monthnav .btn { min-width: 48px; min-height: 48px; font-size: 22px; }
.stage-sums { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 10px 0; }
.ssum { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ssum.total { border-color: var(--ok); }
.ssum .big { font-size: 20px; }
.small { font-size: 12px; }
.report .actions a.btn { text-decoration: none; display: inline-flex; align-items: center; color: var(--text); }
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; --ok: #000; }
  body { background: #fff; color: #000; }
  header.top, nav.tabs, nav.seg, .sumbar, .noprint, .toast, dialog { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .tablewrap { overflow: visible; }
  .print-only { display: block; }
}

/* Sarlavha: telefonda nom (va DEMO) birinchi qatorda to'liq, tugmalar ikkinchi qatorda */
header.top [hidden] { display: none !important; }
@media (max-width: 520px) {
  header.top { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  header.top h1 { flex: 1 0 100%; white-space: normal; overflow: visible; font-size: 19px; }
  header.top .btn { flex: 1 1 0; min-height: 44px; padding: 8px 10px; }
  .searchbar { top: var(--head-h, 112px); }
}
/* details > summary — bosish joyi >= 44px */
details.card > summary { min-height: 44px; display: flex; align-items: center; gap: 8px; }
details.card > summary::after { float: none; margin-left: auto; }
details.card > summary::-webkit-details-marker { display: none; }

/* Ish haqi: sana oralig'i, bo'lim kartalari tugma, ro'yxat */
.payfilter { display: grid; gap: 10px; }
.pf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pf-date { display: grid; gap: 4px; font-weight: 600; }
.pf-date input { min-height: 48px; font-size: 18px; letter-spacing: .02em; }
.pf-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-quick .btn { min-height: 44px; }
.pf-quick .btn.on { background: var(--primary); color: var(--primary-ink, #fff); }
.pf-hint { margin: 0; }
.ssum-btn { display: grid; gap: 2px; text-align: left; background: var(--card); color: var(--text); cursor: pointer; font: inherit; min-height: 44px; }
.ssum-btn:hover { border-color: var(--primary); }
.ssum-go { font-size: 13px; font-weight: 700; color: var(--primary); }
.rec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.rec-head h2 { margin: 0; }
.report h3 { margin: 16px 0 6px; font-size: 16px; }
.seg.seg2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .pf-row { grid-template-columns: 1fr 1fr; } .pf-date input { font-size: 16px; padding: 10px; } }

/* Loginlar */
.ulist { display: grid; gap: 4px; }
.urow { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.4fr) minmax(220px, 1.2fr); gap: 10px 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.urow:first-child { border-top: 0; }
.uname { display: grid; gap: 2px; }
.urow .inline { flex-wrap: wrap; }
.urow .inline input { min-width: 0; flex: 1 1 140px; min-height: 44px; }
.urow .inline .btn { min-height: 44px; }
.urow .phone-pre { font-weight: 700; color: var(--muted); }
@media (max-width: 860px) { .urow { grid-template-columns: 1fr; } }

/* Sozlamalar: asosiy Bito ulanish + yig'iladigan qo'shimcha */
.conn { margin: 0; }
details.adv > .settings { margin-top: 12px; }
details.adv > .settings > .card, details.adv > .settings > form.card { border: 1px solid var(--line); box-shadow: none; }
.uname .pill { justify-self: start; }
.urow .phone-pre { font-size: 16px; padding: 0 2px; border: 0; background: none; }
@media (max-width: 520px) {
  .sheets-t thead { display: none; }
  .sheets-t, .sheets-t tbody, .sheets-t td { display: block; }
  .sheets-t tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "name name name" "n qty pay"; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .sheets-t td { border: 0; padding: 0; text-align: left; }
  .sheets-t td:nth-child(1) { grid-area: name; }
  .sheets-t td:nth-child(2) { grid-area: n; color: var(--muted); }
  .sheets-t td:nth-child(2)::after { content: ' ta'; }
  .sheets-t td:nth-child(3) { grid-area: qty; }
  .sheets-t td:nth-child(4) { grid-area: pay; text-align: right; }
}
.mats .locked { color: var(--muted); white-space: nowrap; }
.stage-card .flow { font-weight: 700; color: var(--primary); } .chain { margin: 0 0 4px; }

/* Natija (chiqadigan mahsulot) — tema 'ok' rangi */
.produce-out { margin: 4px 0 0; color: var(--ok); font-weight: 600; font-size: 15px; }
.pout { color: var(--ok); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 520px) { .pcard .pout { display: none; } } /* telefonda karta balandligi oshmasin — natija oynada ko'rinadi */

/* Bugun oynasi: kun tanlash; qatordagi natija */
.daybar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.daybar .btn { min-height: 44px; }
.daybar .btn.on { background: var(--primary); color: var(--primary-ink, #fff); }
.daybar .pf-date input { width: 150px; min-height: 44px; }
.row-out { color: var(--ok); font-size: 13px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Telefonda komponentlar — karta: nom + × birinchi qatorda, Tarkibda / Haqiqatda / Omborda ikkinchi qatorda */
@media (max-width: 520px) {
  .mats thead { display: none; }
  .mats, .mats tbody, .mats td { display: block; }
  .mats tr { display: grid; grid-template-columns: 0.9fr 1.5fr 1fr auto; grid-template-areas: "name name name del" "tpl need have have"; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .mats td { border: 0; padding: 0; text-align: left; min-width: 0; }
  .mats td:nth-child(1) { grid-area: name; }
  .mats td[data-tpl] { grid-area: tpl; }
  .mats td[data-label="Haqiqatda"] { grid-area: need; }
  .mats td[data-have] { grid-area: have; }
  .mats td:last-child:not([data-have]) { grid-area: del; }
  .mats td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
  .mats .mat-in { width: 72px; max-width: 100%; }
  .mats td[data-label="Haqiqatda"] { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
  .mats td[data-label="Haqiqatda"]::before { flex-basis: 100%; }
}

/* Sana oralig'i tanlagich (public/daterange.js) */
:root { --dr-accent: #2563eb; --dr-accent-strong: #1e40af; --dr-soft: #dbeafe; }
html[data-stage] { --dr-accent: var(--stage); --dr-accent-strong: color-mix(in srgb, var(--stage) 75%, #000); --dr-soft: color-mix(in srgb, var(--stage) 16%, #fff); }
.dr-btn { min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); font-weight: 700; font-size: 17px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dr-btn:focus-visible { outline: 3px solid var(--dr-accent); outline-offset: 2px; }
.dr-pop { position: absolute; z-index: 50; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 16px; width: max-content; max-width: calc(100vw - 16px); }
.dr-main { display: flex; gap: 16px; }
.dr-cal { min-width: 0; }
.dr-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.dr-title { font-size: 17px; }
.dr-nav { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 22px; cursor: pointer; color: var(--text); }
.dr-nav:hover:not([disabled]) { background: var(--bg); }
.dr-nav[disabled] { opacity: .3; cursor: default; }
.dr-grid { border-collapse: separate; border-spacing: 0 4px; }
.dr-grid th { font-size: 13px; color: var(--muted); font-weight: 600; padding: 4px 0; width: 44px; text-align: center; }
.dr-grid td { padding: 0; text-align: center; }
.dr-day { width: 44px; height: 40px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; cursor: pointer; border-radius: 0; font-variant-numeric: tabular-nums; }
.dr-day.out { color: var(--muted); }
.dr-day.in { background: var(--dr-soft); }
.dr-day.start { border-radius: 10px 0 0 10px; }
.dr-day.end { border-radius: 0 10px 10px 0; }
.dr-day.start.end { border-radius: 10px; }
.dr-day.start, .dr-day.end { background: var(--dr-accent); color: #fff; font-weight: 700; }
.dr-day.last { background: var(--dr-accent-strong); color: #fff; }
.dr-day.today:not(.in) { box-shadow: inset 0 0 0 2px var(--dr-accent); border-radius: 10px; }
.dr-day.fut { color: var(--muted); opacity: .35; cursor: not-allowed; }
.dr-day:hover:not([disabled]):not(.start):not(.end) { background: var(--bg); border-radius: 10px; }
.dr-day:focus-visible { outline: 3px solid var(--dr-accent); outline-offset: -3px; border-radius: 10px; }
.dr-presets { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--line); display: grid; gap: 2px; align-content: start; min-width: 150px; }
.dr-presets button { width: 100%; text-align: left; min-height: 40px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.dr-presets button:hover { background: var(--bg); }
.dr-presets button.on { background: var(--line); font-weight: 700; }
.dr-foot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; display: grid; gap: 8px; }
.dr-inputs { display: flex; align-items: center; gap: 8px; }
.dr-in { width: 130px; min-height: 44px; padding: 8px 10px; font-size: 16px; text-align: center; }
.dr-err { margin: 0; color: var(--danger); font-size: 14px; }
.dr-err:empty { display: none; }
.dr-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dr-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 49; }
@media (max-width: 520px) {
  .dr-btn { width: 100%; text-align: left; }
  .dr-pop.dr-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: calc(100vh - 170px); overflow-y: auto; border-radius: 18px 18px 0 0; padding: 14px 12px calc(14px + env(safe-area-inset-bottom)); }
  .dr-main { flex-direction: column; gap: 10px; }
  .dr-cal { order: 2; }
  .dr-grid { width: 100%; table-layout: fixed; }
  .dr-grid th { width: auto; }
  .dr-day { width: 100%; height: 44px; }
  .dr-presets { order: 1; border-left: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
  .dr-presets li { flex: 0 0 auto; }
  .dr-presets button { white-space: nowrap; background: var(--bg); min-height: 40px; }
  .dr-inputs { justify-content: center; }
  .dr-in { width: 0; flex: 1; }
  .dr-actions .btn { flex: 1; min-height: 48px; }
}
.pf-row1 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 6px; }
.pf-lbl { font-weight: 700; }
.dr-actions .btn.primary { background: var(--dr-accent); color: #fff; }
.monthnav .monthlbl { min-width: 130px; text-align: center; font-size: 17px; } .monthnav .btn[disabled] { opacity: .35; cursor: default; }

/* Rasmsiz karta (Bito'da rasm yo'q) — ixcham: nom va ma'lumotlar */
.pcard.noimg { min-height: 0; grid-template-rows: auto auto 1fr; grid-template-columns: 1fr; }
@media (max-width: 520px) { .pcard.noimg { grid-template-columns: 1fr; } }
@media (max-width: 520px) { #produce-target { font-size: 15px; padding-right: 28px; } }
.pimg[hidden], .dimg[hidden] { display: none !important; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 22px; height: 22px; }

/* Sozlamalar → Bo'limlar */
.err.pre { white-space: pre-line; }
.notice { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, #16a34a 12%, transparent); margin: 8px 0; }
.stage-t td { vertical-align: top; }
.stage-t tr.bad td:first-child { border-left: 3px solid #dc2626; }
.stage-form { margin-top: 12px; }
.stage-form select { width: 100%; }
ul.audit { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.pill.neutral { background: color-mix(in srgb, currentColor 10%, transparent); font-weight: 500; }
