/* Мобильно-первая база. Ноутбук — второй сценарий, поэтому без десктопных
   изысков: крупные тач-таргеты, читаемый шрифт, безопасные отступы. */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1f2320;
  --text-muted: #6b7268;
  --primary: #3f6e52;
  --primary-text: #ffffff;
  --border: #e2e0da;
  --danger: #b3432b;
  --warning: #c98a1a;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 {
  font-size: 22px;
  margin: 0 0 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

input, select, textarea {
  width: 100%;
  font-size: 16px; /* iOS не зумит поле при фокусе, если >=16px */
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  padding: 14px 16px;
  margin-top: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-text);
  cursor: pointer;
}

button:active, .btn:active {
  opacity: 0.85;
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

/* Навигация по разделам */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-list a {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

/* Вкладки (Сырьё / Упаковка и т.п.) */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tabs button {
  width: auto;
  flex: 1;
  margin-top: 0;
  padding: 10px 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tabs button.active {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

/* Строки списка */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
}
.list-row-main {
  min-width: 0;
}
.list-row-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.list-row-value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.warning {
  color: var(--warning);
  border-color: var(--warning);
}
.badge.danger {
  color: var(--danger);
  border-color: var(--danger);
}
.badge.success {
  color: var(--primary);
  border-color: var(--primary);
}

.line-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.line-item-main {
  min-width: 0;
}
.line-item-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.line-item-sub {
  font-size: 13px;
  color: var(--text-muted);
}
.line-item-value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* Сканер */
.scan-video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  display: block;
}
.scan-feed {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scan-feed-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.scan-feed-item.found {
  background: #eaf3ec;
  color: var(--primary);
}
:root[data-theme] .scan-feed-item.found {
  background: #eaf3ec;
}
.scan-feed-item.notfound {
  background: #fbeee9;
  color: var(--danger);
}
.scan-picker {
  margin-top: 8px;
  padding: 12px;
  border: 1px dashed var(--warning);
  border-radius: var(--radius);
  background: #fdf6e8;
}
.qr-box {
  text-align: center;
}
.qr-box img {
  max-width: 220px;
  width: 100%;
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}
.button-row {
  display: flex;
  gap: 10px;
}
.button-row button {
  margin-top: 0;
}

.total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 18px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.top-bar h1 {
  margin: 0;
}
.top-bar a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  font-size: 28px;
  line-height: 56px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  margin-top: 0;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 10px;
}
