/* Оформление повторяет табель АРКО (tabel.ar-ko.ru) и реестр имущества (sklad.ar-ko.ru):
   белый фон, меню слева с чёрным активным пунктом, красный акцент #da3329, шрифт Inter/системный.
   Отличие от табеля: лист закупок оставлен плотным (много строк и столбцов на экране). */
:root {
  --bg: #ffffff; --bg-soft: #f6f6f6; --bg3: #ececec; --text: #111111; --muted: #6b6b6b; --border: #d9dada;
  --accent: #da3329; --accent-soft: #eea39e; --accent-tint: #fdeceb;
  --ink: #000000; --on-ink: #ffffff;
  --ok: #1f8a4c; --ok-tint: #e6f4ec; --warn: #b26a00; --warn-tint: #fff3dc;
  --shadow: 0 10px 40px rgba(0, 0, 0, .18);
  --side-w: 252px;
  /* старые имена, на которые ссылается разметка */
  --bg2: var(--bg-soft); --line: var(--border); --primary: var(--ink); --primary-text: var(--on-ink);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131313; --bg-soft: #1c1c1c; --bg3: #262626; --text: #f2f2f2; --muted: #9a9a9a; --border: #333;
    --accent: #ef4a3f; --accent-soft: #6b2f2b; --accent-tint: #2b1a19; --ink: #f2f2f2; --on-ink: #111;
    --ok: #4cc47f; --ok-tint: #17281f; --warn: #f0b04a; --warn-tint: #2d2414;
    --shadow: 0 10px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131313; --bg-soft: #1c1c1c; --bg3: #262626; --text: #f2f2f2; --muted: #9a9a9a; --border: #333;
  --accent: #ef4a3f; --accent-soft: #6b2f2b; --accent-tint: #2b1a19; --ink: #f2f2f2; --on-ink: #111;
  --ok: #4cc47f; --ok-tint: #17281f; --warn: #f0b04a; --warn-tint: #2d2414;
  --shadow: 0 10px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 34px; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- каркас: меню слева ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: var(--side-w); flex: none; border-right: 1px solid var(--border); background: var(--bg);
  display: flex; flex-direction: column; padding: 22px 10px 14px; position: sticky; top: 0;
  height: 100vh; height: 100dvh; overflow-y: auto;
}
.brand { display: block; padding: 0 8px 4px; }
.brand img { display: block; height: 56px; width: auto; }
.brand-title { margin: 14px 8px 20px; display: flex; flex-direction: column; gap: 2px; }
.brand-title b { font-size: 24px; letter-spacing: -.02em; }
.brand-title span { font-size: 14px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 8px; text-decoration: none; font-size: 17px; color: var(--text); }
.nav a svg, .tabbar svg { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.nav a:hover { background: var(--bg-soft); }
.nav a.active { background: var(--ink); color: var(--on-ink); }
.nav a.active svg { opacity: 1; }
.side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.side-foot .who { line-height: 1.35; margin-bottom: 10px; color: var(--text); }
.side-foot a, .side-foot button { display: block; background: none; border: 0; padding: 6px 0; color: var(--muted); text-align: left; text-decoration: none; font-size: 14px; }
.side-foot a:hover, .side-foot button:hover { color: var(--text); }
.side-foot .org { margin-top: 12px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.logo-img { display: block; }
:root[data-theme="dark"] .logo-img { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-img { filter: invert(1); } }

.main { flex: 1; min-width: 0; padding: 34px 44px 60px; }
.main > .row:first-child { margin-bottom: 22px; }
.page.wide { padding: 22px 28px 0; }
.page.wide > .row:first-child { margin-bottom: 10px; }
.page.wide h1 { font-size: 28px; }
.main a.muted.small { color: var(--muted); text-decoration: none; font-size: 16px; margin-right: 6px; }
.main a.muted.small:hover { color: var(--text); }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 16px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg-soft); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(.94); background: var(--accent); }
.btn.primary:disabled { background: var(--accent-soft); border-color: var(--accent-soft); filter: none; opacity: 1; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.link { border: none; background: none; height: auto; padding: 2px 0; color: var(--accent); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 0 14px; height: 44px; min-width: 0; font-size: 16px; outline: none;
}
textarea { height: auto; padding: 10px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 12%, transparent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input::placeholder { color: var(--muted); opacity: .8; }
input:disabled, select:disabled { background: var(--bg-soft); color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; vertical-align: middle; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
label.field input, label.field select, label.field textarea { width: 100%; height: 52px; font-size: 18px; }
label.field textarea { height: auto; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.err { color: var(--accent); font-size: 15px; margin: 6px 0; min-height: 20px; }

/* ---------- карточки ---------- */
.card { border: 1px solid var(--border); border-radius: 14px; padding: 20px; background: var(--bg); }
.card h2 { margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 18px; }
.pcard { display: block; text-decoration: none; }
.pcard:hover { border-color: var(--ink); }
.tag { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px; background: var(--bg-soft); color: var(--muted); font-size: 13px; font-weight: 600; margin-left: 8px; vertical-align: middle; letter-spacing: 0; }

/* ---------- вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.login-logo { height: 84px; width: auto; align-self: flex-start; }
.login-card h1 { font-size: 30px; }
.login-card .btn.primary { height: 52px; font-size: 18px; border-radius: 10px; }
.center-card { max-width: 440px; margin: 10vh auto; }

/* ---------- вкладки объекта ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 14px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; text-decoration: none; font-weight: 600; font-size: 15px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; margin-left: 4px; font-weight: 700; }

/* ---------- сводка и панель над листом ---------- */
.summary { background: var(--bg-soft); border-radius: 12px; padding: 12px 18px; display: flex; gap: 28px; flex-wrap: wrap; font-size: 14px; align-items: center; color: var(--muted); }
.summary b { color: var(--text); font-size: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.toolbar input, .toolbar select { height: 40px; font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 99px; padding: 6px 14px; background: var(--bg); cursor: pointer; font-size: 14px; }
.chip:hover { background: var(--bg-soft); }
.chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------- лист закупок (плотный) ---------- */
.sheet-wrap { overflow: auto; height: calc(100vh - 250px); min-height: 320px; border: 1px solid var(--border); border-radius: 12px; }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 14px; }
.sheet th, .sheet td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 5px 8px; background: var(--bg); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet thead th { position: sticky; top: 0; z-index: 5; background: var(--bg-soft); font-weight: 600; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; text-align: left; white-space: normal; vertical-align: bottom; padding: 8px 12px 8px 8px; }
.sheet .hl { display: block; cursor: grab; user-select: none; }
.sheet .rz { position: absolute; top: 0; right: 0; bottom: 0; width: 7px; cursor: col-resize; }
.sheet .rz:hover { background: var(--muted); opacity: .5; }
.sheet th.dropmark { box-shadow: inset 3px 0 0 var(--accent); }
.sheet .s1, .sheet .s2, .sheet .s3 { position: sticky; z-index: 3; }
.sheet thead .s1, .sheet thead .s2, .sheet thead .s3 { z-index: 8; }
.sheet .s1 { left: 0; }
.sheet .s2 { left: 34px; text-align: right; color: var(--muted); }
.sheet .s3 { left: 76px; border-right: 2px solid var(--ink); }
.sheet td.wrap { white-space: normal; }
.sheet tbody tr:hover td { background: var(--bg-soft); }
.sheet .name { white-space: normal; line-height: 1.3; }
.sheet tr.group td { background: var(--bg3); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; position: sticky; left: 0; overflow: visible; }
.sheet tr.group .gt { position: sticky; left: 10px; display: inline-flex; gap: 12px; align-items: center; }
.sheet input[type=text], .sheet input[type=number], .sheet input[type=date], .sheet select { width: 100%; height: 30px; padding: 0 6px; font-size: 14px; border-color: transparent; background: transparent; border-radius: 6px; }
.sheet select { padding-right: 2px; }
.sheet input:hover, .sheet select:hover { border-color: var(--border); }
.sheet input:focus, .sheet select:focus { background: var(--bg); border-color: var(--ink); box-shadow: none; }
.sheet td.s3 { padding-right: 38px; }
.sheet .rm-btn { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1; padding: 0; opacity: 0; }
.sheet tr:hover .rm-btn, .sheet .rm-btn:focus-visible { opacity: 1; }
.sheet .rm-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-tint); }
@media (hover: none) { .sheet .rm-btn { opacity: .6; } }
.sheet .small { font-size: 12px; line-height: 1.3; }
.sheet .btn.small { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.pos { color: var(--ok); } .neg { color: var(--accent); }
.state-lbl { font-size: 13px; color: var(--muted); }

/* ---------- очередь ---------- */
.qcard { margin-bottom: 14px; }
.qcols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 12px 0; }
.qbox { background: var(--bg-soft); border-radius: 10px; padding: 12px 14px; }
.qbox h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; letter-spacing: .04em; }

/* ---------- простые таблицы ---------- */
table.plain { border-collapse: collapse; width: 100%; font-size: 15px; }
.plain th, .plain td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.plain th { background: var(--bg-soft); font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.plain tr:last-child td { border-bottom: 0; }
.plain .num { text-align: right; }

/* ---------- шаги (как «1 КУДА / 2 ЧТО» в табеле) ---------- */
.steps { display: grid; gap: 16px; }
.step { display: grid; grid-template-columns: 40px 1fr; gap: 14px; }
.step .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.step.done .n { background: var(--ok); }
.note { background: var(--warn-tint); color: var(--warn); padding: 12px 16px; border-radius: 10px; font-size: 15px; margin: 10px 0; }

/* ---------- окна и уведомления ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 22px 24px; }
.modal.wide { max-width: 760px; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--on-ink); padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200; max-width: 92vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--accent); color: #fff; }
.hist ul { padding: 0; margin: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--border); list-style: none; }
.kbd { font-family: ui-monospace, Consolas, monospace; background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; word-break: break-all; }

/* ---------- телефон: меню выезжает, снизу панель вкладок ---------- */
.tabbar { display: none; }
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-102%); visibility: hidden; transition: transform .2s, visibility .2s; }
  body.menu-open .side { transform: none; visibility: visible; box-shadow: var(--shadow); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 55; }
  .main, .page.wide { padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: 28px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--bg); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)); }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 11px; border-radius: 8px; }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar .active { color: var(--accent); font-weight: 700; }
  .sheet-wrap { height: calc(100vh - 300px); }
  .grid { grid-template-columns: 1fr; }
  .qcols { grid-template-columns: 1fr; }
}
@media print { .side, .tabbar, .toolbar { display: none !important; } .main { padding: 0; } }
