:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.88);
  --bg-panel: rgba(255, 255, 255, 0.94);
  --bg-soft: #f0f3f9;
  --bg-strong: #ffffff;
  --text: #111827;
  --text-muted: #667085;
  --text-soft: #98a2b3;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.05);
  --brand: #111827;
  --brand-strong: #0f172a;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-width: 272px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Geist, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 28%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.08), transparent 24%),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  width: min(100% - 24px, 1480px);
  margin: 0 auto;
  padding: 16px 0 24px;
  display: grid;
  gap: 16px;
}

.panel,
.sidebar {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 20px;
}

.sidebar {
  padding: 18px;
  position: sticky;
  top: 16px;
  align-self: start;
  display: grid;
  gap: 18px;
}

.workspace-shell,
.workspace-content,
.section-heading,
.summary-grid,
.content-grid,
.grid,
.asset-form,
.form-actions,
.inventory-list,
.detail-card,
.topbar-controls,
.backup-panel,
.backup-actions,
.snapshot-history,
.import-preview-meta,
.import-json-form,
.import-json-actions,
.import-preview-actions,
.import-format-grid {
  display: grid;
  gap: 16px;
}

.section-heading {
  align-items: start;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
  margin-bottom: 12px;
  max-width: 11ch;
}

h2 {
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 0;
}

h3 {
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.muted-copy,
.section-heading > p,
.form-help,
.inventory-notes,
.detail-notes,
.pagination-summary {
  color: var(--text-muted);
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
}

.form-help {
  font-size: 0.82rem;
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  border-color: rgba(59, 130, 246, 0.34);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

textarea {
  min-height: 116px;
  resize: vertical;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    transform var(--transition),
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    opacity var(--transition);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.secondary-btn {
  background: var(--bg-strong);
  border-color: var(--line);
  color: var(--text);
}

.ghost-btn {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
}

.ghost-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.sidebar-head,
.sidebar-brand-link,
.sidebar-link,
.sidebar-lock,
.inventory-toolbar-meta,
.inventory-results,
.inventory-topline,
.inventory-meta,
.detail-meta,
.detail-actions,
.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-head {
  justify-content: space-between;
}

.sidebar-brand-link {
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.sidebar-head-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #111827, #475467);
}

.sidebar-nav,
.sidebar-section {
  display: grid;
  gap: 10px;
}

.sidebar-label {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-link {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.sidebar-link:hover,
.sidebar-link:focus-visible,
.sidebar-link.is-active {
  background: var(--bg-soft);
  color: var(--text);
}

.sidebar-link.is-active {
  font-weight: 700;
}

.sidebar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-width: 18px;
  height: 18px;
  color: currentColor;
}

.sidebar-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-tag-teal {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.sidebar-tag-blue {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.sidebar-tag-cyan {
  background: rgba(6, 182, 212, 0.14);
  color: #0e7490;
}

.sidebar-tag-amber {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.sidebar-tag-rose {
  background: rgba(244, 63, 94, 0.16);
  color: #be123c;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-strong);
}

.summary-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.summary-card strong {
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  letter-spacing: -0.03em;
}

.content-grid {
  align-items: start;
}

.dashboard-grid,
.inventory-page-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

.inventory-panel,
.form-panel,
.detail-panel {
  min-width: 0;
}

.form-page-panel {
  width: 100%;
}

.detail-page-panel {
  width: 100%;
}

.scan-layout {
  display: grid;
  gap: 20px;
}

.scan-box,
.qr-code-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-strong);
}

.qr-reader {
  min-height: 280px;
}

.scan-side {
  display: grid;
  gap: 16px;
}

.scan-feedback,
.qr-code-caption {
  color: var(--text-muted);
}

.qr-code-panel {
  display: grid;
  gap: 14px;
  justify-items: start;
}

.qr-code-frame {
  width: 168px;
  min-height: 168px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.qr-code-frame canvas,
.qr-code-frame img,
.qr-code-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

.inventory-viewbar {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96)),
    var(--bg-strong);
  box-shadow: var(--shadow-soft);
}

.inventory-viewbar-main {
  display: grid;
  gap: 12px;
}

.viewbar-field {
  display: grid;
  gap: 8px;
}

.viewbar-label {
  color: var(--text-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.toolbar-select,
.viewbar-field input,
.viewbar-field select {
  min-height: 44px;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.98);
}

.inventory-toolbar-meta,
.inventory-results {
  flex-wrap: wrap;
}

.inventory-toolbar-meta {
  justify-content: space-between;
}

.inventory-results {
  align-items: baseline;
}

.inventory-results strong {
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.backup-panel {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(16, 185, 129, 0.06)),
    var(--bg-strong);
}

.backup-actions,
.import-json-actions,
.import-preview-actions {
  grid-auto-flow: column;
  justify-content: start;
}

.import-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-strong);
  color: var(--text);
}

.import-btn input {
  display: none;
}

.import-preview-panel {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-strong);
  display: grid;
  gap: 16px;
}

.import-preview-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  margin-right: 8px;
  margin-bottom: 8px;
}

.import-json-form textarea {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.import-format-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
}

.import-format-example pre {
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  overflow: auto;
}

.inventory-list {
  min-height: 220px;
  margin-top: 8px;
}

.inventory-table-host {
  display: block;
}

.inventory-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96)),
    var(--bg-strong);
  box-shadow: var(--shadow-soft);
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.inventory-table thead {
  background: rgba(240, 243, 249, 0.88);
}

.inventory-table th {
  padding: 14px 16px;
  text-align: left;
  color: var(--text-soft);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.inventory-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.94rem;
}

.inventory-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.inventory-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}

.inventory-table tbody tr:last-child td {
  border-bottom: 0;
}

.table-code {
  font-weight: 700;
  color: var(--brand);
}

.table-notes {
  color: var(--text-muted);
  max-width: 34ch;
  line-height: 1.45;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.inventory-select {
  width: 100%;
  text-align: left;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 252, 0.98)),
    var(--bg-strong);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.inventory-select:hover {
  transform: translateY(-1px);
}

.inventory-select.is-selected {
  border-color: rgba(59, 130, 246, 0.26);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.08), var(--shadow-soft);
}

.inventory-topline,
.detail-title-row {
  justify-content: space-between;
}

.inventory-meta,
.detail-meta,
.detail-actions {
  flex-wrap: wrap;
}

.device-code {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.pill-type-sd {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.pill-type-micro-sd {
  background: rgba(6, 182, 212, 0.14);
  color: #0e7490;
}

.pill-type-hdd {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.pill-type-external-hdd {
  background: rgba(217, 119, 6, 0.16);
  color: #92400e;
}

.pill-type-internal-ssd {
  background: rgba(5, 150, 105, 0.14);
  color: #065f46;
}

.pill-type-ssd {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.pill-type-usb {
  background: rgba(244, 63, 94, 0.14);
  color: #be123c;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.stack-column {
  display: grid;
  gap: 16px;
}

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

.form-actions {
  grid-auto-flow: column;
  justify-content: start;
}

.dashboard-panel .form-actions {
  margin-top: 8px;
}

.photo-preview,
.detail-photo-wrap {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.photo-preview img,
.detail-photo-wrap img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.detail-card.empty-state {
  min-height: 220px;
  place-items: center;
}

.detail-field {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-strong);
}

.detail-field span {
  display: block;
  color: var(--text-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.secondary-action,
.danger-action {
  border: 1px solid var(--line);
  background: var(--bg-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
}

.danger-action {
  color: var(--danger);
}

.empty-list {
  padding: 28px 18px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--text-muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
}

@media (min-width: 1024px) {
  .app-shell {
    grid-template-columns: minmax(240px, var(--sidebar-width)) minmax(0, 1fr);
  }

  .content-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  }

  .inventory-viewbar-main {
    grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(180px, 0.6fr));
  }

  .scan-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  }
}

@media (max-width: 1023px) {
  .sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 100%);
    padding-top: 12px;
  }

  .panel,
  .sidebar {
    padding: 16px;
  }

  .summary-grid,
  .grid.two-columns,
  .detail-grid,
  .dashboard-grid,
  .inventory-page-grid {
    grid-template-columns: 1fr;
  }

  .inventory-table {
    min-width: 760px;
  }

  .backup-actions,
  .import-json-actions,
  .import-preview-actions {
    grid-auto-flow: row;
  }

  .import-format-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-auto-flow: row;
  }

  .inventory-topline,
  .detail-title-row {
    flex-direction: column;
    align-items: start;
  }
}
