/* Тема «Я-Картон»: тёмно-синяя шапка + светлое содержимое
   --navy   #1B1930  шапка
   --bg     #F4F5F9  фон страницы
   --card   #FFFFFF  карточки
   --line   #E1E3EE  границы
   --text   #2B2A3C  текст (тёмно-синие чернила)
   --muted  #6C6A85  вторичный текст
   --orange #E8A85A  фирменный оранжевый (акцент)
   --green  #1F7A4D  приход
   --red    #C0392B  расход */
:root {
  --navy: #1B1930;
  --navy2: #2C2A43;
  --bg: #F4F5F9;
  --card: #FFFFFF;
  --field: #FAFAFD;
  --line: #E1E3EE;
  --text: #2B2A3C;
  --muted: #6C6A85;
  --orange: #E8A85A;
  --orange-dark: #C8883C;
  --green: #1F7A4D;
  --green-bg: #E1F2E8;
  --red: #C0392B;
  --red-bg: #FBE5E2;
  --radius: 8px;
  font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- шапка (тёмно-синяя) ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 22px;
  background: var(--navy);
  border-bottom: 3px solid var(--orange);
  color: #ECEAF6;
}
.brand { display: flex; align-items: center; gap: 16px; }
.logoplate {
  background: #fff; border-radius: 10px; padding: 5px 12px;
  display: flex; align-items: center;
}
.logo { height: 46px; width: auto; display: block; }
.topbar h1 { margin: 0; font-size: 1.3rem; letter-spacing: .01em; font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 8px; }
.userbox label { font-size: .8rem; color: #A5A1C2; }
.userbox input {
  width: 160px; padding: 7px 10px; border: 1px solid #403D5E;
  border-radius: var(--radius); background: var(--navy2); color: #ECEAF6; font: inherit;
}
.userbox input::placeholder { color: #757195; }
.sync { color: #4CAF7D; font-size: 1.1rem; transition: color .3s; }
.sync.off { color: #E06056; }

/* ---------- вкладки подразделений ---------- */
.tabs { display: flex; gap: 6px; padding: 14px 22px 0; max-width: 1284px; margin: 0 auto; }
.tab {
  padding: 9px 24px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #E9EAF2; color: var(--muted);
}
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 1px;
}

/* ---------- вкладки разделов ---------- */
.subtabs { display: flex; gap: 6px; padding: 12px 22px 0; flex-wrap: wrap; max-width: 1284px; margin: 0 auto; }
.subtab {
  padding: 7px 18px; font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--muted);
}
.subtab:hover { color: var(--text); border-color: var(--orange); }
.subtab.active { background: var(--orange); color: var(--navy); border-color: var(--orange); font-weight: 600; }

/* ---------- карточки ---------- */
main { padding: 0 22px 40px; max-width: 1284px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-top: 18px;
  box-shadow: 0 1px 3px rgba(43,42,60,.06);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card h2 { margin: 0; font-size: 1.05rem; }
h4 { margin: 18px 0 8px; font-size: .95rem; }

/* ---------- форма ---------- */
.grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; position: relative; }
.field.wide { grid-column: span 4; }
.field.small { grid-column: span 1; }
.field label { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; background: var(--field); color: var(--text);
}
.field input::placeholder { color: #A9A7BE; }
.withbtn { display: flex; gap: 6px; }
.withbtn select { flex: 1; min-width: 0; }
.mini {
  width: 34px; border: none; background: var(--orange); color: var(--navy);
  border-radius: var(--radius); font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.mini:hover { background: var(--orange-dark); }
.formfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 12px; flex-wrap: wrap; }
.hint { font-size: .85rem; color: var(--muted); }
button.primary, #importFile {
  padding: 10px 22px; font: inherit; font-weight: 600; cursor: pointer;
  border: none; border-radius: var(--radius); background: var(--navy); color: #fff;
}
button.primary:hover, #importFile:hover { background: var(--navy2); }
button.primary.sm { padding: 6px 14px; font-size: .85rem; }
button:disabled { opacity: .6; cursor: wait; }
#txForm.mode-in .primary { background: var(--green); }
#txForm.mode-in .primary:hover { background: #186340; }
#txForm.mode-out .primary { background: var(--red); }
#txForm.mode-out .primary:hover { background: #A32F23; }
.msg { margin: 10px 0 0; padding: 8px 12px; border-radius: var(--radius); font-size: .9rem; }
.msg.ok { background: var(--green-bg); color: var(--green); }
.msg.err { background: var(--red-bg); color: var(--red); }

/* выпадающий список подсказок */
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--orange);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 300px; overflow-y: auto; box-shadow: 0 10px 24px rgba(43,42,60,.18);
}
.suggest .opt { padding: 6px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.suggest .opt:hover, .suggest .opt.sel { background: #FBF2E4; }
.suggest .opt .nm { flex: 1; }
.suggest .opt .art { font-family: "IBM Plex Mono", monospace; font-size: .82rem; color: var(--muted); }
.suggest .opt .bal { font-size: .82rem; color: var(--green); white-space: nowrap; }

/* ---------- таблицы ---------- */
.filter {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; width: 280px; max-width: 100%; background: var(--field); color: var(--text);
}
.filter::placeholder { color: #A9A7BE; }
.filter.short { width: auto; }
.rowtools { display: flex; gap: 8px; flex-wrap: wrap; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 180px; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-bottom: 2px solid var(--orange); }
#stockTable tbody tr { cursor: pointer; }
#stockTable tbody tr:hover td, .cardlog tbody tr:hover td { background: #F7F2E8; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.art { font-family: "IBM Plex Mono", monospace; font-size: .84rem; color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge.in  { background: var(--green-bg); color: var(--green); }
.badge.out { background: var(--red-bg); color: var(--red); }
.zero { color: #B4B2C6; }
.low { color: var(--red); font-weight: 600; }
td.pos { color: var(--green); font-weight: 600; }
td.neg { color: var(--red); font-weight: 600; }
.del { border: none; background: none; color: #B4B2C6; cursor: pointer; font-size: 1rem; }
.del:hover { color: var(--red); }

/* ---------- фото ---------- */
.thumb {
  width: 42px; height: 42px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); display: inline-block; vertical-align: middle;
  background: var(--field); flex: none;
}
.thumb.none { position: relative; }
.thumb.none::after { content: "—"; position: absolute; inset: 0; display: grid; place-items: center; color: #B4B2C6; }
.thumbwrap { position: relative; display: inline-block; }
.pcount {
  position: absolute; right: -5px; bottom: -5px;
  background: var(--orange); color: var(--navy); font-size: .68rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px; line-height: 1.2;
}
.photoBtn { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 4px 8px; cursor: pointer; font-size: 1rem; }
.photoBtn:hover { background: var(--orange); }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(27,25,48,.88);
  display: grid; place-items: center; cursor: zoom-out; padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 12px 48px rgba(0,0,0,.5); }

/* ---------- карточка товара ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(27,25,48,.55);
  display: grid; place-items: center; padding: 18px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  width: min(860px, 100%); max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(27,25,48,.35);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 2px solid var(--orange);
  background: var(--navy); color: #fff; border-radius: 12px 12px 0 0;
}
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.close { border: none; background: none; color: #A5A1C2; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.close:hover { color: #E06056; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.cardinfo { display: flex; flex-wrap: wrap; gap: 6px 26px; font-size: .92rem; }
.cardinfo .kv b { color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; display: block; }
.cardinfo .big { font-size: 1.25rem; font-weight: 700; color: var(--orange-dark); }
.gallery-head { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.gallery-head h4 { margin: 0; }
.gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.gallery .ph { position: relative; }
.gallery img {
  width: 128px; height: 128px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); cursor: zoom-in; display: block;
}
.gallery .rm {
  position: absolute; top: 4px; right: 4px;
  border: none; border-radius: 999px; width: 24px; height: 24px;
  background: rgba(27,25,48,.8); color: #F0A29B; cursor: pointer; font-size: .85rem;
}
.gallery .rm:hover { background: var(--red); color: #fff; }
.gallery .empty { color: #B4B2C6; font-size: .9rem; padding: 8px 0; }
.cardlog th, .cardlog td { padding: 5px 8px; font-size: .85rem; }

/* ---------- снятие остатков ---------- */
.takeInput {
  width: 100px; padding: 6px 8px; text-align: right; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--field); color: var(--text);
}
.takeInput:focus { border-color: var(--orange); }

/* ---------- импорт ---------- */
.note { font-size: .88rem; color: var(--muted); line-height: 1.55; }
.note b { color: var(--text); }
.importrow { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.importrow .lbl { align-self: center; font-size: .88rem; color: var(--muted); }
#gsUrl {
  flex: 1; min-width: 260px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); font: inherit; background: var(--field); color: var(--text);
}
#gsUrl::placeholder { color: #A9A7BE; }
.importrow button { padding: 9px 18px; font: inherit; font-weight: 600; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); cursor: pointer; }
.importrow button:hover { border-color: var(--orange); }
.importrow button.primary { background: var(--navy); color: #fff; border: none; }
input[type="file"] { font: inherit; font-size: .88rem; color: var(--muted); }
input[type="file"]::file-selector-button {
  padding: 6px 12px; margin-right: 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--orange); }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .field, .field.wide { grid-column: span 4; }
  .field.small { grid-column: span 2; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .logo { height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- индикация активности и прогресс загрузки ---------- */
.netbar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300;
  overflow: hidden; pointer-events: none;
}
.netbar[hidden] { display: none; }
.netbar div {
  height: 100%; width: 30%; background: var(--orange);
  border-radius: 3px; animation: netslide 1s linear infinite;
}
@keyframes netslide {
  from { transform: translateX(-110%); }
  to   { transform: translateX(430%); }
}
.upbar {
  position: relative; height: 24px; background: var(--field);
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  margin-top: 10px; max-width: 420px;
}
.upbar[hidden] { display: none; }
.upfill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0%;
  background: var(--green); transition: width .15s ease;
}
.uptext {
  position: relative; display: block; text-align: center;
  font-size: .78rem; line-height: 24px; color: var(--text); font-weight: 500;
}
@media (prefers-reduced-motion: reduce) {
  .netbar div { animation: none; width: 100%; }
}

/* ---------- админ ---------- */
.linkbtn {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font: inherit; text-decoration: underline;
}
.linkbtn:hover { color: var(--red); }
#bkNow, #pwSave {
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); margin-right: 8px;
}
#bkNow:hover, #pwSave:hover { border-color: var(--orange); }
#adminPass, #pwOld, #pwNew {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; background: var(--field); color: var(--text); min-width: 200px;
}

/* ---------- экран блокировки по сроку ---------- */
.lockscreen {
  position: fixed; inset: 0; z-index: 500; background: var(--navy);
  display: grid; place-items: center; padding: 24px; text-align: center;
}
.lockscreen[hidden] { display: none; }
.lockbox { max-width: 440px; color: #ECEAF6; }
.lockbox .locklogo { width: 84px; height: 84px; object-fit: contain; opacity: .85; margin-bottom: 12px; }
.lockbox h2 { margin: 0 0 10px; font-size: 1.5rem; }
.lockbox p { color: #A5A1C2; }
.lockbox .note { margin-top: 8px; }
#licClear { padding: 8px 16px; font: inherit; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); cursor: pointer; }
#licClear:hover { border-color: var(--red); color: var(--red); }

/* ---------- съёмка камерой и превью ---------- */
.photobtns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.photoact {
  padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); white-space: nowrap;
}
.photoact:hover { border-color: var(--orange); background: #FDF6EC; }
#fCamBtn, #cardCamBtn { border-color: var(--orange); }
.preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.preview .pv { position: relative; }
.preview img {
  width: 74px; height: 74px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); display: block;
}
.preview .pvrm {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border: none; border-radius: 999px; background: var(--red); color: #fff;
  cursor: pointer; font-size: .8rem; line-height: 22px; padding: 0;
}
.camrow { display: flex; gap: 6px; }
