*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #020617;
  color: #f1f5f9;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app {
  max-width: 32rem;
  margin: 0 auto;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.header {
  padding-top: 0.5rem;
  text-align: center;
}

.title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: #94a3b8;
}

.nav-home {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn {
  border: none;
  border-radius: 1rem;
  padding: 1.1rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
  min-height: 3rem;
}

.btn:active:not(:disabled) {
  transform: scale(0.99);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #059669;
  color: #fff;
  box-shadow: 0 8px 24px rgb(5 46 22 / 50%);
}

.btn-primary:active:not(:disabled) {
  background: #10b981;
}

.btn-secondary {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 8px 24px rgb(12 74 110 / 40%);
}

.btn-secondary:active:not(:disabled) {
  background: #0ea5e9;
}

.btn-outline {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #475569;
}

.btn-outline:active:not(:disabled) {
  background: #1e293b;
}

.btn-danger {
  background: rgb(69 10 10 / 40%);
  color: #fecaca;
  border: 1px solid rgb(127 29 29 / 60%);
}

.btn-danger:active:not(:disabled) {
  background: rgb(69 10 10 / 70%);
}

.btn-sm {
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  min-height: 2.5rem;
}

.btn-block {
  width: 100%;
}

.section-scan {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-scan .scanner-wrap {
  max-height: min(52vh, 420px);
}

#screen-collect.camera-active .inventory-section {
  margin-top: 0;
}

.scan-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.scan-hint {
  flex: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  background: #0f172a;
  font-size: 0.8rem;
  color: #cbd5e1;
  text-align: center;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid #b45309;
  background: rgb(69 26 3 / 50%);
  color: #fef3c7;
  font-size: 0.875rem;
}

.scanner-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  background: #000;
  box-shadow: 0 0 0 2px rgb(16 185 129 / 40%);
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  pointer-events: none;
  position: absolute;
  inset: 2rem;
  border: 2px dashed rgb(255 255 255 / 50%);
  border-radius: 0.75rem;
}

.scanner-label {
  position: absolute;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgb(255 255 255 / 90%);
  text-shadow: 0 1px 4px #000;
}

.scanner-paused {
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  border-radius: 1rem;
  border: 1px dashed #475569;
  background: rgb(15 23 42 / 60%);
  color: #94a3b8;
}

.paused-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.paused-text {
  margin: 0;
  font-size: 0.875rem;
}

.inventory-section {
  margin-top: 0.5rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 40%);
}

.inventory-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.inventory-header h2 {
  margin: 0;
  font-size: 1rem;
  color: #e2e8f0;
}

.totals {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #94a3b8;
}

.totals strong {
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.inventory-loading,
.inventory-empty {
  margin-top: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  color: #64748b;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 60%);
}

.inventory-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 80%);
}

.inventory-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #1e293b;
}

.inventory-list li:last-child {
  border-bottom: none;
}

.inventory-list .code {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: #6ee7b7;
  word-break: break-all;
}

.inventory-list .qty {
  flex-shrink: 0;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  background: #1e293b;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.qty-modal {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 1rem;
  background: #0f172a;
  color: #f1f5f9;
  max-width: 24rem;
  width: calc(100% - 2rem);
  box-shadow: 0 25px 50px rgb(0 0 0 / 50%);
}

.qty-modal::backdrop {
  background: rgb(0 0 0 / 70%);
}

.qty-modal form {
  padding: 1.25rem;
}

.qty-modal h2 {
  margin: 0;
  font-size: 1.125rem;
}

.qty-codigo {
  margin: 0.25rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  color: #34d399;
}

.qty-modal label {
  display: block;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #cbd5e1;
}

.qty-modal input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  border-radius: 0.75rem;
  border: 1px solid #475569;
  background: #020617;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.qty-modal input:focus {
  outline: 2px solid #10b981;
  outline-offset: 0;
}

.qty-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.qty-actions .btn {
  flex: 1;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(90%, 24rem);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.75rem;
  border: 1px solid rgb(16 185 129 / 50%);
  background: rgb(6 78 59 / 95%);
  color: #ecfdf5;
  box-shadow: 0 10px 40px rgb(0 0 0 / 40%);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
}

.toolbar-home,
.toolbar-collect {
  flex-direction: column;
  gap: 0.75rem;
}

.toolbar-row {
  display: grid;
  gap: 0.75rem;
  width: 100%;
}

.toolbar-row-2 {
  grid-template-columns: 1fr 1fr;
}

.toolbar-row .btn {
  width: 100%;
}

.toolbar-header {
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.toolbar-header .screen-title {
  min-width: 0;
}

.toolbar-import {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  align-items: stretch;
}

.toolbar-import .btn-importar-wide,
.toolbar-import #btn-importar {
  grid-column: 1 / -1;
}

.screen-title {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
  text-align: left;
}

.inventarios-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inventario-card {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 70%);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.inventario-card:active {
  background: #1e293b;
  border-color: #334155;
}

.inventario-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.inventario-card-head strong {
  font-size: 1rem;
  color: #f8fafc;
}

.inventario-card-meta,
.inventario-card-totals {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.45;
}

.inventario-card-totals {
  color: #6ee7b7;
  font-weight: 600;
}

.badge {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-open {
  background: rgb(6 78 59 / 50%);
  color: #6ee7b7;
  border: 1px solid rgb(16 185 129 / 40%);
}

.badge-done {
  background: rgb(30 58 138 / 40%);
  color: #93c5fd;
  border: 1px solid rgb(59 130 246 / 35%);
}

.card {
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 50%);
}

.collect-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.collect-nome {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
}

.collect-info {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.4;
}

.form-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 50%);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border: none;
  margin: 0;
  padding: 0;
}

.field span,
.field legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: #e2e8f0;
}

.field input[type="text"],
.field input[type="url"],
.field select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid #475569;
  background: #020617;
  color: #fff;
  font-size: 1rem;
}

.field input:focus,
.field select:focus {
  outline: 2px solid #10b981;
}

.hint {
  font-size: 0.75rem;
  color: #64748b;
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #cbd5e1;
  margin-top: 0.35rem;
}

.scan-hint-block {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  background: #0f172a;
  font-size: 0.85rem;
  color: #cbd5e1;
  text-align: center;
}

.hardware-scan {
  padding: 1rem;
}

.hardware-scan-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.scan-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.scan-input-row input {
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
}

.section-hardware-scan .field {
  margin-bottom: 0;
}

.item-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.item-main .desc {
  font-size: 0.75rem;
  color: #94a3b8;
  word-break: break-word;
}

.qty-descricao {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.inventory-list li {
  align-items: flex-start;
}

.items-filter-field {
  margin-top: 0.75rem;
}

.sync-status {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: #422006;
  color: #fcd34d;
  font-size: 0.8rem;
}

.item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.item-btns {
  display: flex;
  gap: 0.5rem;
}

.item-btns .btn-item-action {
  padding: 0.5rem 0.85rem;
  font-size: 0.8125rem;
  min-height: 2.35rem;
  min-width: 4.25rem;
}

.edit-item-code-wrap {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: #0f172a;
  border: 1px solid #334155;
}

.edit-item-code-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.edit-item-codigo {
  margin: 0.35rem 0 0;
  font-family: ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 600;
  color: #34d399;
  word-break: break-all;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  min-height: auto;
}

.item-pending {
  background: rgba(251, 191, 36, 0.06);
}

.item-sync-badge {
  display: inline-block;
  margin-top: 0.15rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background: #422006;
  color: #fcd34d;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: stretch;
}

.search-row input {
  min-width: 0;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid #475569;
  background: #020617;
  color: #fff;
  font-size: 1rem;
}

.search-row input:focus {
  outline: 2px solid #10b981;
  outline-offset: 0;
}

.search-row .btn {
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 80%);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #1e293b;
}

.data-table th {
  background: #0f172a;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .mono {
  font-family: ui-monospace, monospace;
  color: #6ee7b7;
  white-space: nowrap;
}

.import-panel {
  margin-top: 0.5rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid #1e293b;
  background: rgb(15 23 42 / 40%);
}

.import-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #e2e8f0;
}

.file-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
}

.alert-success {
  border-color: rgb(16 185 129 / 50%);
  background: rgb(6 78 59 / 40%);
  color: #a7f3d0;
}
