:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #0b1425;
  --muted: #667085;
  --line: #e4e7ec;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
  --accent: #e93e0e;
  --accent-hover: #c9340c;
  --cool: #eef4f9;
  --ok: #027a48;
  --danger: #b42318;
  --radius: 2px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: "Prompt", "Avenir Next", "Segoe UI", sans-serif;
  --header-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}
button, .btn, a.btn { touch-action: manipulation; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.btn:hover { text-decoration: none; }

.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: relative;
  background: var(--sidebar);
  color: #f9fafb;
  padding: 0.9rem 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.nav-scrim {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0.7rem 0.65rem;
  margin: 0 0 0.35rem;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 100%;
  max-width: 140px;
  height: auto;
  display: block;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-height: 0; }
.nav-section {
  margin: 0.7rem 0.45rem 0.25rem;
  color: #98a2b3;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #d0d5dd;
  padding: 0.58rem 0.65rem;
  border-radius: 2px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a.active {
  background: transparent;
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.header-search input {
  border-radius: 0 !important;
}
.user-trigger {
  border-radius: 0 !important;
}
.btn, .btn-primary, input, select, textarea, .panel, .tag, .modal, .action-tabs .tab {
  border-radius: 0 !important;
}
.scan-panel {
  display: grid;
  gap: 0.9rem;
  max-width: 640px;
}
.scan-hero-block {
  border: 1px dashed #d0d5dd;
  background: #fafafa;
  padding: 1.6rem 1.2rem 1.35rem;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.scan-hero-block.is-busy {
  border-color: #98a2b3;
  background: #f2f4f7;
}
.scan-hero-block.is-ok {
  border-color: #039855;
  background: #ecfdf3;
  box-shadow: 0 0 0 3px rgba(3, 152, 85, 0.12);
}
.scan-hero-block.is-err {
  border-color: var(--danger);
  background: #fef3f2;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}
.scan-hero-block .scan-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 0.9rem;
  border-radius: 50%;
  border: 3px solid rgba(233, 62, 14, 0.45);
  animation: scan-pulse 1.6s ease-in-out infinite;
}
.scan-hero-block.is-ok .scan-ring {
  border-color: #039855;
  animation: none;
}
.scan-hero-block.is-err .scan-ring {
  border-color: var(--danger);
  animation: none;
}
@keyframes scan-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.7; }
}
.scan-heading {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.scan-sub { margin: 0.35rem 0 0.9rem; }
.scan-panel .scan-input {
  width: min(420px, 100%);
  margin: 0 auto;
  display: block;
  font-size: 1.2rem;
  padding: 0.95rem 1rem;
  text-align: center;
  border: 1px solid var(--ink);
}
.scan-status {
  margin: 0.75rem 0 0;
  font-weight: 650;
  font-size: 0.95rem;
}
.scan-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.camera-reader {
  position: relative;
  width: min(560px, 100%);
  margin: 0.35rem auto 0.65rem;
  background: #0b1425;
  overflow: hidden;
  min-height: 280px;
  height: min(52vh, 460px);
}
.camera-reader video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b1425;
  image-rendering: auto;
}
.camera-reticle {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 38%;
  height: 24%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(11, 20, 37, 0.35);
  pointer-events: none;
}
.camera-reader canvas,
.camera-reader img,
#qr-shaded-region {
  display: none !important;
}
.camera-file-reader {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 400px;
  height: 400px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.camera-hint { margin: 0 0 0.75rem; font-size: 0.88rem; }
.scan-hero-block.camera-live .scan-ring { display: none; }
.scan-hero-block.camera-live .scan-input { margin-top: 0.35rem; }
.last-scan { text-align: center; margin: 0; }
.scan-hero { display: none; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  background: #0b1425;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}
.bulk-bar .btn { border-color: transparent; }
.bulk-bar .btn:not(.btn-primary) {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}
.check-col { width: 2rem; text-align: center; }
.check-col input { width: 1rem; height: 1rem; }
.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.85rem;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.nav-toggle {
  display: none;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.page-actions:empty { display: none; }
.page-actions:not(:has(*)) { display: none; }

.workspace { display: flex; flex-direction: column; min-width: 0; background: var(--bg); overflow-x: clip; }

.app-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 1.1rem;
}

.header-left { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.org-label {
  color: #98a2b3;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.org-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}

.header-search { flex: 1; min-width: 0; }
.header-search input {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: #f9fafb;
  border-radius: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
}
.header-search input:focus {
  outline: none;
  border-color: #f2b8a4;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(233, 62, 14, 0.12);
}

.sidebar-account {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: grid;
  gap: 0.55rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.15rem 0.35rem;
}
.sidebar-user-meta {
  min-width: 0;
  display: grid;
  gap: 0.05rem;
  color: #f9fafb;
}
.sidebar-user-meta strong {
  font-size: 0.85rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-meta small {
  color: #98a2b3;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.sidebar-user-meta span {
  color: #98a2b3;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-signout {
  display: flex;
  align-items: center;
  padding: 0.58rem 0.65rem;
  color: #f2b8a4;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.sidebar-signout:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scanner-pill {
  font-size: 0.75rem;
  color: var(--ok);
  background: #ecfdf3;
  border: 1px solid #abefc6;
  border-radius: 0;
  padding: 0.28rem 0.6rem;
  white-space: nowrap;
}

.user-menu { position: relative; }
.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 0;
  padding: 0.2rem 0.35rem 0.2rem 0.2rem;
  cursor: pointer;
  color: inherit;
}
.user-trigger:hover { background: #f9fafb; border-color: var(--line); }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #e4e7ec;
  display: grid;
  place-items: center;
  color: #667085;
  flex-shrink: 0;
}
.user-avatar-fallback { border: 1px solid #d0d5dd; }
.user-meta { text-align: left; line-height: 1.15; padding-right: 0.25rem; }
.user-meta strong { display: block; font-size: 0.82rem; font-weight: 650; }
.user-meta small { color: var(--muted); font-size: 0.7rem; text-transform: capitalize; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
  padding: 0.35rem;
  z-index: 40;
}
.user-dropdown-head {
  padding: 0.55rem 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}
.user-dropdown-head strong { display: block; font-size: 0.88rem; }
.user-dropdown-head span { color: var(--muted); font-size: 0.78rem; }
.user-dropdown a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 2px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
}
.user-dropdown a:hover { background: #f9fafb; text-decoration: none; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.05rem 1.25rem 0.35rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.page-head p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }
.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.content { padding: 0.75rem 1.25rem 1.75rem; display: grid; gap: 1rem; min-width: 0; }
.content > * { min-width: 0; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.5rem 0.65rem;
  background: #fff;
  color: var(--ink);
}
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23475567' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 12px 8px;
  padding-right: 2.1rem;
  cursor: pointer;
}
select:disabled {
  background-color: #f2f4f7;
  color: var(--muted);
  cursor: not-allowed;
}
textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 2px;
  padding: 0.48rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger, .btn.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-small { padding: 0.28rem 0.55rem; font-size: 0.8rem; }
.btn-google {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.8rem 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  min-width: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0 0 0.9rem;
  padding: 0 0 0.75rem;
  border-bottom: 1px solid #eef2f6;
}
.panel-head h2 { margin: 0; font-size: 0.95rem; font-weight: 700; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.stat-card {
  border-radius: 2px;
  padding: 0.9rem 1rem;
  color: #fff;
  display: grid;
  gap: 0.25rem;
  min-height: 84px;
  min-width: 0;
}
a.stat-card { color: #fff; text-decoration: none; }
a.stat-card:hover { color: #fff; text-decoration: none; filter: brightness(1.08); }
.stat-card span { opacity: 0.85; font-size: 0.8rem; font-weight: 500; }
.stat-card strong { font-size: 1.65rem; letter-spacing: -0.03em; }
.tone-a { background: #0b1425; }
.tone-b { background: #1d3556; }
.tone-c { background: var(--accent); }
.tone-d { background: #344054; }

.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
.split > * { min-width: 0; }

.bar-list { display: grid; gap: 0.7rem; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(7rem, 34%) minmax(3rem, 1fr) 1.75rem;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.88rem;
}
.bar-row > span {
  min-width: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.bar-row > strong { text-align: right; }
.bar { height: 8px; background: #eef2f6; border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.tone2 i { background: #1d3556; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  min-width: 0;
  max-width: 100%;
}
.table-wrap table { min-width: 560px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 0.88rem;
}
th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fafafa;
}
.muted { color: var(--muted); }

.tag {
  display: inline-flex;
  border-radius: 0;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  background: #f2f4f7;
  text-transform: lowercase;
  font-weight: 650;
}
.tag-created, .tag-booked_in, .tag-in_stock, .tag-new { background: #ecfdf3; color: var(--ok); }
.tag-moved, .tag-note, .tag-used, .tag-condition_changed, .tag-migrated, .tag-quantity_adjusted { background: var(--cool); color: #175cd3; }
.tag-booked_out, .tag-refurbished { background: #fef3f2; color: var(--danger); }
.tag-retired { background: #f2f4f7; color: #475467; }
.tag-scheduled, .tag-scheduled_out { background: #fff6ed; color: #c4320a; }
.tag-schedule_cancelled { background: #f2f4f7; color: #475467; }

.filters { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
.filters input[type="search"] { min-width: min(220px, 100%); flex: 1; }

.scan-hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
}
.scan-target {
  border: 1px dashed #d0d5dd;
  border-radius: 2px;
  padding: 1.6rem 1.2rem;
  text-align: center;
  background: #fafafa;
  outline: none;
}
.scan-target:focus, .scan-target:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 62, 14, 0.12);
}
.scan-ring {
  width: 56px; height: 56px; margin: 0 auto 0.85rem;
  border-radius: 50%;
  border: 3px solid rgba(233, 62, 14, 0.4);
}
.scan-input {
  width: min(380px, 100%);
  margin-top: 0.65rem;
  text-align: center;
}
.scan-tips h3 { margin: 0; font-size: 0.95rem; }
.scan-tips ol { margin: 0.5rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; font-size: 0.9rem; }
.live-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.live-feed li {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 0.6rem; background: #f9fafb; border-radius: 2px; font-size: 0.88rem;
}

.detail-grid {
  display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 0;
}
.detail-grid .full { grid-column: 1 / -1; }
.detail-grid dt { color: var(--muted); font-size: 0.72rem; margin-bottom: 0.15rem; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-grid dd { margin: 0; font-weight: 600; font-size: 0.92rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.timeline { display: grid; gap: 0.75rem; }
.timeline-item { display: grid; grid-template-columns: 110px 1fr; gap: 0.65rem; }
.timeline-item .when { color: var(--muted); font-size: 0.8rem; }
.timeline-item p { margin: 0.2rem 0 0; font-size: 0.88rem; }

.form-stack, .form-grid { display: grid; gap: 0.8rem; }
.form-stack label, .form-grid label { display: grid; gap: 0.4rem; font-size: 0.85rem; font-weight: 600; }
.form-grid { grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid[hidden] { display: none !important; }
.form-grid label[hidden],
.form-stack label[hidden] { display: none !important; }
.check { display: flex !important; align-items: center; gap: 0.45rem; font-weight: 500; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.suggest-wrap { position: relative; display: block; }
.suggest-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: 0.2rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
  max-height: 240px;
  overflow: auto;
}
.suggest-list li {
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.88rem;
}
.suggest-list li small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.75rem;
  margin-top: 0.1rem;
}
.suggest-list li.is-active,
.suggest-list li:hover { background: var(--cool); }
.suggest-list li.is-empty {
  cursor: default;
  color: var(--muted);
  font-weight: 400;
}

.config-list { list-style: none; margin: 0.7rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.config-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.5rem; background: #f9fafb; border-radius: 2px; font-size: 0.88rem;
}
.add-list-item { display: flex; gap: 0.4rem; }
.add-list-item input { flex: 1; }

.catalog-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-top: 0.35rem;
  min-height: 280px;
}
.catalog-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.7rem;
  background: #fafbfc;
}
.catalog-col h3 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.catalog-add-device select {
  width: auto;
  min-width: 5.5rem;
}
.picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
  flex: 1;
  align-content: start;
  max-height: 420px;
  overflow: auto;
}
.picker-list > li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.picker-list > li[hidden],
.picker-list > li.is-hidden {
  display: none !important;
}
.picker-list .picker-empty {
  padding: 0.75rem 0.5rem;
  font-size: 0.88rem;
}
.picker-actions {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}
.catalog-selected-mfr {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--ink, #0b1425);
}
.picker-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.picker-item:hover { border-color: #98a2b3; }
.picker-item.is-active {
  border-color: var(--navy, #0b1425);
  background: #0b1425;
  color: #fff;
}
.picker-item.is-disabled { opacity: 0.55; }
.picker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-chevron {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.55;
}
.picker-item.is-active .picker-chevron { opacity: 1; }
#device-picker > li[data-manufacturer] {
  padding: 0.45rem 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 0.9rem;
  font-weight: 600;
}
#device-picker .picker-meta {
  margin-left: auto;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: capitalize;
}


.modal {
  border: 1px solid var(--line);
  padding: 0;
  border-radius: 2px;
  width: min(860px, calc(100vw - 2.5rem));
  max-height: calc(100vh - 3rem);
  overflow: auto;
  box-shadow: 0 28px 80px rgba(11, 20, 37, 0.24);
  background: #fff;
}
.modal::backdrop {
  background: rgba(11, 20, 37, 0.52);
}
.modal-card {
  display: flex;
  flex-direction: column;
  gap: 1.45rem;
  padding: 2rem 2.2rem 1.7rem;
  margin: 0;
}
.modal-card header {
  margin: 0;
  padding: 0 0 1.15rem;
  border-bottom: 1px solid var(--line);
}
.modal-card header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.modal-card header p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
.modal-card .form-grid {
  gap: 1.15rem 1.35rem;
  margin: 0;
}
.modal-card .form-stack {
  gap: 1.15rem;
  margin: 0;
}
.modal-card label {
  gap: 0.5rem;
  font-size: 0.9rem;
}
.modal-card input,
.modal-card select,
.modal-card textarea {
  padding: 0.72rem 0.85rem;
  min-height: 2.7rem;
}
.modal-card select {
  padding-right: 2.4rem;
}
.modal-card textarea {
  min-height: 5.5rem;
}
.modal-card .inline-fields {
  gap: 0.55rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.15rem 0 0;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--line);
}
.modal-actions .btn {
  min-height: 44px;
  padding: 0.65rem 1.25rem;
}
.readonly-field input[readonly] {
  background: #f2f4f7;
  color: var(--muted);
  cursor: default;
}
.field-hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.78rem;
}
.device-summary-block {
  background: #f9fafb;
  border: 1px solid #eef2f6;
}
.device-summary {
  margin: 0;
  padding: 1rem 1.15rem 0.85rem;
  background: transparent;
  border: 0;
  display: grid;
  gap: 0.25rem;
  font-size: 0.92rem;
}
.modal-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.15rem;
  padding: 0.15rem 0.55rem 0.55rem;
  border-top: 1px solid #eef2f6;
}
.modal-tools a,
.modal-tools button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.modal-tools a:hover,
.modal-tools button:hover {
  color: var(--ink);
  text-decoration: underline;
}
.modal-tools .is-danger { color: var(--danger); }
.modal-tools .is-danger:hover { color: var(--danger); }

.modal-sticker { width: min(340px, calc(100vw - 2.5rem)); }
.sticker-sheets {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0;
}
.sticker-sheets .sheet {
  width: 80mm;
  height: 50mm;
  max-width: 100%;
  padding: 2.5mm 3mm;
  border: 1px solid var(--line);
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
}
.sticker-sheets .sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3mm;
  margin-bottom: 1.5mm;
}
.sticker-sheets .brand { display: flex; justify-content: flex-start; margin: 0; flex: 1; min-width: 0; }
.sticker-sheets .brand img { width: 38mm; max-width: 100%; height: auto; display: block; }
.sticker-sheets .manufacturer { margin: 0; font-size: 9px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.sticker-sheets .model { margin: 0 0 1.5mm; font-size: 12px; font-weight: 700; line-height: 1.15; }
.sticker-sheets svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.sticker-sheets .barcode-col { width: 100%; min-width: 0; }
.sticker-sheets .barcode-col svg { width: 100%; shape-rendering: crispEdges; }
.sticker-sheets .code { text-align: center; font-size: 9px; font-weight: 700; margin-top: 1mm; letter-spacing: 0.04em; }
.sticker-sheets .qr-col { flex: 0 0 14mm; text-align: center; }
.sticker-sheets .qr-col canvas, .sticker-sheets .qr-col img { width: 14mm; height: 14mm; display: block; }
.sticker-sheets .qr-hint { display: none; }
.bulk-qty-stepper {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
  justify-content: center;
}
.bulk-qty-btn {
  width: 3rem;
  min-height: 3rem;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
}
.bulk-qty-stepper input {
  width: 6rem;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0.5rem;
  min-height: 3rem;
}
.modal-bulk-sheet { width: min(700px, calc(100vw - 2.5rem)); }
.bulk-sheet-page {
  background: #fff;
  padding: 1.5rem;
  text-align: center;
  max-width: 190mm;
  margin: 0 auto;
}
.bulk-sheet-brand { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.bulk-sheet-brand img { width: 60mm; max-width: 100%; height: auto; }
.bulk-sheet-name { margin: 0; font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }
.bulk-sheet-sub { margin: 0.15rem 0 1.5rem; color: var(--muted); font-size: 1rem; font-weight: 600; }
.bulk-sheet-main {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.2rem;
  margin-bottom: 1.25rem;
}
.bulk-sheet-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bulk-sheet-main svg,
.bulk-sheet-quick svg { max-width: 100%; height: auto; display: block; margin: 0 auto; shape-rendering: crispEdges; }
.bulk-sheet-code { margin-top: 0.5rem; font-size: 1rem; font-weight: 700; letter-spacing: 0.04em; }
.bulk-sheet-quick-row { display: flex; gap: 1rem; }
.bulk-sheet-quick {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  padding: 1rem;
  border: 1px solid var(--line);
}
.bulk-sheet-quick .bulk-sheet-code { font-size: 1.4rem; }
.bulk-sheet-quick-plus { background: #ecfdf3; border-color: #b7ebc9; }
.bulk-sheet-quick-plus .bulk-sheet-code { color: var(--ok); }
.bulk-sheet-quick-minus { background: #fff5f4; border-color: #f5c2c0; }
.bulk-sheet-quick-minus .bulk-sheet-code { color: var(--danger); }
.action-tabs {
  display: flex;
  gap: 0.45rem;
  margin: 0;
  flex-wrap: wrap;
}
.action-tabs .tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.action-tabs .tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
  background: var(--ink); color: #fff;
  padding: 0.65rem 0.9rem;
  border-radius: 2px;
  font-size: 0.88rem;
}

/* Login */
.page-login { min-height: 100vh; }
.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}
.login-hero {
  background:
    radial-gradient(900px 650px at 12% 5%, rgba(233,62,14,0.55), transparent 60%),
    radial-gradient(550px 550px at 100% 100%, rgba(233,62,14,0.2), transparent 60%),
    linear-gradient(160deg, #0b1425 0%, #111827 60%, #17100b 100%);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.login-hero-inner { max-width: 420px; }
.login-logo {
  width: min(280px, 70vw);
  height: auto;
  display: block;
  filter: brightness(0) invert(1);
}
.login-hero .eyebrow,
.login-card .eyebrow {
  text-transform: lowercase;
  letter-spacing: 0.02em;
  color: #f2b8a4;
  font-weight: 650;
  margin: 0 0 0.55rem;
}
.login-card .eyebrow { color: var(--accent); }
.login-hero h1 {
  margin: 0.4rem 0 0.75rem;
  font-size: clamp(2rem, 3vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.login-hero p { margin: 0; color: #d0d5dd; line-height: 1.5; }
.login-panel {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: #fff;
}
.login-card { width: min(420px, 100%); }
.login-card h2 { margin: 0 0 0.35rem; font-size: 1.5rem; }
.login-lead { margin: 0 0 1rem; color: var(--muted); }
.login-steps {
  margin: 0 0 1.1rem;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.35rem;
  color: #344054;
  font-size: 0.92rem;
}
.login-error {
  background: #fef3f2;
  color: var(--danger);
  border-radius: 2px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
}
.login-hint { margin-top: 0.85rem; font-size: 0.85rem; }
.login-setup h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.login-setup p { margin: 0.4rem 0; font-size: 0.88rem; }
.login-code {
  display: block;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.55rem 0.65rem;
  font-size: 0.75rem;
  word-break: break-all;
  margin: 0.35rem 0 0.7rem;
}

@media (max-width: 1100px) {
  body.nav-open { overflow: hidden; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0.65rem 0.7rem;
    padding-top: max(0.65rem, env(safe-area-inset-top));
    padding-left: max(0.7rem, env(safe-area-inset-left));
    padding-right: max(0.7rem, env(safe-area-inset-right));
  }
  .sidebar-top .brand {
    margin: 0;
    padding: 0.35rem 0.5rem;
    max-width: 128px;
    flex: 1;
  }
  .brand-logo { max-width: 108px; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 44px;
  }
  .nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 41;
    margin: 0;
    padding: 0.45rem 0.7rem 0.85rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    background: var(--sidebar);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
    max-height: calc(100dvh - 3.6rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.is-open .nav { display: flex; }
  .nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(11, 20, 37, 0.45);
  }
  .nav-scrim:not([hidden]) { display: block; }
  .nav a,
  .sidebar-signout {
    min-height: 44px;
    font-size: 1rem;
  }
  .sidebar-account { margin-top: 0.85rem; }
  .app-header {
    height: auto;
    min-height: 52px;
    padding: 0.65rem 0.9rem;
    padding-left: max(0.9rem, env(safe-area-inset-left));
    padding-right: max(0.9rem, env(safe-area-inset-right));
  }
  .header-search input { width: 100%; font-size: 16px; }
  input, select, textarea {
    font-size: 16px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem 0.9rem 0.25rem;
  }
  .page-actions { width: 100%; }
  .page-head h1 { font-size: 1.25rem; }
  .content {
    padding: 0.65rem 0.9rem 1.4rem;
    padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  }
  .panel { padding: 0.9rem; }
  .catalog-split { min-height: 0; }
  .bar-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label value"
      "bar bar";
    gap: 0.3rem 0.65rem;
  }
  .bar-row > span { grid-area: label; }
  .bar-row > strong { grid-area: value; }
  .bar-row > .bar { grid-area: bar; }
  .panel-head { flex-wrap: wrap; gap: 0.45rem; }
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .filters input[type="search"] {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }
  .filters select,
  .filters button { min-width: 0; width: 100%; }
  .login-hero { min-height: 180px; padding: 1.4rem; }
  .login-panel { padding: 1.5rem 1rem; }
  .suggest-list li { min-height: 44px; }
}

@media (max-width: 760px) {
  .btn { min-height: 44px; font-size: 16px; }
  .btn-small { min-height: 36px; }
  .stat-card { min-height: 76px; padding: 0.75rem 0.8rem; }
  .stat-card strong { font-size: 1.4rem; }
  .filters,
  .timeline-item {
    grid-template-columns: 1fr;
  }
  .timeline-item { gap: 0.2rem; }
  .page-actions .btn,
  .page-actions a.btn { flex: 1 1 calc(50% - 0.5rem); text-align: center; justify-content: center; }
  th, td { white-space: nowrap; }
  .modal {
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
  }
  .modal-card {
    padding: 1.35rem 1.2rem max(1.4rem, env(safe-area-inset-bottom));
    gap: 1.2rem;
    min-height: 100%;
  }
  .modal-card .form-grid { grid-template-columns: 1fr; }
  .bulk-sheet-quick-row { flex-direction: column; }
  .modal-actions {
    display: flex;
    justify-content: stretch;
  }
  .modal-actions .btn { width: auto; flex: 1; justify-content: center; }
  .modal-actions .btn-primary { grid-column: auto; }
  .action-tabs .tab {
    flex: 1 1 calc(50% - 0.35rem);
    text-align: center;
    min-height: 44px;
  }
  .config-list li { flex-wrap: wrap; }
  .add-list-item,
  .catalog-add-device,
  .inline-fields { flex-wrap: wrap; }
  .add-list-item .btn,
  .inline-fields .btn { width: 100%; }
  .picker-list > li { flex-wrap: wrap; }
  .picker-actions { width: 100%; justify-content: flex-end; }
  .live-feed li { flex-direction: column; gap: 0.15rem; }
  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .suggest-list { max-height: 40vh; }
  .scan-panel { max-width: none; }
  .scan-actions { display: grid; }
  .scan-actions .btn { width: 100%; }
  .login-hero { min-height: 120px; padding: 1rem; }
  .login-logo { width: min(180px, 52vw); }
  .check-col { width: 2.75rem; }
  .check-col input { width: 1.15rem; height: 1.15rem; }
}

.inline-fields { display: flex; gap: 0.4rem; }
.inline-fields input { flex: 1; }
.plain-list { margin: 0 0 0.85rem; padding-left: 1.1rem; display: grid; gap: 0.25rem; font-size: 0.9rem; }
.tiny { font-size: 0.75rem; font-weight: 500; }

@media (min-width: 600px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid,
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .split,
  .catalog-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-layout { grid-template-columns: 1.05fr 0.95fr; }
}

@media (min-width: 1101px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.guide { display: grid; gap: 1rem; max-width: 720px; }
.guide-lead {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.45;
}
.guide-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}
.guide-steps li {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.75rem;
  align-items: start;
}
.guide-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.guide-steps p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; font-weight: 400; }
.guide kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 0.8rem;
  background: #fff;
}
.panel-warn { border: 1px solid #f5c2c0; background: #fff8f7; }
.panel-warn .panel-head h2 { color: var(--danger); }
.detail-grid .btn-small { margin-left: 0.35rem; }

@page sticker-label {
  size: 80mm 50mm;
  margin: 0;
}
@media print {
  body:has(#sticker-modal[open]) > *:not(#sticker-modal),
  body:has(#bulk-sheet-modal[open]) > *:not(#bulk-sheet-modal) { display: none !important; }
  #sticker-modal,
  #bulk-sheet-modal {
    position: static;
    display: block !important;
    width: auto;
    max-height: none;
    border: none;
    box-shadow: none;
    overflow: visible;
  }
  #sticker-modal::backdrop,
  #bulk-sheet-modal::backdrop { display: none; }
  #sticker-modal .modal-card > header,
  #sticker-modal .modal-actions,
  #bulk-sheet-modal .modal-card > header,
  #bulk-sheet-modal .modal-actions { display: none; }
  .sticker-sheets {
    max-height: none;
    overflow: visible;
    display: block;
    gap: 0;
    padding: 0;
  }
  .sticker-sheets .sheet {
    page: sticker-label;
    width: 80mm;
    height: 50mm;
    max-width: 80mm;
    border: none;
    margin: 0;
    padding: 2.5mm 3mm;
    page-break-after: always;
    break-after: page;
  }
  .sticker-sheets .sheet:last-of-type {
    page-break-after: auto;
    break-after: auto;
  }
  .bulk-sheet-page { max-width: none; padding: 0; }
  .bulk-sheet-main,
  .bulk-sheet-quick { border-color: #d0d5dd !important; }
}
