/* WMS — Sonance brand */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #e3e6ea;
  --text: #1a1f24;
  --text-muted: #6b7680;
  --primary: #00a3e1;
  --primary-hover: #0093cb;
  --danger: #ef5350;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.03);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08);
  --r: 10px;
  --r-sm: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Montserrat', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1f24 0%, #2d3640 100%);
}
.login-card {
  background: var(--surface); border-radius: 16px; padding: 36px; width: min(380px, 92vw);
  box-shadow: var(--shadow-lg);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.login-card p { color: var(--text-muted); margin: 0 0 28px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,163,225,.12); }
.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 12px 16px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 14px; cursor: pointer; width: 100%;
  font-family: inherit; transition: background .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* Shell */
.shell { display: none; flex-direction: column; min-height: 100vh; }
.shell.show { display: flex; }
header.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px;
  display: flex; align-items: center; height: 56px; gap: 24px; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--primary);
  color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: none; border: none; padding: 8px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-radius: var(--r-sm); font-family: inherit;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); }
.tab-disabled { opacity: .4; cursor: not-allowed; }
.user-area { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; }
.user-area button {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 12px; font-family: inherit;
}
.user-area button:hover { background: var(--surface-2); color: var(--text); }

main.content { flex: 1; padding: 20px 24px; overflow: auto; }
.panel { display: none; }
.panel.active { display: block; }

/* Locations panel */
.toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar h2 { margin: 0; font-size: 18px; font-weight: 600; }
.unit-tabs { display: flex; gap: 4px; background: var(--surface); border-radius: var(--r-sm); padding: 4px; border: 1px solid var(--border); }
.unit-tab { background: none; border: none; padding: 6px 12px; font-size: 13px; cursor: pointer;
  border-radius: 4px; color: var(--text-muted); font-family: inherit; font-weight: 500; }
.unit-tab.active { background: var(--primary); color: #fff; }
.spacer { flex: 1; }
.stats { font-size: 12px; color: var(--text-muted); }
.stats b { color: var(--text); font-weight: 600; }

.btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px;
  font-family: inherit; font-weight: 500; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: #cdd3da; }
.btn-danger { color: var(--danger); border-color: rgba(239,83,80,.3); }
.btn-danger:hover { background: rgba(239,83,80,.08); border-color: var(--danger); }
.btn-print { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-print:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* Grid */
.grid-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px; overflow: auto; max-height: calc(100vh - 200px); box-shadow: var(--shadow);
}
table.grid { border-collapse: separate; border-spacing: 0; font-size: 10px;
  font-family: 'JetBrains Mono', Menlo, monospace; }
table.grid th, table.grid td {
  border: 1px solid var(--border); padding: 0; min-width: 32px; height: 28px;
  text-align: center; white-space: nowrap; vertical-align: middle; position: relative;
}
table.grid thead th { background: var(--surface-2); font-weight: 600; cursor: pointer; user-select: none;
  font-size: 11px; }
table.grid thead th.corner { cursor: default; background: var(--surface); }
table.grid thead th:hover:not(.corner) { background: #e0e6ec; }
table.grid tbody th { background: var(--surface-2); font-weight: 600; cursor: pointer; user-select: none;
  font-size: 11px; padding: 0 8px; }
table.grid tbody th:hover { background: #e0e6ec; }
.empty-cell { background: #fafafa; cursor: pointer; }
.empty-cell:hover { background: #f0f3f7; }
.stack-cell { cursor: pointer; font-weight: 600; }
.stack-cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; z-index: 1; }
.lv1 { background: #e0f2fe; color: #075985; }
.lv2 { background: #bae6fd; color: #075985; }
.lv3 { background: #7dd3fc; color: #082f49; }
.lv4 { background: #38bdf8; color: #fff; }
.lv5 { background: #0ea5e9; color: #fff; }
.lv6 { background: #0369a1; color: #fff; }
.lv-pill { display: inline-block; padding: 2px 4px; border-radius: 3px; font-size: 9px;
  background: rgba(0,0,0,.1); margin: 1px; }

/* Gap cells — physical space where racks used to be, no longer exist. Invisible, just preserves layout alignment. */
.gap-cell { background: transparent !important; border: none !important; cursor: default; }
.gap-header { background: transparent !important; border: none !important; cursor: default !important; color: transparent; }
.gap-header:hover { background: transparent !important; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* Modal tabs */
.mtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.mtab { background: none; border: none; padding: 8px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mtab.active { color: var(--text); border-bottom-color: var(--primary); }

/* Level checkboxes (Print panel) */
.lv-checks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lv-check {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--surface-2); border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; font-family: 'JetBrains Mono', monospace;
}
.lv-check input { margin: 0; }
.lv-check span { font-weight: 600; }

/* Radio pills */
.radio-pill {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: var(--surface-2); border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; flex: 1;
}

/* Select */
.select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 13px; background: var(--surface);
  font-family: inherit; color: var(--text);
}

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r); padding: 24px; width: min(440px, 92vw);
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.modal .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.level-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.level-btn {
  width: 38px; height: 38px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--r-sm); font-weight: 600; font-size: 14px; cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.level-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1f24; color: #fff; padding: 10px 18px; border-radius: var(--r-sm);
  font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s; z-index: 200;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

/* QR resolver */
.qr-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.qr-card {
  background: var(--surface); border-radius: var(--r); padding: 32px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-lg); text-align: center;
}
.qr-card .loc-id {
  font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 700;
  margin: 12px 0; letter-spacing: 0.02em;
}
.qr-card .breadcrumb {
  display: flex; justify-content: center; gap: 8px; color: var(--text-muted); font-size: 13px;
  margin-bottom: 16px;
}
.qr-card .breadcrumb span { background: var(--surface-2); padding: 4px 10px; border-radius: var(--r-sm); }
.qr-card .meta { color: var(--text-muted); font-size: 12px; margin-top: 16px; }
.qr-card .not-found { color: var(--danger); font-weight: 600; }
