* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2E7D32;
  --primary-dark: #1B5E20;
  --primary-light: #E8F5E9;
  --bg: #F4F6F4;
  --card: #FFFFFF;
  --text: #212121;
  --muted: #757575;
  --border: #E0E0E0;
  --danger: #D32F2F;
  --warn: #F57F17;
  --info: #1565C0;
  --shadow: 0 1px 3px rgba(0,0,0,.12);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---------- Экраны ---------- */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content { flex: 1; padding: 14px; overflow-y: auto; }

.icon-btn {
  background: transparent; border: none; color: #fff;
  font-size: 20px; width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }
.icon-btn.dark { color: var(--text); }
.primary-text { color: #fff; font-size: 26px; font-weight: 300; }

.btn {
  border: none; border-radius: 8px; padding: 12px 16px;
  cursor: pointer; font-weight: 500; transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); width: 100%; margin-top: 8px; }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }
.btn.danger { background: var(--danger); color: #fff; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Вход ---------- */
#login-screen { display: none; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--primary-dark), #388E3C); }
#login-screen.active { display: flex; }
.login-box {
  background: #fff; border-radius: 16px; padding: 30px 26px;
  width: min(92vw, 380px); box-shadow: 0 8px 30px rgba(0,0,0,.25);
  text-align: center;
}
.logo-wrap { font-size: 44px; }
.logo { font-size: 24px; color: var(--primary-dark); letter-spacing: 1px; }
.subtitle { color: var(--muted); margin: 4px 0 18px; font-size: 13px; }
.login-box input {
  display: block; width: 100%; margin-bottom: 10px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  outline: none; font-size: 15px;
}
.login-box input:focus { border-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 4px 0 14px; }
.error { color: var(--danger); min-height: 20px; margin-top: 10px; font-size: 13px; }

/* ---------- Карточки списков ---------- */
.list-cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border-radius: 12px; padding: 14px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.card .meta span { white-space: nowrap; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge.active { background: var(--primary-light); color: var(--primary); }
.badge.completed { background: #E3F2FD; color: var(--info); }
.badge.archived { background: #EEEEEE; color: var(--muted); }

/* ---------- Дровер ---------- */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 82%;
  max-width: 300px; background: #fff; z-index: 100;
  transform: translateX(-105%); transition: transform .25s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 14px; background: var(--primary); color: #fff;
}
.drawer-nav { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; padding: 12px 10px; border-radius: 10px;
  font-size: 16px; cursor: pointer; text-align: left; color: var(--text);
}
.nav-item:hover { background: var(--primary-light); }
.nav-item.admin-only { display: none; }

/* ---------- Вкладки проекта ---------- */
.project-tabs { display: flex; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 58px; z-index: 40; }
.tab { flex: 1; padding: 12px; background: none; border: none; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; flex: 1; padding: 12px; overflow-y: auto; }
.tab-content.active { display: block; }
.tab-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.info-box { background: var(--card); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 12px; font-size: 13.5px; width: 100%; }
.info-box .row { display: flex; gap: 8px; padding: 2px 0; }
.info-box .row b { min-width: 120px; color: var(--muted); font-weight: 500; }

/* ---------- Смена ---------- */
.session-info-bar {
  background: var(--card); padding: 10px 14px; font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 6px 16px; box-shadow: var(--shadow);
  border-bottom: 1px solid var(--border);
}
.session-info-bar .field { color: var(--muted); }
.session-info-bar .field b { color: var(--text); font-weight: 600; }

.session-sections { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.section { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--primary-light); font-weight: 600; color: var(--primary-dark);
}
.list-inline { display: flex; gap: 10px; padding: 12px; overflow-x: auto; }
.chip-station {
  min-width: 130px; background: #fff; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px; cursor: pointer;
}
.chip-station.selected { border-color: var(--primary); background: var(--primary-light); }
.chip-station .cs-name { font-weight: 600; font-size: 14px; }
.chip-station .cs-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Таблица измерений ---------- */
table.journal { width: 100%; border-collapse: collapse; font-size: 13px; }
table.journal th, table.journal td { padding: 8px 8px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.journal th { background: #FAFAFA; color: var(--muted); font-size: 12px; white-space: nowrap; }
table.journal tr { cursor: pointer; }
table.journal tr:hover { background: var(--primary-light); }
table.journal td.num { white-space: nowrap; }
.muted { color: var(--muted); }
.empty-hint { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.row-actions { display: inline-flex; gap: 14px; font-size: 16px; }
.row-actions button { background: none; border: none; cursor: pointer; font-size: 16px; padding: 2px 4px; }

/* ---------- Модалка ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0;
  padding: 20px 18px 24px;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal-box { border-radius: 16px; }
}
.modal-box h2 { font-size: 18px; margin-bottom: 14px; color: var(--primary-dark); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 2px; font-weight: 500; }
input.f, select.f, textarea.f {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; outline: none; margin-bottom: 12px; background: #fff;
}
input.f:focus, select.f:focus, textarea.f:focus { border-color: var(--primary); }
textarea.f { min-height: 64px; resize: vertical; }
.modal-footer { display: flex; gap: 10px; margin-top: 8px; }
.modal-footer .btn { flex: 1; }

/* ---------- Фото ---------- */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.photo-item { position: relative; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; background: #eee; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-item .del-photo {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
  background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 50%;
  font-size: 12px; cursor: pointer;
}
.photo-item.doc { background: var(--primary-light); display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 12px; text-align: center; padding: 6px; word-break: break-all; }
.upload-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Карта ---------- */
#project-map { height: calc(100vh - 140px); border-radius: 12px; overflow: hidden; }

/* ---------- Админ ---------- */
.admin-section { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.admin-section h3 { margin-bottom: 10px; font-size: 15px; color: var(--primary-dark); }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pending-row .btn { width: auto; padding: 6px 12px; font-size: 12px; border-radius: 6px; }

/* ---------- Мобильная таблица измерений ---------- */
.measure-card { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.measure-card:hover { background: var(--primary-light); }
.measure-card .mc-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.measure-card .mc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-top: 6px; font-size: 12.5px; color: var(--text); }
.measure-card .mc-grid .k { color: var(--muted); }

@media (min-width: 820px) {
  .measure-cards-mobile { display: none; }
  table.journal { display: table; }
}
@media (max-width: 819px) {
  table.journal { display: none; }
}