/* style.css — PWA склада. Крупные кнопки ≥44px, понятно без инструкции. */
:root {
  --green: #1f7a3d;
  --green-dark: #155c2d;
  --green-light: #e6f5ea;
  --red: #c0392b;
  --red-light: #fdecec;
  --orange: #e67e22;
  --orange-light: #fef3e2;
  --bg: #f0f4f1;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 10px;

  /* Брендинг (выбрано владельцем 19.06): использовать в новом коде вместо хардкода */
  --brand: #3B6D11;           /* основной (кнопки, акценты, иконка PWA) */
  --brand-light: #639922;     /* светлый акцент */
  --brand-soft: #EAF3DE;      /* фон-плашка (заработок, мягкие блоки) */
  --brand-soft-text: #173404; /* текст на --brand-soft */
  --danger: #E24B4A;          /* срочное/дефицит (белый текст поверх) */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

/* ── Шапка ─────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green);
  color: #fff;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  font-size: 18px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { flex: 0 0 auto; }
.user-label {
  flex: 1;
  font-size: 15px;
  font-weight: 400;
  opacity: 0.92;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
}

/* ── Экраны ─────────────────────────────────────────────────────────────────── */
.screen { padding: 16px; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
[hidden] { display: none !important; }

/* ── Карточки ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.06);
}
.center-card { text-align: center; }

h1 { font-size: 22px; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 15px; line-height: 1.45; }

/* ── Вход ───────────────────────────────────────────────────────────────────── */
.code-input {
  display: block;
  width: 100%;
  margin: 20px 0 12px;
  padding: 16px;
  font-size: 28px;
  letter-spacing: 6px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fafafa;
  color: var(--text);
  transition: border-color 0.15s;
}
.code-input:focus { border-color: var(--green); background: #fff; }

/* ── Кнопки ─────────────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  font-size: 19px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.08s, opacity 0.08s;
  margin-top: 10px;
}
.btn:active { transform: scale(0.97); opacity: 0.88; }
.btn-primary { background: var(--green); color: #fff; }
.btn-checkin { background: var(--green); color: #fff; font-size: 20px; min-height: 64px; }
.btn-checkout { background: #4b5563; color: #fff; font-size: 20px; min-height: 64px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── Роль / имя ─────────────────────────────────────────────────────────────── */
.role-tag {
  display: inline-block;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

/* ── Статус смены ───────────────────────────────────────────────────────────── */
.shift-status {
  margin: 12px 0 4px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--green-light);
  color: var(--green-dark);
}
.shift-status.warn { background: var(--orange-light); color: #7c4a00; }
.shift-status.off { background: #f3f4f6; color: var(--muted); }

/* ── Гео ────────────────────────────────────────────────────────────────────── */
.geo-state {
  margin-top: 10px;
  font-size: 14px;
  min-height: 20px;
}

/* ── Сообщение после чек-ина ────────────────────────────────────────────────── */
.checkin-msg {
  margin-top: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
}
.checkin-msg.ok { background: var(--green-light); color: var(--green-dark); }
.checkin-msg.err { background: var(--red-light); color: var(--red); }

/* ── Сообщение об ошибке ────────────────────────────────────────────────────── */
.msg-error {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--red-light);
  color: var(--red);
  font-size: 15px;
  font-weight: 500;
}

/* ── Карточка заработка ─────────────────────────────────────────────────────── */
.card-earn { display: flex; flex-direction: column; gap: 4px; }
.earn-label { font-size: 14px; }
.earn-sum { font-size: 30px; font-weight: 700; color: var(--green); }
.earn-sub { font-size: 13px; }

/* ── feat/tasks: навигация, список задач, модалка ────────────────────────── */

/* Нижняя навигация */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  padding: 10px 0 8px;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
}
.nav-btn span { font-size: 11px; font-weight: 500; }
.nav-btn.active { color: var(--green); }

/* Отступ снизу под нав-бар */
body.has-nav .screen { padding-bottom: 80px; }

/* Поля формы */
.field-input, .field-textarea, .field-select {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.field-input:focus, .field-textarea:focus, .field-select:focus {
  border-color: var(--green); background: #fff;
}
.field-textarea { resize: vertical; min-height: 60px; }
.row-fields { display: flex; gap: 8px; }
.row-fields .field-select { margin-top: 10px; }

.section-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }

/* Карточка задачи */
.tasks-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.btn-refresh {
  background: none; border: none; font-size: 22px;
  color: var(--green); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.btn-refresh:active { background: var(--green-light); }

.tasks-list { display: flex; flex-direction: column; gap: 10px; }
.tasks-empty { text-align: center; padding: 20px 0; }

.task-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fff;
}
.task-card.prio-1 { border-color: #e74c3c; background: #fff8f8; }
.task-card.prio-2 { border-color: #f39c12; background: #fffbf3; }
.task-card.prio-3 { border-color: var(--border); }
.task-card.status-done { opacity: 0.55; }

.task-prio { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.task-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.task-details { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.task-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.task-btns { display: flex; gap: 8px; }
.task-btn {
  flex: 1;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.task-btn-take { background: var(--green); color: #fff; }
.task-btn-done { background: #27ae60; color: #fff; }
.task-btn-cancel { background: #ecf0f1; color: #555; }
.task-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Модалка */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end;
}
.modal-card {
  width: 100%; max-width: 520px; margin: 0 auto;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
.modal-card h3 { font-size: 18px; margin-bottom: 6px; }
.modal-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.btn-cancel { background: #f3f4f6; color: var(--text); font-size: 16px; font-weight: 600;
              min-height: 52px; border: none; border-radius: var(--radius-sm); cursor: pointer; }

/* msg-success */
.msg-success {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 15px;
  font-weight: 500;
}

/* ── feat/plan-day: план фасовки ─────────────────────────────────────────── */

/* Поле кол-ва — короткое, рядом с select */
.field-qty {
  flex: 0 0 130px;
}

/* Строка "нафасовать" */
.plan-need {
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
  color: var(--text);
}

/* ── feat/dispatcher: список заданий ─────────────────────────────────────── */

.assign-list {
  list-style: none;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.assign-list li {
  font-size: 14px;
  color: var(--text);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.assign-list li:last-child { border-bottom: none; }

/* ── feat/9/boss: пульт управляющего ──────────────────────────────────────── */

/* Суб-табы внутри экрана boss */
.boss-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.boss-tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}
.boss-tab.active {
  background: var(--primary);
  color: #fff;
}

.boss-panel {
  padding-bottom: 8px;
}

/* Сетка плиток дашборда */
.boss-group-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 14px 0 6px;
}
.boss-group-title:first-child { margin-top: 4px; }

.boss-tile-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.boss-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.boss-tile--warn {
  border-color: #E24B4A;
  background: rgba(226,75,74,.07);
}
.boss-tile-icon { font-size: 22px; }
.boss-tile-val  { font-size: 18px; font-weight: 700; color: var(--text); }
.boss-tile-label { font-size: 11px; color: var(--text-muted); }

/* Баланс кассы */
.kassa-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 2px;
}
.kassa-balance-sum {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}

/* Маленькая кнопка (закрытие брака) */
.btn-small {
  font-size: 12px;
  padding: 2px 10px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  min-height: 28px;
  margin-left: 6px;
}

/* ── PWA: баннер установки на телефон ──────────────────────────────────────── */
.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--brand-soft);
  color: var(--brand-soft-text);
  padding: 10px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.install-banner-text { flex: 1; font-weight: 500; }
.btn-install-ok {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}
.btn-install-x {
  background: none;
  border: none;
  color: var(--brand-soft-text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 44px;
  opacity: 0.7;
}

/* ── Доступность: видимый фокус для клавиатурной навигации ───────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}
