html, body { margin: 0; min-height: 100%; background: #0f1115; color: #e8ecf1; font-family: system-ui, sans-serif; }
* { box-sizing: border-box; }
#app { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 0 0 12px; font-size: 1.2rem; }
h3 { margin: 0 0 10px; font-size: 1rem; }
.muted { color: #8b95a5; }
p.muted { margin: 4px 0 0; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.fx-btn.sm { padding: 4px 10px; font-size: .8rem; }

.lookup { display: flex; gap: 8px; margin-bottom: 12px; }
.lookup .fx-input { flex: 1; }
.scan-result:empty { display: none; }
.scan-card { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 16px; margin-bottom: 14px; border-left: 4px solid #5b9dff; }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.qty-input { width: 80px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; }
.stat-val { font-size: 1.6rem; font-weight: 700; }
.stat-lbl { color: #8b95a5; font-size: .85rem; }
.stat.warn .stat-val { color: #f5b942; }
.stat.bad .stat-val { color: #ff6b6b; }

.banner { display: flex; gap: 12px; align-items: center; background: #3a2e12; border: 1px solid #6b5316; color: #f5d27a; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.link { background: none; border: 0; color: #7db4ff; cursor: pointer; text-decoration: underline; font: inherit; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid #262b35; margin-bottom: 14px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: #8b95a5; padding: 10px 14px; cursor: pointer; font: inherit; white-space: nowrap; }
.tab.active { color: #e8ecf1; border-bottom-color: #5b9dff; }
.count { margin-left: 6px; background: #ff6b6b; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: .75rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; }
.result-count { margin: 0 0 8px; font-size: .85rem; }

.table-wrap { overflow-x: auto; padding: 0; }
.fx-table { width: 100%; border-collapse: collapse; }
.fx-table th, .fx-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #1f242d; white-space: nowrap; }
.fx-table th.num, .fx-table td.num { text-align: right; }
.strong { font-weight: 600; }
.pos { color: #5fd38d; }
.neg { color: #ff8585; }
.th-btn { background: none; border: 0; color: inherit; font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.fx-badge.st-ok { background: #16361f; color: #5fd38d; }
.fx-badge.st-low { background: #3a2e12; color: #f5b942; }
.fx-badge.st-out { background: #3d1a1a; color: #ff6b6b; }
.fx-badge.mv-in { background: #16361f; color: #5fd38d; }
.fx-badge.mv-out { background: #3d1a1a; color: #ff8585; }
.fx-badge.mv-adjust { background: #1d2b46; color: #7db4ff; }

.alert-title { font-weight: 600; margin-bottom: 4px; }
.po-bar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 14px 16px; margin-bottom: 12px; }
.po-group { padding: 12px 0 0; margin-bottom: 12px; overflow: hidden; }
.po-head { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 0 16px 8px; }
.po-head h3 { margin: 0; }

.take-sum { padding: 10px 14px; margin-bottom: 12px; color: #aab3c2; }
.count-input { width: 90px; text-align: right; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.chart { padding: 16px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 80px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #1a1f28; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-val { text-align: right; font-weight: 600; }

.empty { text-align: center; padding: 36px 16px; color: #8b95a5; }

.foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 20px; }
.hint { margin-left: auto; font-size: .8rem; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.modal { width: 100%; max-width: 540px; max-height: 92vh; overflow-y: auto; padding: 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .85rem; color: #aab3c2; margin-bottom: 4px; }
.field .fx-input { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fx-input.invalid { border-color: #ff6b6b; }
.err { color: #ff8585; font-size: .8rem; min-height: 1em; margin-top: 3px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#print-root { display: none; }

@media (max-width: 600px) {
  #app { padding: 16px 10px 40px; }
  .hint { margin-left: 0; width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 70px; }
  .lookup { flex-wrap: wrap; }
}

@media print {
  html, body { background: #fff; color: #000; }
  #app, .modal-overlay { display: none !important; }
  #print-root { display: block; padding: 0; font-family: system-ui, sans-serif; }
  #print-root h1 { font-size: 20pt; }
  #print-root h2 { font-size: 13pt; margin-top: 18px; }
  .print-table { width: 100%; border-collapse: collapse; font-size: 10pt; margin-bottom: 8px; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
  .print-table th.num, .print-table td.num { text-align: right; }
  .print-table thead { background: #eee; }
  .print-table tr { break-inside: avoid; }
}
