:root {
  --bg: #e8f1fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, #0f2f75, #2563eb);
  color: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; }
h2 { margin-bottom: 10px; font-size: 17px; }

.app-header p { color: #dbeafe; font-size: 13px; }
.muted, .status, small { color: var(--muted); font-size: 13px; }

main {
  display: grid;
  gap: 12px;
  padding: 12px;
  padding-bottom: 30px;
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.sticky-card {
  position: sticky;
  top: 78px;
  z-index: 10;
}

.step-pill {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  background: #f8fafc;
}

input:focus, select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: var(--primary);
  background: #fff;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:active { transform: translateY(1px); }
button.ghost { border: 1px solid #93c5fd; background: #eff6ff; color: var(--primary-dark); }
button.danger { background: var(--danger); }
button.compact { min-height: 34px; padding: 7px 11px; }
.hidden { display: none !important; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.workspace { display: grid; gap: 12px; }

.status {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #f1f5f9;
}

.danger-status {
  background: #fee2e2;
  color: #991b1b;
}

.session-row, .list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.scan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.camera-btn {
  min-height: 44px;
  margin-top: 10px;
  border-radius: 12px;
  background: #0f766e;
}

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  max-height: 230px;
  overflow: auto;
}

.search-result {
  width: 100%;
  border-radius: 12px;
  padding: 10px;
  background: #eef6ff;
  color: var(--text);
  text-align: left;
}

.search-result strong,
.product-preview strong,
.line-description {
  display: block;
}

.search-result small,
.product-preview small,
.line-meta {
  display: block;
  margin-top: 4px;
}

.product-preview {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  font-size: 14px;
}

#line-count, #history-count {
  padding: 5px 10px;
  border-radius: 999px;
  background: #dbeafe;
  color: var(--primary-dark);
}

#line-search { margin: 6px 0 10px; }

.count-lines, .history-lines {
  display: grid;
  gap: 8px;
}

.count-line, .history-line {
  display: grid;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

.history-line {
  gap: 4px;
}

.history-line strong {
  color: var(--primary-dark);
}

.line-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.line-actions input { min-height: 40px; }
.line-delete { min-height: 38px; padding-inline: 12px; }

.bottom-actions {
  position: sticky;
  bottom: 8px;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0), var(--card) 30%);
}

.scanner-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(15, 23, 42, 0.65);
}

.scanner-card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 14px;
  border-radius: 18px;
  background: var(--card);
}

#scanner-video {
  width: 100%;
  min-height: 260px;
  margin-top: 12px;
  border-radius: 14px;
  background: #020617;
  object-fit: cover;
}

@media (min-width: 760px) {
  main {
    max-width: 760px;
    margin: 0 auto;
  }
}
