:root {
  --bg: #0f1115;
  --card: #191c22;
  --card2: #21252d;
  --line: #2a2f38;
  --text: #e9ecf1;
  --muted: #8b93a1;
  --accent: #ff8a3d;
  --accent-dim: #4a2f1c;
  --green: #35c46b;
  --red: #f2545b;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  overscroll-behavior-y: none;
}

body { min-height: 100vh; }

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 14px calc(84px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 2px 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(var(--bg) 70%, rgba(15, 17, 21, 0));
}

.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.me {
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 22px 2px 10px;
}

h2:first-child { margin-top: 6px; }

/* ---------- карточки инструмента ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.15s ease;
}

.tool:active { transform: scale(0.975); }
.tool.taken { opacity: 0.72; }

.tool .pic {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--card2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
}

.tool .pic .ico {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool .pic img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tool .body { padding: 10px 11px 12px; }

.tool .name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 35px;
}

.tool .meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}
.dot.busy { background: var(--accent); }
.dot.late { background: var(--red); }

/* ---------- строки / доска ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.person {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.person .who { font-weight: 650; font-size: 15px; }
.person .count { color: var(--muted); font-size: 12.5px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.row:first-of-type { border-top: none; }

.row .t { font-size: 14.5px; }
.row .s { font-size: 12.5px; color: var(--muted); }
.row .s.late { color: var(--red); }

.pill {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--muted);
  white-space: nowrap;
}

.pill.late { background: rgba(242, 84, 91, 0.15); color: var(--red); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 34px 10px;
  font-size: 14px;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 650;
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  width: 100%;
}

.btn.primary { background: var(--accent); color: #1b1208; }
.btn.danger { background: rgba(242, 84, 91, 0.16); color: var(--red); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.sm { padding: 9px 12px; font-size: 13px; border-radius: 11px; width: auto; }
.btn:active { filter: brightness(0.92); }

/* ---------- отчёт ---------- */
.rep { margin-bottom: 14px; }
.rep .head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 7px;
}
.rep .sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.bar {
  height: 8px;
  border-radius: 5px;
  background: var(--card2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), #ffb37a);
}
.bar.late > i { background: linear-gradient(90deg, var(--red), #ff8b91); }

/* ---------- вкладки ---------- */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 10;
}

.tabs button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 62px;
}

.tabs button .ic { font-size: 19px; line-height: 1; }
.tabs button.on { color: var(--text); background: var(--card); }
.tabs button.on .ic { filter: none; }

/* ---------- модальное окно ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fade 0.15s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.2s ease;
}

@keyframes up { from { transform: translateY(20px); opacity: 0.6; } to { transform: none; opacity: 1; } }

.sheet h3 { margin: 0 0 6px; font-size: 18px; }
.sheet p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.sheet .actions { display: grid; gap: 8px; }

.field {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 16px;
  margin-bottom: 10px;
}

.field:focus { outline: none; border-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--green);
  color: #04160a;
  font-weight: 650;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 60;
  animation: fade 0.15s ease;
  max-width: 88%;
  text-align: center;
}

.toast.err { background: var(--red); color: #fff; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 4px 0 6px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 12px;
  text-align: center;
}

.stat b { display: block; font-size: 22px; font-weight: 700; }
.stat span { font-size: 11.5px; color: var(--muted); }

.admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.admin-row:first-of-type { border-top: none; }
.admin-row .n { flex: 1; min-width: 0; }
.admin-row .n b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .n span { font-size: 12px; color: var(--muted); }
.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card2);
  border-radius: 10px;
  padding: 8px 9px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
}
.icon-btn:active { filter: brightness(0.9); }

.icon-btn.num {
  font-weight: 700;
  font-size: 13px;
  min-width: 30px;
}

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.login { padding-top: 22vh; text-align: center; }
.login .big { font-size: 44px; }

.login-title {
  font-size: 21px;
  font-weight: 700;
  margin: 12px 0 10px;
  letter-spacing: -0.01em;
}

.gate-help {
  margin: 18px auto 0;
  max-width: 330px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.login .reg {
  margin: 20px auto 0;
  max-width: 330px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login .reg .field { text-align: center; }

.search { margin-bottom: 10px; }

.chips {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.chip.on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.preview {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 14px;
  background: var(--card2);
}

.preview-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 70px;
  height: 130px;
  border-radius: 14px;
  background: var(--card2);
  margin-bottom: 14px;
}

.btn.link {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 16px;
}
