:root {
  --bg: var(--tg-theme-secondary-bg-color, #17212b);
  --card: var(--tg-theme-bg-color, #232e3c);
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #708499);
  --accent: var(--tg-theme-button-color, #5288c1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: rgba(128, 128, 128, 0.14);
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.phone {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  background: var(--bg);
  padding-top: calc(14px + var(--tg-safe-area-inset-top, env(safe-area-inset-top, 44px)) + var(--tg-content-safe-area-inset-top, 36px));
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: calc(130px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}


.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.add-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 8px 15px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.days {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 2px 4px 10px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.days::-webkit-scrollbar {
  display: none; /* Chrome / Safari */
}
.day {
  flex: 0 0 calc(20% - 6.5px); /* Ровно 5 карточек на экран, остальные уходят в карусель */
  min-width: 58px;
  scroll-snap-align: center;
  text-align: center;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--card);
  font-size: 12px;
  color: var(--hint);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.day.active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  border-color: transparent;
  transform: scale(1.04);
}
.day b {
  display: block;
  font-size: 16px;
  margin-top: 2px;
  color: inherit;
}
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid #31b545;
  cursor: pointer;
}
.card.warn {
  border-left-color: #f59e0b;
}
.card.free {
  background: transparent;
  border: 1.5px dashed var(--border);
  text-align: center;
  color: var(--hint);
  padding: 13px;
  font-size: 14px;
  font-weight: 500;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.time {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}
.name {
  font-size: 15px;
  font-weight: 600;
}
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  background: rgba(49, 181, 69, 0.14);
  color: #31b545;
}
.badge.warn {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
}
.note {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 10px;
  line-height: 1.35;
}

.btns {
  display: flex;
  gap: 6px;
}
.b {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  background: rgba(128, 128, 128, 0.12);
  color: var(--text);
  cursor: pointer;
}
.b.ok {
  background: #31b545;
  color: #fff;
}
.b.burn {
  background: #e53935;
  color: #fff;
}

.nav {
  position: fixed;
  bottom: calc(36px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  left: 16px;
  right: 16px;
  background: var(--card);
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 5;
}
.nav div {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--hint);
  font-weight: 600;
  padding: 10px 8px;
  border-radius: 17px;
  cursor: pointer;
  transition: 0.18s ease;
}
.nav div.act {
  background: var(--accent);
  color: var(--accent-text);
}
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
  align-items: flex-end;
  justify-content: center;
}
.overlay.open {
  display: flex;
}
.sheet {
  width: 100%;
  max-width: 500px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(22px + env(safe-area-inset-bottom, 0px));
  max-height: 92vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.handle {
  width: 38px;
  height: 4px;
  background: var(--hint);
  opacity: 0.4;
  border-radius: 4px;
  margin: 0 auto 12px;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 700;
}
.close-btn {
  background: rgba(128, 128, 128, 0.15);
  border: none;
  color: var(--hint);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}

.client-box, .time-row, .move-summary, .logs-box {
  background: var(--bg);
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.move-summary {
  border-left: 3px solid var(--accent);
}
.alert-note {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(229, 57, 53, 0.14);
  color: #ef5350;
  font-size: 12px;
}
.sec-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--hint);
  font-weight: 600;
  margin: 12px 0 6px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.st-btn {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.st-btn.selected {
  border-color: #31b545;
  background: rgba(49, 181, 69, 0.15);
  color: #31b545;
}
.st-btn.selected-warn {
  border-color: #e53935;
  background: rgba(229, 57, 53, 0.15);
  color: #ef5350;
}

.time-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.move-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

textarea, .dark-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 11px;
  font-size: 14px;
  outline: none;
  user-select: text;
}
textarea {
  resize: none;
  height: 68px;
  font-size: 13px;
}
.prev-hint {
  font-size: 11px;
  color: var(--accent);
  margin-top: 5px;
}

.footer-btns {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.save-btn {
  flex: 2;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.del-btn {
  flex: 1;
  background: rgba(229, 57, 53, 0.14);
  color: #ef5350;
  border: none;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.date-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.d-chip {
  flex: 1;
  min-width: 72px;
  text-align: center;
  padding: 8px 6px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--hint);
  font-size: 12px;
  cursor: pointer;
}
.d-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}
.d-chip b {
  display: block;
  font-size: 13px;
  margin-top: 2px;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.slot-btn {
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.slot-btn.busy {
  opacity: 0.35;
  text-decoration: line-through;
  cursor: not-allowed;
}
.slot-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.msg-links {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.msg-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.msg-tg {
  background: var(--accent);
  color: var(--accent-text);
}
.msg-wa {
  background: #25d366;
  color: #fff;
}

.logs-box {
  max-height: 210px;
  overflow-y: auto;
  padding: 8px 10px;
}
.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.log-item:last-child {
  border-bottom: none;
}
/* Применяется ТОЛЬКО на компьютере (где есть мышь/трекпад) */
@media (pointer: fine) {
  .phone {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 640px;
    min-height: 850px;
    margin: 0 auto;
    padding-top: 20px;
    padding-bottom: 18px;
  }
  .nav {
    position: sticky;
    bottom: 18px;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: 100%;
    margin-top: auto;
  }
  .overlay {
    align-items: center;
    padding: 20px;
  }
  .sheet {
    max-width: 520px;
    max-height: 850px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    padding: 18px 20px 22px;
  }
  .handle {
    display: none;
  }
}





