/* Wideformat Inventory — enterprise UI
   Neutral warm greys, a single deep-teal accent, dense but readable tables. */

:root {
  --bg: #f5f4f2;
  --surface: #ffffff;
  --surface-2: #faf9f8;
  --border: #e4e1dd;
  --border-strong: #cdc9c4;
  --text: #161513;
  --text-2: #4f4c48;
  --text-3: #75716b;
  --brand: #312d2a;
  --brand-2: #3a3632;
  --accent: #00688c;
  --accent-hover: #005573;
  --accent-soft: #e6f1f5;
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --warn: #a35a00;
  --warn-soft: #fdf2e2;
  --ok: #2e7d32;
  --ok-soft: #e9f4ea;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(22, 21, 19, 0.06), 0 1px 1px rgba(22, 21, 19, 0.04);
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand small { font-weight: 400; color: #c9c4be; font-size: 12px; margin-left: 2px; }
.nav { display: flex; gap: 2px; height: 100%; flex: 1; }
.nav a {
  color: #d9d5d0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 3px solid transparent;
  border-top: 3px solid transparent;
  font-size: 13.5px;
}
.nav a:hover { color: #fff; text-decoration: none; background: var(--brand-2); }
.nav a.active { color: #fff; border-bottom-color: #6fc3df; }
.nav .count { background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 6px; line-height: 17px; }
.usermenu { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #d9d5d0; white-space: nowrap; }
.usermenu a { color: #d9d5d0; }
.usermenu .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #5b5652; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px;
}
.usermenu form { margin: 0; }
.linkbtn { background: none; border: 0; color: #d9d5d0; cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { color: #fff; text-decoration: underline; }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }

/* ---------- Page ---------- */
main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 24px 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.breadcrumb { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head p { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--border-strong); color: inherit;
}
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-3); }
.kpi.danger { border-top-color: var(--danger); }
.kpi.danger .value { color: var(--danger); }
.kpi.warn { border-top-color: #e08a00; }
.kpi.warn .value { color: var(--warn); }
.kpi.accent { border-top-color: var(--accent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: #fbfaf9; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
table.data tr.row-out td:first-child, table.data tr.row-below td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
table.data tr.row-low td:first-child { box-shadow: inset 3px 0 0 #e08a00; }
table.data tr.row-roll-low { background: #fdf5f4; }
table.data tr.row-roll-low:hover { background: #fbeceb; }
table.data tr.row-roll-low td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.len-low { color: var(--danger) !important; }
table.data .check { width: 1%; }
.empty { padding: 36px 18px; text-align: center; color: var(--text-3); }
.qty-strong { font-weight: 600; }
.bar { height: 6px; background: #ece9e5; border-radius: 3px; overflow: hidden; width: 90px; display: inline-block; vertical-align: middle; margin-left: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.low > span { background: #e08a00; }
.bar.crit > span { background: var(--danger); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.low { color: var(--warn); background: var(--warn-soft); }
.badge.below, .badge.out { color: var(--danger); background: var(--danger-soft); }
.badge.neutral { color: var(--text-2); background: #efedea; }
.badge.neutral::before { display: none; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 3px; background: #efedea; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }
.tag.scan { background: var(--accent-soft); color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f1efec; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #e3b5b2; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 48px; font-size: 16px; padding: 0 20px; }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.icon-btn { background: none; border: 0; padding: 4px 6px; color: var(--accent); cursor: pointer; font: 600 12.5px var(--font); }
.icon-btn:hover { text-decoration: underline; }
.icon-btn.danger { color: var(--danger); }
form.inline { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.form { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .label-text { display: block; font-weight: 600; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.req::after { content: " *"; color: var(--danger); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], input[type=url], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 4px;
  font: 14px var(--font); color: var(--text); background: #fff;
}
textarea { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input-suffix { display: flex; }
.input-suffix input { border-radius: 4px 0 0 4px; }
.input-suffix span { border: 1px solid var(--border-strong); border-left: 0; padding: 0 10px; display: flex; align-items: center; background: var(--surface-2); border-radius: 0 4px 4px 0; color: var(--text-3); }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form-actions { display: flex; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 280px; }
.toolbar select, .toolbar input[type=date] { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--text-2); font-size: 12.5px; border-right: 1px solid var(--border-strong); font-weight: 600; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--brand); color: #fff; }
.seg a:hover { text-decoration: none; background: #f1efec; }
.seg a.on:hover { background: var(--brand); }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; border: 1px solid; border-left-width: 4px; font-size: 13.5px; }
.alert.success { background: var(--ok-soft); border-color: #b7d9b9; border-left-color: var(--ok); }
.alert.error { background: var(--danger-soft); border-color: #eec2bf; border-left-color: var(--danger); }
.alert.info { background: var(--accent-soft); border-color: #b9d7e2; border-left-color: var(--accent); }
.alert.warn { background: var(--warn-soft); border-color: #f0d3a8; border-left-color: #e08a00; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Tabs (settings) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; color: var(--text-2); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Definition list ---------- */
dl.props { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--text-3); font-size: 12.5px; }
dl.props dd { margin: 0; font-weight: 500; }
.qr-box { text-align: center; }
.qr-box img { width: 180px; height: 180px; image-rendering: pixelated; border: 1px solid var(--border); padding: 6px; background: #fff; }
.qr-box .url { word-break: break-all; font-size: 12px; margin-top: 8px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border); background: var(--surface); color: var(--text-3);
  font-size: 12px; padding: 14px 24px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer .cits { display: flex; align-items: center; gap: 8px; }
.footer .cits strong { color: var(--text-2); }
.footer .cits img { width: 18px; height: 18px; }
.footer .contacts { display: flex; gap: 14px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.auth-page { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-side {
  background: linear-gradient(160deg, #312d2a 0%, #3f3833 55%, #1f4f60 100%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side h1 { font-size: 30px; font-weight: 600; margin-top: 40px; max-width: 420px; line-height: 1.25; }
.auth-side p { color: #d9d5d0; max-width: 420px; }
.auth-side ul { padding: 0; list-style: none; color: #e9e6e2; }
.auth-side li { padding: 6px 0 6px 22px; position: relative; }
.auth-side li::before { content: ""; position: absolute; left: 0; top: 13px; width: 10px; height: 2px; background: #6fc3df; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; background: var(--surface); }
.auth-box { width: 100%; max-width: 360px; }
.auth-box h2 { font-size: 22px; margin-bottom: 4px; }
.auth-box .field { margin-bottom: 14px; }
.cits-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #c9c4be; }
.cits-badge img { width: 22px; height: 22px; }

/* ---------- Scan (mobile) pages ---------- */
body.scan { background: #ecebe8; }
.scan-top { background: var(--brand); color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scan-top .brand { font-size: 14px; }
.scan-wrap { max-width: 520px; margin: 0 auto; padding: 16px; flex: 1; width: 100%; }
.scan-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 14px; }
.scan-item .code { font-family: var(--mono); color: var(--text-3); font-size: 13px; }
.scan-item h1 { font-size: 21px; margin: 2px 0 0; }
.big-number { text-align: center; padding: 18px 0 8px; }
.big-number .n { font-size: 56px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big-number .u { font-size: 20px; color: var(--text-3); margin-left: 4px; }
.big-number .cap { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.scan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 14px; }
.scan-card h2 { margin-bottom: 12px; }
.scan-card input[type=text], .scan-card input[type=password], .scan-card input[inputmode] { height: 50px; font-size: 20px; }
.pin-input { text-align: center; letter-spacing: 0.4em; font-size: 26px !important; }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: flex; align-items: center; justify-content: center; height: 48px; border: 1px solid var(--border-strong);
  border-radius: 6px; font-weight: 600; cursor: pointer; background: #fff; font-size: 15px;
}
.choice input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); }
.operator { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.stepper { display: flex; gap: 8px; }
.stepper button { width: 56px; flex: none; font-size: 22px; }
.recent { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.recent li:last-child { border-bottom: 0; }
.done-banner { background: var(--ok-soft); border: 1px solid #b7d9b9; color: #1d5a20; border-radius: 8px; padding: 14px; margin-bottom: 14px; font-weight: 600; text-align: center; }
.scan-foot { text-align: center; font-size: 12px; color: var(--text-3); padding: 18px 16px 24px; }
.scan-foot img { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-toggle { display: block; }
  .topbar { flex-wrap: wrap; height: auto; min-height: 52px; padding: 8px 16px; gap: 8px; }
  .brand { flex: 1; }
  .nav, .usermenu { display: none; width: 100%; }
  .topbar.open .nav { display: flex; flex-direction: column; }
  .topbar.open .usermenu { display: flex; padding: 8px 12px 12px; }
  .nav a { padding: 10px 12px; border: 0; }
  .nav a.active { border-left: 3px solid #6fc3df; }
  main { padding: 16px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .toolbar input[type=search] { width: 100%; }
  dl.props { grid-template-columns: 120px 1fr; }
}

@media print {
  .topbar, .footer, .actions, .toolbar, .actions-cell { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
