/* PIMS Mini App — стили под тему Telegram */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #999999);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

.hidden { display: none !important; }
#app { max-width: 480px; margin: 0 auto; padding-bottom: 76px; min-height: 100vh; }

/* Экран выбора локации */
#gate { text-align: center; padding: 60px 24px 24px; }
.gate-logo { font-size: 56px; }
#gate h2 { font-size: 28px; letter-spacing: 4px; margin: 8px 0 4px; }
.gate-sub { color: var(--hint); margin-bottom: 28px; }
#gate-locations { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.loc-btn {
  border: 2px solid var(--bg2); background: var(--bg2); color: var(--text);
  padding: 18px; border-radius: 16px; font-size: 17px; font-weight: 600; cursor: pointer;
}
.loc-btn.selected { border-color: var(--btn); background: var(--bg); }
#gate-password {
  width: 100%; border: none; background: var(--bg2); border-radius: 14px;
  padding: 16px; font-size: 20px; text-align: center; letter-spacing: 6px;
  color: var(--text); outline: none; margin-bottom: 12px;
}
.big-btn {
  width: 100%; border: none; background: var(--btn); color: var(--btn-text);
  padding: 16px; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
}
#gate-error { color: var(--red); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* Шапка */
#header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--bg2);
  position: sticky; top: 0; z-index: 10;
}
#user-name { font-weight: 600; font-size: 17px; }
.status { font-size: 13px; color: var(--hint); margin-top: 2px; }
.status.on { color: var(--green); font-weight: 500; }

#month-picker { display: flex; align-items: center; gap: 6px; font-size: 14px; }
#month-label { min-width: 88px; text-align: center; font-weight: 500; }
.month-btn {
  border: none; background: var(--bg); color: var(--link);
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer;
}

/* Вкладки */
.tab { display: none; padding: 16px; }
.tab.active { display: block; }
h3 { font-size: 15px; margin: 18px 0 8px; color: var(--hint); font-weight: 600; }

/* Смена */
#shift-box { text-align: center; }
#shift-hint { color: var(--hint); font-size: 13px; margin-bottom: 16px; line-height: 1.4; }
.shift-btn {
  width: 100%; border: none; border-radius: 18px; padding: 24px;
  font-size: 19px; font-weight: 700; cursor: pointer; transition: transform .08s, opacity .15s;
}
.shift-btn:active { transform: scale(.97); }
.shift-btn:disabled { opacity: .35; }
.shift-btn.open { background: rgba(52,199,89,.16); color: var(--green); }
.shift-btn.close { background: rgba(255,59,48,.13); color: var(--red); }
#shift-progress { color: var(--hint); font-size: 13px; margin-top: 12px; }

/* Списки */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg2); border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.list-item .sub { color: var(--hint); font-size: 12px; margin-top: 2px; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.badge.in { background: rgba(52,199,89,.15); color: var(--green); }
.badge.out { background: rgba(255,59,48,.12); color: var(--red); }
.badge.del { background: rgba(255,149,0,.14); color: var(--orange); }
.empty { text-align: center; color: var(--hint); padding: 24px 0; font-size: 14px; }

/* Календарь */
#calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 11px; color: var(--hint); padding: 6px 0; font-weight: 600; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 14px; cursor: pointer; background: var(--bg2);
  border: 2px solid transparent;
}
.cal-day.other { opacity: .25; pointer-events: none; }
.cal-day.today { border-color: var(--link); }
.cal-day .hrs { font-size: 9px; color: var(--green); font-weight: 700; }
.cal-day.has { background: rgba(52,199,89,.14); }
.cal-day.selected { border-color: var(--btn); }
#day-details { margin-top: 14px; }

/* Зарплата */
.salary-card { background: var(--bg2); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.salary-card .period { font-size: 13px; color: var(--hint); font-weight: 600; }
.salary-card .hours { font-size: 15px; margin-top: 6px; }
.salary-card .sum { font-size: 24px; font-weight: 700; margin-top: 4px; }
.salary-card.total { background: var(--btn); color: var(--btn-text); }
.salary-card.total .period { color: var(--btn-text); opacity: .8; }
.salary-warn {
  background: rgba(255,149,0,.14); color: var(--orange);
  border-radius: 12px; padding: 12px 14px; font-size: 13px; margin-bottom: 12px;
}
.rate-line { text-align: center; color: var(--hint); font-size: 13px; margin-bottom: 16px; }

/* Админ */
.admin-nav { display: flex; gap: 6px; margin-bottom: 14px; }
.admin-nav-btn {
  flex: 1; border: none; background: var(--bg2); color: var(--text);
  padding: 9px 0; border-radius: 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.admin-nav-btn.active { background: var(--btn); color: var(--btn-text); }
.aview { display: none; }
.aview.active { display: block; }

.emp-row { display: flex; align-items: center; gap: 8px; background: var(--bg2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.emp-row .name { flex: 1; font-size: 14px; font-weight: 500; }
.emp-row .sub { display: block; font-size: 11px; color: var(--hint); font-weight: 400; }
.rate-input {
  width: 70px; border: none; background: var(--bg); border-radius: 8px;
  padding: 7px 8px; font-size: 14px; color: var(--text); text-align: right; outline: none;
}
.small-btn {
  border: none; background: var(--btn); color: var(--btn-text);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.small-btn.gray { background: var(--bg); color: var(--hint); }
.small-btn.red { background: rgba(255,59,48,.15); color: var(--red); }

.report-row { background: var(--bg2); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; }
.report-row .rname { font-weight: 600; margin-bottom: 6px; }
.report-row .rline { display: flex; justify-content: space-between; color: var(--hint); font-size: 13px; padding: 2px 0; }
.report-row .rline b { color: var(--text); }
.report-total { background: var(--btn); color: var(--btn-text); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.report-total .rline { display: flex; justify-content: space-between; padding: 2px 0; }

.mark-edit-row { display: flex; align-items: center; gap: 6px; background: var(--bg2); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.mark-edit-row .mdate { color: var(--hint); }
.mark-edit-row .mtype { flex: 1; }
.add-mark-form { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.add-mark-form input, .add-mark-form select {
  border: none; background: var(--bg2); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; color: var(--text); outline: none;
}

/* График */
.sched-row.today { border: 2px solid var(--link); }
.sched-wd { color: var(--hint); font-size: 12px; font-weight: 400; margin-left: 4px; }
.sched-time { font-weight: 700; color: var(--green); }
.sched-off { color: var(--hint); font-size: 13px; }

/* Поставки */
.hint-text { color: var(--hint); font-size: 13px; margin: 4px 0 14px; line-height: 1.4; }
.supplier-btns { display: flex; flex-direction: column; gap: 12px; }
.supplier-btn {
  border: 2px solid var(--bg2); background: var(--bg2); color: var(--text);
  padding: 22px; border-radius: 16px; font-size: 17px; font-weight: 600; cursor: pointer;
}
.supplier-btn:active { border-color: var(--btn); }
.link-btn {
  border: none; background: none; color: var(--link); font-size: 14px;
  padding: 0 0 10px; cursor: pointer;
}
#supply-search {
  width: 100%; border: none; background: var(--bg2); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; color: var(--text); outline: none; margin-bottom: 10px;
}
.prod-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border-radius: 12px; padding: 10px 12px;
}
.prod-name { flex: 1; font-size: 14px; font-weight: 500; line-height: 1.3; }
.prod-req { display: block; font-size: 11px; color: var(--hint); font-weight: 400; margin-top: 2px; }
.qty-input {
  width: 64px; border: none; background: var(--bg); border-radius: 8px;
  padding: 9px 8px; font-size: 15px; color: var(--text); text-align: center; outline: none;
}
#supply-cart-info { text-align: center; color: var(--hint); font-size: 13px; padding: 14px 0 10px; }
.field-label { font-size: 13px; color: var(--hint); font-weight: 600; margin: 16px 0 8px; }
.delivery-btns { display: flex; gap: 10px; }
.delivery-btn {
  flex: 1; border: 2px solid var(--bg2); background: var(--bg2); color: var(--text);
  padding: 14px; border-radius: 14px; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.3;
}
.delivery-btn small { color: var(--hint); font-weight: 400; }
.delivery-btn.selected { border-color: var(--btn); background: var(--bg); }
#supply-date, #supply-phone {
  width: 100%; border: none; background: var(--bg2); border-radius: 12px;
  padding: 14px; font-size: 16px; color: var(--text); outline: none;
}
#supply-submit { margin-top: 20px; }
.done-icon { font-size: 56px; text-align: center; margin: 30px 0 10px; }
#supply-step-done h3 { text-align: center; color: var(--text); font-size: 19px; }
#supply-step-done .hint-text { text-align: center; margin-bottom: 20px; }

/* Отчёты */
.report-section {
  background: var(--bg2); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.rs-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rs-name { font-size: 14px; font-weight: 600; line-height: 1.3; padding-right: 8px; }
.rs-count { font-size: 12px; font-weight: 700; color: var(--orange); white-space: nowrap; }
.rs-count.ok { color: var(--green); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 64px; height: 64px; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.thumb-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: var(--red); color: #fff;
  font-size: 10px; cursor: pointer; line-height: 1;
}
.thumb-add {
  width: 64px; height: 64px; border: 2px dashed rgba(128,128,128,.4); border-radius: 10px;
  background: none; color: var(--hint); font-size: 24px; cursor: pointer;
}
#report-submit { margin-top: 14px; }
#report-progress { text-align: center; color: var(--hint); font-size: 13px; padding-top: 12px; }
#report-types .supplier-btns { margin-bottom: 4px; }
.list-item .sub { display: block; color: var(--orange); font-size: 12px; margin-top: 3px; }
.salary-cards { margin-bottom: 6px; }

/* Нижняя навигация */
#navbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: var(--bg2);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(128,128,128,.15);
}
.nav-btn {
  flex: 1; border: none; background: none; color: var(--hint);
  font-size: 17px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav-btn span { font-size: 9px; font-weight: 500; }
.nav-btn.active { color: var(--link); }

/* Тост */
#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
  max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
