/* Smartlock Stock — одна таблица стилей, сначала телефон */
:root {
  --bg: #f3f5f4; --card: #fff; --ink: #1d2a26; --muted: #66756f; --line: #dfe5e2;
  --brand: #2f5d50; --brand2: #3f7a69; --soft: #e8f0ed;
  --red: #c0392b; --redbg: #fdecea; --amber: #a86b00; --amberbg: #fff4dc; --green: #237a46; --greenbg: #e5f5ea;
  --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 6px 0 14px; }
h2 { font-size: 17px; margin: 0 0 10px; }
main { max-width: 1180px; margin: 0 auto; padding: 14px 14px 96px; }
body.out main { padding-top: 8vh; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.pad { padding: 4px 2px; margin: 0; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #d9e8e2; text-decoration: none; padding: 7px 12px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.on { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.me { display: flex; align-items: center; gap: 12px; }
.me .who { color: #fff; text-decoration: none; display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.me .who small { color: #cfe1da; font-size: 12px; }
.me form { margin: 0; }
.top .link { color: #fff; }

/* нижняя панель на телефоне */
.tabbar { display: none; }
.mobile-only { display: none; }
@media (max-width: 760px) {
  .top { padding: 10px 14px; }
  .nav, .me { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; color: var(--muted); font-size: 11.5px; padding: 3px 0; }
  .tabbar a span { font-size: 20px; line-height: 1.1; }
  .tabbar a.on { color: var(--brand); font-weight: 600; }
  .tabbar a.plus span { background: var(--brand); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-size: 19px; }
  .mobile-only { display: flex; }
  main { padding: 12px 10px 92px; }
  h1 { font-size: 20px; }
}

/* карточки, кнопки, формы */
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.03); }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 420px; margin: 0 auto 14px; }
.card.hl { box-shadow: 0 0 0 2px var(--brand2); }
.card.inline { display: flex; gap: 12px; align-items: end; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.head h1 { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--brand2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand2); }
.btn.wide { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; min-width: 0; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #cfd8d4; border-radius: 9px; padding: 9px 11px; min-height: 42px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand2); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 6px; margin: 0; color: var(--ink); font-size: 14px; white-space: nowrap; }
label.check input { width: auto; min-height: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 14px; }
fieldset.seg { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
fieldset.seg legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; width: 100%; }
fieldset.seg label { flex-direction: row; align-items: center; gap: 8px; margin: 0; padding: 9px 14px; border: 1px solid #cfd8d4; border-radius: 9px; color: var(--ink); font-size: 15px; cursor: pointer; }
fieldset.seg label:has(input:checked) { border-color: var(--brand); background: var(--soft); font-weight: 600; }
fieldset.seg input { width: auto; min-height: 0; margin: 0; accent-color: var(--brand); }
.actions { display: flex; gap: 10px; margin-top: 6px; }
.actions .btn { min-width: 180px; }
.crumbs { margin: 0 0 4px; font-size: 14px; }
.crumbs a { text-decoration: none; }
.links { gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.links form { margin: 0; }
.login { text-align: center; }
.login form, .login .flash { text-align: left; }
.login .logo img { width: 56px; height: 56px; }
.login h1 { margin: 8px 0 2px; }
.copy { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* сообщения */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--soft); }
.flash.ok { background: var(--greenbg); color: var(--green); }
.flash.err { background: var(--redbg); color: var(--red); }
.flash.warn { background: var(--amberbg); color: var(--amber); }
.flash[hidden] { display: none; }

/* метки */
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--brand); vertical-align: 1px; }
.tag.red { background: var(--redbg); color: var(--red); }
.tag.amber { background: var(--amberbg); color: var(--amber); }
.tag.green { background: var(--greenbg); color: var(--green); }
.tag.gray { background: #eceeed; color: var(--muted); }

/* таблицы */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #eef2f0; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.neg td { background: var(--redbg); }
.bad { color: var(--red); font-weight: 700; }
.plus { color: var(--green); font-weight: 600; }
.ok { color: var(--green); }
.defect { color: var(--red); }
.card.flush .tbl th:first-child, .card.flush .tbl td:first-child { padding-left: 16px; }
.off { opacity: .55; }

/* остатки */
.whs { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 14px; align-items: start; }
@media (max-width: 760px) { .whs { grid-template-columns: 1fr; } }
.wh-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.wh-head h2 { margin: 0; }
.wh-head .tot { margin-left: auto; font-size: 14px; }
details.cont { border: 1px solid var(--line); border-radius: 10px; margin-top: 10px; overflow: hidden; }
details.cont summary { cursor: pointer; padding: 10px 12px; background: #f7f9f8; display: flex; align-items: center; gap: 8px; list-style: none; }
details.cont summary::-webkit-details-marker { display: none; }
details.cont summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.cont[open] summary::before { transform: rotate(90deg); }
details.cont .cname { font-weight: 600; }
details.cont .cnt { margin-left: auto; }
details.cont .tbl th, details.cont .tbl td { padding-left: 12px; padding-right: 12px; }
.search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search input[type=search] { width: 240px; }
@media (max-width: 760px) { .head .search { width: 100%; } .search input[type=search] { flex: 1; width: auto; } }

/* новая операция */
.opgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.opbtn { display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--r); background: #fff; text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.03); border-left: 5px solid var(--brand); }
.opbtn b { font-size: 18px; }
.opbtn span { color: var(--muted); font-size: 14px; }
.opbtn.in { border-left-color: var(--green); }
.opbtn.out { border-left-color: var(--red); }
.opbtn.mv { border-left-color: var(--amber); }
.opbtn.inv { border-left-color: #5866a8; }
.opbtn:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08), 0 0 0 1px var(--brand2); }
@media (max-width: 760px) { .opgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .opbtn b { overflow-wrap: anywhere; font-size: 15.5px !important; } .opbtn { padding: 14px; } .opbtn b { font-size: 16px; } .opbtn span { font-size: 12.5px; } }

/* строки операции */
.lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.line { display: grid; grid-template-columns: 1.1fr 1.6fr .8fr 110px 40px; gap: 0 10px; align-items: end; padding: 12px 12px 4px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfb; }
.line:not(:has(.ld)) { grid-template-columns: 1.1fr 1.8fr 110px 40px; }
.line.neg { border-color: var(--amber); background: var(--amberbg); }
.line .x { width: 40px; height: 42px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 20px; color: var(--muted); cursor: pointer; }
.line .bal { grid-column: 1 / -1; margin: -6px 0 8px; min-height: 1em; }
.line.neg .bal { color: var(--amber); font-weight: 600; }
@media (max-width: 760px) {
  .line, .line:not(:has(.ld)) { grid-template-columns: 1fr 1fr 44px; }
  .line .li { grid-column: 1 / -1; order: -1; }
  .line .lc { grid-column: 1 / -1; order: -2; }
  .line .x { grid-column: 3; grid-row: 3; }
  .line:not(:has(.ld)) .lq { grid-column: 1 / 3; }
}

/* журнал */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; align-items: end; padding-bottom: 4px; }
.filters .fbtn { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.optag { font-weight: 600; text-decoration: none; white-space: nowrap; }
.t-receipt, .t-return { color: var(--green); }
.t-issue, .t-writeoff { color: var(--red); }
.t-transfer { color: var(--amber); }
.t-inventory { color: #5866a8; }
@media (max-width: 760px) {
  .journal thead { display: none; }
  .journal, .journal tbody, .journal tr, .journal td { display: block; width: 100%; }
  .journal tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .journal td { padding: 0; border: 0; }
  .card.flush .journal td:first-child { padding-left: 0; }
  .journal td:nth-child(1) { grid-column: 1; font-size: 13px; color: var(--muted); }
  .journal td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .journal td:nth-child(3) { grid-column: 1 / -1; font-size: 13px; }
  .journal td:nth-child(4) { grid-column: 1; font-weight: 600; }
  .journal td:nth-child(5) { grid-column: 2; grid-row: 4; font-size: 17px; }
  .journal td:nth-child(6), .journal td:nth-child(7) { grid-column: 1 / -1; color: var(--muted); }
  .journal td:nth-child(7)::before { content: "Автор: "; }
}

/* инвентаризация */
.inv input.cnt { width: 90px; min-height: 38px; padding: 6px 8px; text-align: right; }
.inv .diff { display: inline-block; min-width: 70px; text-align: left; padding-left: 6px; }
@media (max-width: 760px) {
  .inv thead { display: none; }
  .inv, .inv tbody, .inv tr, .inv td { display: block; width: 100%; }
  .inv tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .inv td { padding: 0; border: 0; text-align: left !important; }
  .inv td:nth-child(1) { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
  .inv td:nth-child(2) { grid-column: 1 / -1; font-weight: 600; }
  .inv td:nth-child(3)::before { content: "По учёту: "; color: var(--muted); font-weight: 400; }
  .inv td:nth-child(3) { align-self: center; }
  .inv td:nth-child(4) { grid-column: 2; grid-row: 3; }
}

/* справочники */
.row-form { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: end; padding: 10px 0; border-bottom: 1px solid #eef2f0; }
.row-form label { flex: 1 1 140px; margin-bottom: 0; }
.row-form label.grow { flex: 2 1 220px; }
.row-form .btn { margin-top: 8px; }
.row-form.new { border-bottom: 0; background: var(--soft); border-radius: 10px; padding: 12px; margin-top: 10px; }
.card.row-form.new { padding: 16px; }
form.mini { display: inline; margin: 0 10px 0 0; }
form.mini select { min-height: 34px; padding: 4px 8px; font-size: 14px; width: auto; }

/* карточка операции */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.card.scroll { overflow-x: auto; }
@media (max-width: 760px) { .card.scroll { padding: 8px 4px; } .card.scroll .tbl td, .card.scroll .tbl th { padding: 8px 6px; } }
