:root {
  --bg: #10141c;
  --bg-2: #171d28;
  --card: #1c2433;
  --line: #2b3648;
  --text: #e8eef7;
  --muted: #93a0b5;
  --accent: #f0b429;
  --in: #3dd68c;
  --out: #ff6b6b;
  --idle: #5d6b82;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
.app { max-width: 1400px; margin: 0 auto; padding: 12px 16px 48px; }

.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; margin-bottom: 10px; }
.brand { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.logo { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #1a1406; font-weight: 800; display: grid; place-items: center; }
h1 { margin: 0; font-size: 1rem; white-space: nowrap; }
.subtitle { display: none; }
.item-picker { display: flex; align-items: end; gap: 8px; background: transparent; border: 0; padding: 0; min-width: 0; flex: 1 1 auto; }
.item-picker label { margin: 0; min-width: 140px; }
.item-prefix { margin: 0 0 8px; white-space: nowrap; }
.status-stack { display: flex; flex-direction: row; align-items: stretch; gap: 8px; flex: 0 0 auto; }
.server-status { min-width: 150px; min-height: 0; display: grid; place-items: center; text-align: center; border-radius: 10px; padding: 8px 10px; font-weight: 800; letter-spacing: 0.02em; font-size: 0.82rem; }
.kpi-strip { display: flex; gap: 8px; }
.user-chip { flex: 0 0 auto; }
.item-search { position: relative; }
.item-combo { display: flex; }
.item-combo input { flex: 1; border-radius: 8px 0 0 8px; }
.item-combo button { width: 36px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; background: #2c3648; color: var(--text); cursor: pointer; margin-top: 6px; }
.topbar, .item-picker, .item-search { overflow: visible; }
.item-matches { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; max-height: 70vh; overflow-y: auto; background: #1c2433; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; }
.item-matches button { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); padding: 8px 10px; cursor: pointer; }
.item-matches button:hover, .item-matches button.active { background: #2a2212; color: #f0b429; }
.item-prefix { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.qty-status { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; font-weight: 700; align-items: center; }
.qty-counts { display: flex; justify-content: space-between; gap: 8px; }
.qty-progress { display: flex; align-items: center; gap: 8px; }
.qty-bar { flex: 1; height: 16px; background: #10141c; border-radius: 999px; overflow: hidden; }
.qty-bar span { display: block; height: 100%; width: 0; background: #ff6b6b; }
.qty-status.match .qty-bar span { background: #3dd68c; }
.qty-status.mismatch { background: #3a1717; color: #ffb4b4; border: 1px solid #ff6b6b; }
.qty-status.match { background: #163226; color: #b8f5d4; border: 1px solid #3dd68c; }
.status-stack { display: flex; flex-direction: column; gap: 8px; }
.server-row { display: flex; align-items: stretch; min-width: 280px; }
.server-status { flex: 2; min-height: 72px; display: grid; place-items: center; text-align: center; border-radius: 10px 0 0 10px; padding: 10px 14px; font-weight: 800; letter-spacing: 0.02em; }
.save-details { margin-top: 12px; max-height: 280px; overflow: auto; text-align: left; background: #10141c; border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; }
.aligned-row { display: grid; grid-template-columns: 18ch 1fr; gap: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.aligned-row span:first-child { white-space: pre; color: #93a0b5; }
.save-details div { margin: 4px 0; }
.save-details ol { margin: 6px 0 0; padding-left: 18px; }
.server-status.ok { background: #163226; color: #3dd68c; border: 1px solid #3dd68c; }
.server-status.bad { background: #3a1717; color: #ff6b6b; border: 1px solid #ff6b6b; }
.offline-block { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: rgba(58, 23, 23, 0.88); color: #fff; text-align: center; padding: 24px; }
.offline-block.hidden { display: none; }
.offline-block h2 { font-size: 2rem; margin: 0 0 8px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 92px; }
.kpi span { display: block; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi strong { font-size: 1.2rem; }
.kpi.accent { border-color: #5a4514; background: #2a2212; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tab.active { background: var(--card); color: var(--text); border-color: var(--line); }
.ico { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; flex: 0 0 22px; }
.ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h2 .ico { width: 20px; height: 20px; margin-right: 6px; vertical-align: -4px; }
.kpi-label { display: flex !important; align-items: center; gap: 6px; }
.kpi-label .ico { width: 16px; height: 16px; flex-basis: 16px; }
.kpi-label .ico svg { width: 16px; height: 16px; }

.panel { display: none; }
.panel.active { display: block; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.warn { border-color: #5a2a2a; }
h2 { margin: 0 0 8px; font-size: 1.05rem; }
.hint { color: var(--muted); margin: 0 0 12px; }
.floor-head { display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; padding: 4px 8px; border-radius: 999px; }
.badge.in { background: #163226; color: var(--in); }
.badge.out { background: #3a1717; color: var(--out); }

.session-form.idle .meta-grid,
.session-form.idle .qty-status,
.session-form.idle .scan-row {
  opacity: 0.55;
  filter: grayscale(0.7);
}
.session-form.idle input,
.session-form.idle button[type="submit"] {
  pointer-events: none;
  cursor: not-allowed;
  background: #121820;
  color: #6d788a;
  border-color: #2a3344;
}
.session-form.active .meta-grid input:not(:disabled) {
  background: #101820;
  border-color: #3dd68c;
  color: var(--text);
}
.btn.saving, .btn:disabled { cursor: not-allowed; opacity: 0.45; filter: grayscale(0.4); }
.email-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.email-grid label input,
.email-grid label select { width: 100%; margin-top: 6px; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; min-height: 38px; }
.meta-grid label { margin: 0; }
.session-form .meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.scan-row { display: flex; gap: 8px; }
.scan-input { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 1rem; }
.scan-input.xl { font-size: 1.35rem; padding: 16px 18px; }
.search, select, label input[type="text"], label input[type="password"], label input[type="date"], label input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  margin-top: 6px;
  font: inherit;
  min-height: 38px;
  color-scheme: dark;
}
label { display: block; margin: 0 0 12px; color: var(--muted); }
label input[type="text"] { width: 100%; margin-top: 6px; }
.btn.warn-yellow { background: #c9a227; border-color: #e0b82e; color: #1a1406; font-weight: 700; }
.btn.warn-yellow:disabled { opacity: 0.45; }
.ship-id-badge {
  display: inline-block;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #2a2212;
  border: 1px solid #5a4514;
  color: #f0b429;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.ship-row { display: flex; gap: 8px; align-items: center; }
.ship-row input { flex: 1; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 8px; font: inherit; }
.ship-row .btn { padding: 6px 10px; font-size: 0.82rem; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }

.btn { background: #2c3648; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn .ico { width: 18px; height: 18px; flex-basis: 18px; }
.btn .ico svg { width: 18px; height: 18px; }
.btn.primary { background: #1f6f4a; border-color: #2a8a5c; }
.btn.save-btn { background: #1f7a4d; border-color: #2ea36a; color: #fff; }
.btn.cancel-btn { background: #8a2a2a; border-color: #d14b4b; color: #fff; }
.btn.push-right { margin-left: auto; }
.btn.ghost { background: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.result-box { margin-top: 14px; border-radius: 12px; padding: 16px 18px; font-weight: 700; font-size: 1.05rem; background: #222a38; }
.result-box.ok { background: #163226; color: var(--in); }
.result-box.bad { background: #3a1717; color: var(--out); }
.result-box.idle { color: var(--muted); font-weight: 500; }

.stat-list { list-style: none; margin: 0; padding: 0; }
.stat-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.log-list { display: grid; gap: 6px; }
.log-list.empty { color: var(--muted); }
.log-item { display: flex; justify-content: space-between; gap: 10px; background: var(--bg-2); border-radius: 8px; padding: 8px 10px; font-size: 0.92rem; }
.log-item .ok { color: var(--in); }
.log-item .bad { color: var(--out); }

.toolbar { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar-right { display: flex; gap: 8px; }
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #223049; }
.status-in { color: var(--in); font-weight: 700; }
.status-out { color: var(--out); font-weight: 700; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin-top: 12px; }
.select-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; padding: 10px 12px; background: #1c2430; border: 1px solid var(--line); border-radius: 10px; }
.select-bar.hidden, .hidden { display: none !important; }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; }
.subtab { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.subtab.active { background: #2a2212; color: #f0b429; border-color: #5a4514; }
.batch-id { background: transparent; border: 0; color: #f0b429; font-weight: 800; cursor: pointer; padding: 0; }
.batch-serials { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.batch-serials span { background: #10141c; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }

.user-chip { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; color: var(--muted); font-size: 0.85rem; }
.load-progress { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(7, 17, 31, 0.78); }
.load-progress.hidden { display: none; }
.load-card { width: min(420px, calc(100% - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.load-track { height: 14px; background: #10141c; border-radius: 999px; overflow: hidden; }
.load-track span { display: block; height: 100%; width: 0; background: var(--in); }
#loadLabel { margin: 10px 0 0; color: var(--muted); }
.login-screen { position: fixed; inset: 0; background: #0c1018; display: grid; place-items: center; z-index: 80; padding: 16px; }
.login-screen.hidden { display: none; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.login-card .logo { margin-bottom: 12px; }
.login-card h1 { margin-bottom: 16px; }
.login-card label input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; width: 100%; margin-top: 6px; font: inherit; min-height: 38px; }
.admin-only.hidden { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(7, 17, 31, 0.72); padding: 16px; }
.modal.hidden { display: none !important; }
.modal-card { width: min(460px, 100%); background: #3a1717; border: 2px solid #ff6b6b; border-radius: 16px; padding: 22px 22px 18px; color: #ffe8e8; box-shadow: var(--shadow); }
.modal-kicker { margin: 0 0 6px; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: #ffb4b4; }
.modal-card h2 { margin: 0 0 10px; font-size: 1.35rem; color: #fff; }
.modal-body { margin: 0 0 14px; font-size: 1.05rem; white-space: pre-wrap; }
.modal-hint { margin: 0; color: #ffc9c9; font-size: 0.88rem; }

@media (max-width: 700px) {
  .scan-row { flex-direction: column; }
  .kpi { min-width: 72px; }
}
