:root {
  --bg: #0e1a22;
  --panel: #17212b;
  --panel-2: #1c2b39;
  --accent: #2ea6a0;
  --accent-dim: #1f6f6a;
  --bubble-out: #2b5f5a;
  --bubble-in: #202f3d;
  --text: #e7edf1;
  --muted: #7d94a3;
  --danger: #d9705a;
  --warn: #d9b45a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ---- login ---- */
#loginScreen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--panel);
  font-size: 30px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: 0.2px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.4; }
.muted.small { font-size: 12px; margin-top: 14px; }

.user-list { margin: 20px 0 8px; display: flex; flex-direction: column; gap: 8px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid #223140;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.user-row:hover { background: var(--panel-2); }
.user-row .avatar { width: 36px; height: 36px; font-size: 15px; }
.user-row .u-meta { flex: 1; }
.user-row .u-name { font-weight: 600; }
.user-row .u-sub { font-size: 12px; color: var(--muted); }
.user-row .u-del { color: var(--muted); background: none; border: none; font-size: 16px; cursor: pointer; padding: 4px; }
.user-row .u-del:hover { color: var(--danger); }

#loginForm, #profileSetupForm { text-align: left; margin-top: 18px; }
#loginForm label, #profileSetupForm label { display:block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
#loginForm input, #profileSetupForm input {
  width: 100%; background: var(--panel-2); border: 1px solid #223140;
  border-radius: 8px; color: var(--text); padding: 9px 10px; font-size: 14px; font-family: inherit;
}
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 1em; }

.auth-spinner { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 24px; }
.spinner-big {
  width: 40px; height: 40px;
  border: 3px solid rgba(46,166,160,0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: fc-spin 0.8s linear infinite;
}
.spinner-small {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(14,26,34,0.35);
  border-top-color: var(--panel);
  border-radius: 50%;
  animation: fc-spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes fc-spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 8px;
}

/* ---- app ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px;
  background: var(--panel);
  border-bottom: 1px solid #182129;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-left > div:last-child { min-width: 0; }
.topbar-title, .topbar-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#appScreen:not(.view-chat) .chat-only { display: none; }
/* дата работы в шапке */
.topbar-date { display: flex; align-items: center; gap: 5px; flex-shrink: 0; margin: 0 4px; }
.topbar-date.warn #shiftsDateInput { border-color: var(--danger); color: var(--danger); font-weight: 700; background: #2a1313; }
.topbar-seg {
  background: none; border: 1px solid #223140; border-radius: 8px; color: var(--accent);
  font-size: 12px; padding: 4px 6px; cursor: pointer;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-dim); color: #dff5f2;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-sub { font-size: 12px; color: var(--muted); }
.topbar-sub.online { color: var(--accent); }
.topbar-right { display: flex; gap: 2px; flex-shrink: 0; }
.topbar-right button {
  background: none; border: none; color: var(--muted);
  font-size: 18px; width: 30px; height: 34px; border-radius: 8px; cursor: pointer; padding: 0;
}
.topbar-right button:hover { background: var(--panel-2); color: var(--text); }

/* Отдельная цветовая тема для вкладки "Смены" */
#tabShifts {
  --accent: #d98a3d;
  --accent-dim: #a3651f;
  --bubble-out: #5c4426;
  --bubble-in: #2a2118;
  --panel-2: #241c14;
}

.search-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border-bottom: 1px solid #182129;
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  background: var(--panel-2); border: 1px solid #223140;
  border-radius: 8px; color: var(--text); padding: 7px 10px; font-size: 14px; font-family: inherit;
}
.search-bar input:focus { outline: none; border-color: var(--accent-dim); }
.search-count { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 56px; text-align: center; }
.search-bar button {
  background: none; border: none; color: var(--muted);
  font-size: 16px; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; flex-shrink: 0;
}
.search-bar button:hover { background: var(--panel-2); color: var(--text); }

.bubble.search-match { box-shadow: 0 0 0 2px var(--warn); }
.bubble.search-match-current { box-shadow: 0 0 0 2px var(--accent); }
mark.search-hl {
  background: #ffe066;
  color: #1a1a1a;
  border-radius: 3px;
  padding: 0 1px;
}

.tab-page {
  flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}

/* Режимы вкладки: сводка во весь экран (по умолчанию) или чат. */
#tabShifts.mode-summary #shiftsHistory { display: none; }
#tabShifts.mode-chat #dayPanel,
#tabShifts.mode-chat #shiftsReplyBox { display: none; }
/* В режиме сводки чата не видно — ответ на отправленное показываем здесь,
   над чипами: иначе ошибку или предупреждение никто бы не увидел. */
.reply-box {
  flex-shrink: 0; margin: 6px 10px 0; padding: 8px 10px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid #223140; font-size: 13px;
  max-height: 30vh; overflow-y: auto; white-space: pre-wrap; position: relative;
}
.reply-box-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 6px; }
.reply-box-actions button { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.reply-box-item + .reply-box-item { border-top: 1px solid #223140; margin-top: 6px; padding-top: 6px; }
#tabShifts.mode-summary #dayPanel { flex: 1; min-height: 0; overflow-y: auto; border-bottom: none; }
#tabShifts.mode-summary .day-panel-body { max-height: none; overflow: visible; padding-bottom: 16px; }

/* Сводка дня под плашкой даты: по каждому сотруднику итог и интервалы. */
.day-panel { background: var(--panel); border-bottom: 1px solid #182129; flex-shrink: 0; font-size: 13px; }
.day-panel-body { max-height: 40vh; overflow-y: auto; padding: 2px 12px 6px; }
/* длительность — слева от полосы, в пустом месте столбца времени между метками:
   часы и минуты в две строки ("2ч" / "45м"), прижато к полосе */
/* пауза — не полоса, а тонкая пунктирная линия: разрыв в работе видно сразу */
/* идущая смена выцветает книзу — конец ещё не наступил */
/* стоп без начала — красная штриховка, ни с каким проектом не спутать */

/* Нижняя панель действий над отрезком ленты */
/* Панель снизу, а не окно: фон прозрачный и не перехватывает касания, так что
   шкала остаётся видимой и рабочей, пока правишь запись. */
.modal.sheet { align-items: flex-end; padding: 0; background: none; pointer-events: none; }
.modal.sheet .modal-card { pointer-events: auto; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45); }
/* окно всегда влезает в экран: карточка не выше экрана, длинный список
   проектов прокручивается внутри себя, кнопки снизу остаются на виду */
.modal.sheet .modal-card {
  border-radius: 16px 16px 0 0; max-width: 560px; padding-bottom: env(safe-area-inset-bottom, 0px);
  max-height: 38dvh; display: flex; flex-direction: column; border-top: 1px solid #2c3b48;
}
.modal.sheet .modal-body { padding: 8px 12px 12px; }
.modal.sheet .modal-header { padding: 6px 12px; }
.modal.sheet .modal-body { flex: 1; min-height: 0; overflow-y: auto; }
.modal.sheet h2 { font-size: 15px; }
.sheet-btn {
  display: block; width: 100%; text-align: left; margin: 6px 0; padding: 12px;
  background: var(--panel-2); color: var(--text); border: 1px solid #223140; border-radius: 10px; font-size: 16px; cursor: pointer;
}
.sheet-btn.danger { color: var(--danger); }
.sheet-btn.primary { background: var(--accent); color: #111; border-color: var(--accent); text-align: center; font-weight: 600; }
/* шапка окна: закрыть слева, "Сохранить" справа */
.sheet-header { align-items: center; gap: 8px; }
.sheet-title { flex: 1; }
.sheet-save {
  background: var(--accent); color: var(--panel); border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.sheet-save:disabled { opacity: 0.4; }
.sheet-btn:disabled { opacity: 0.45; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .sheet-btn { text-align: center; }
.sheet-label { color: var(--muted); font-size: 13px; margin: 10px 0 4px; }
.sheet-time-row { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
/* список часов/минут — вертикально над полем времени */
.time-drop {
  position: fixed; transform: translateX(-50%);
  width: 168px; z-index: 1200; display: flex; gap: 4px;
  background: var(--panel-2); border: 1px solid #33485a; border-radius: 12px; padding: 4px;
}
.time-col { flex: 1; overflow-y: auto; scrollbar-width: none; }
.time-col::-webkit-scrollbar { width: 0; }
.time-opt {
  display: block; width: 100%; padding: 8px; background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; border-radius: 8px;
}
.time-opt.on { background: var(--accent); color: var(--panel); font-weight: 700; }
/* Поле времени — главный элемент формы: крупнее и цветом, чтобы не путалось
   с чипами времени над ним. .modal-body input задаёт width:100% — перебиваем. */
/* время как две кнопки: часы и минуты */
.sheet-time .time-part {
  background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0 2px;
}
.sheet-time .time-colon { opacity: 0.7; }
.modal-body .sheet-time, .modal-body input.sheet-time {
  font-size: 24px; font-weight: 700; letter-spacing: 1px; padding: 6px 12px;
  background: var(--panel-2); color: #e8a33e;
  border: 2px solid #e8a33e; border-radius: 10px;
  flex: none; text-align: center; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center;
}
.modal-body input.sheet-time:focus { outline: none; box-shadow: 0 0 0 3px rgba(232, 163, 62, 0.25); }
.sheet-rel { color: var(--muted); font-size: 13px; }
/* Оба ряда чипов времени (точные времена над полем и сдвиги под ним) —
   строго одна строка с прокруткой вбок. */
.sheet-chips.sheet-time-chips, .sheet-chips.sheet-nudge {
  display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; max-width: 100%;
}
/* Полосы прокрутки у рядов чипов не показываем: они съедают высоту и мелькают */
.sheet-chips, .tla-btns, .bd, .day-panel { scrollbar-width: none; }
.sheet-chips::-webkit-scrollbar, .tla-btns::-webkit-scrollbar { width: 0; height: 0; }
.sheet-nudge { margin-top: 6px; }
.sheet-time-chips .chip, .sheet-nudge .chip, .sheet-proj-chips .chip { flex: 0 0 auto; white-space: nowrap; font-size: 14px; padding: 6px 10px; }
.sheet-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet-chips .chip { font-size: 16px; }
.sheet-emp-chips { margin-bottom: 4px; flex-wrap: nowrap; overflow-x: auto; }
.sheet-chips.sheet-time-chips { margin-bottom: 6px; padding-bottom: 2px; }
/* переключатель СТОП / ПРОЕКТ */
.seg-switch { display: flex; gap: 0; margin: 10px 0 6px; border: 1px solid #223140; border-radius: 10px; overflow: hidden; }
.seg-switch .seg {
  flex: 1; padding: 7px; background: var(--panel-2); color: var(--muted);
  border: none; font: inherit; font-weight: 600; cursor: pointer;
}
.seg-switch .seg.seg-on { background: var(--accent); color: var(--panel); }
.seg-switch .seg.stop.seg-on { background: var(--danger); color: #1a0f0c; }
.sheet-search {
  width: 100%; box-sizing: border-box; margin-bottom: 6px; padding: 8px 10px; font-size: 16px;
  background: var(--panel-2); color: var(--text); border: 1px solid #223140; border-radius: 10px;
}
/* Чипы проектов — тоже одна строка с прокруткой вбок (класс задан вместе с
   .sheet-chips, поэтому селектор из двух классов: иначе перенос переопределял) */
.sheet-chips.sheet-proj-chips { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.chip.chip-new { border-color: var(--accent); color: var(--accent); }
.chip.chip-stop { border-color: var(--danger); color: var(--danger); }
.chip.chip-stop.chip-selected { background: var(--danger); color: #fff; }
.sheet-preview { margin: 12px 0 6px; font-size: 14px; line-height: 1.5; }
.sheet-preview.err { color: var(--danger); }
.sheet-preview:empty { margin: 0; }
.dp-empty, .dp-warn { color: var(--muted); padding: 6px 0; }
/* сотрудник без записей за день — приглушён, чтобы работавшие выделялись */
.bd-head.empty { color: var(--muted); font-weight: 500; }
.dp-warn { color: var(--danger); }
#shiftsDateInput {
  background: var(--panel-2); border: 1px solid #223140;
  border-radius: 8px; color: var(--text); padding: 4px 6px; font-size: 13px;
  color-scheme: dark; font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.shifts-unclosed-warn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: #e0443a; color: #fff; font-weight: 700; font-size: 13px; line-height: 1;
  flex-shrink: 0;
}
.shifts-unclosed-warn.short { background: #c46a12; }

/* Прижат к верху, а не по центру: когда закрывается клавиатура (тап по
   кнопке из поля причины), центрированное окно съезжало бы между нажатием
   и отпусканием пальца, и тап попадал бы в соседнюю кнопку или другой день. */
.cal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.cal-box {
  background: var(--panel); border: 1px solid #223140; border-radius: 12px;
  padding: 12px; width: min(320px, calc(100vw - 24px));
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 600; }
.cal-nav {
  background: var(--panel-2); border: none; color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; font-size: 20px; cursor: pointer;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow span { text-align: center; font-size: 11px; opacity: 0.6; padding-bottom: 2px; }
.cal-day {
  aspect-ratio: 1; border: none; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.cal-day.unclosed { background: #b3261e; color: #fff; font-weight: 600; }
.cal-day.short { background: #c46a12; color: #fff; font-weight: 600; }
.cal-day.acked { box-shadow: inset 0 0 0 2px #3f7f4f; }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.cal-day.detail { outline: 2px solid var(--text); outline-offset: -2px; }
.cal-legend { margin-top: 8px; font-size: 12px; opacity: 0.8; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cal-legend .lg-unclosed { background: #b3261e; }
.cal-legend .lg-short { background: #c46a12; }
.cal-legend .lg-acked { box-shadow: inset 0 0 0 2px #3f7f4f; }
.cal-box { max-height: calc(100dvh - 24px); overflow-y: auto; }
.cal-detail { margin-top: 10px; border-top: 1px solid #223140; padding-top: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.cal-detail-title { font-weight: 600; }
.cal-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-row span { flex: 1; min-width: 0; }
.cal-act {
  background: var(--panel-2); border: 1px solid #223140; color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.cal-act:disabled { opacity: 0.5; }
.cal-act.wide { width: 100%; padding: 8px; }
.cal-act.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); font-weight: 600; }
.cal-reason {
  width: 100%; box-sizing: border-box; background: var(--panel-2); border: 1px solid #223140;
  border-radius: 8px; color: var(--text); padding: 6px 8px; font-size: 13px;
}
.cal-err { color: var(--danger); font-size: 12px; }
.cal-err:empty { display: none; }

.chips-panel {
  display: flex; flex-direction: column; gap: 1.2px;
  padding: 10px 12px 4px;
  background: var(--panel);
  border-top: 1px solid #182129;
  flex-shrink: 0;
}
.chips-row {
  display: flex; gap: 1.8px; overflow-x: auto; padding-bottom: 1.6px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--panel-2); border: 1.5px solid #223140; color: var(--text);
  border-radius: 21px; padding: 4px 10px; font-size: 19px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .08s;
}
.chip:active { transform: scale(0.96); }
.chip.chip-now { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.chip-selected {
  background: var(--accent); color: var(--panel); border-color: var(--accent); font-weight: 700;
  box-shadow: 0 0 0 2px rgba(46,166,160,0.35);
}

.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid #223140; border-radius: 12px;
  padding: 14px;
}
.settings-row-title { font-size: 14px; font-weight: 600; }
.settings-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.history {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bubble-row { display: flex; margin: 3px 0; }
.bubble-row.out { justify-content: flex-end; }
.bubble-row.in { justify-content: flex-start; }

.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.bubble.out {
  background: var(--bubble-out);
  border-bottom-right-radius: 4px;
}
.bubble.in {
  background: var(--bubble-in);
  border-bottom-left-radius: 4px;
}
.bubble.sys { background: transparent; color: var(--muted); font-size: 12.5px; text-align: center; margin: 6px auto; }

.bubble .meta {
  display: flex; align-items: center; gap: 4px;
  margin-top: 4px; font-size: 11px; color: rgba(231,237,241,0.55);
  justify-content: flex-end;
}
.comment-btn {
  margin-top: 6px;
  background: rgba(46,166,160,0.15);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.comment-btn:hover { background: rgba(46,166,160,0.28); }

.bubble a { color: #8fd8d2; text-decoration: underline; }
.bubble b, .bubble strong { color: #fff; }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px;
  background: var(--panel);
  border-top: 1px solid #182129;
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  resize: none;
  background: var(--panel-2);
  border: 1px solid #223140;
  border-radius: 18px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
  max-height: 140px;
  font-family: inherit;
}
.composer textarea:focus { outline: none; border-color: var(--accent-dim); }
.composer button {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); border: none; color: var(--panel);
  font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.composer button:active { transform: scale(0.94); }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
}
.modal-card {
  background: var(--panel); border-radius: 16px;
  width: 100%; max-width: 460px; max-height: 82vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid #223140;
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-header button { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-body { padding: 14px 16px; overflow-y: auto; font-size: 14px; line-height: 1.6; }
.modal-body label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.modal-body input, .modal-body textarea {
  width: 100%; background: var(--panel-2); border: 1px solid #223140;
  border-radius: 8px; color: var(--text); padding: 8px 10px; font-size: 14px; font-family: inherit;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
.primary-btn {
  margin-top: 16px; width: 100%; padding: 10px; border: none; border-radius: 10px;
  background: var(--accent); color: var(--panel); font-weight: 600; font-size: 14px; cursor: pointer;
}

/* ---------- Общая шкала дня (телефон боком / широкий экран) ---------- */
/* Прокрутка — у самой панели (в обе стороны), не у .bd: иначе шапка с
   именами "прилипала" бы к .bd и уезжала вместе с содержимым. */
.bd { --bd-axis: 44px; padding-bottom: 8px; width: max-content; min-width: 100%; }
#tabShifts.mode-summary #dayPanel { overflow: auto; }
.bd-heads {
  display: grid; grid-template-columns: var(--bd-axis) var(--bd-grid);
  position: sticky; top: 0; z-index: 3; background: var(--panel); padding: 4px 0;
  border-bottom: 1px solid #3a4d5e;
}
.bd-head { font-weight: 600; font-size: 13px; line-height: 15px; padding: 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bd-head b { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.bd-body { position: relative; margin-top: 8px; } /* отступ — чтобы первая метка не пряталась под шапкой */
/* тонкие линии часов через всю ширину, получасы — ещё бледнее */
.bd-line { position: absolute; left: 0; border-top: 1px solid #3a4d5e; }
.bd-line.half { border-top-style: dotted; border-top-color: #1c2833; }
.bd-line span {
  position: absolute; left: 0; top: -9px; height: 18px; width: calc(var(--bd-axis) - 6px);
  display: flex; align-items: center; justify-content: flex-end;
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--panel); padding-right: 2px;
}
.bd-line.draft { border-top: 2px dashed var(--accent); z-index: 2; }
.bd-line.draft span { color: var(--accent); font-weight: 700; }
.bd-now { position: absolute; left: var(--bd-axis); right: 0; border-top: 2px solid var(--accent); z-index: 1; }
.bd-now span {
  position: absolute; left: calc(var(--bd-axis) * -1); top: -8px; width: calc(var(--bd-axis) - 6px);
  text-align: right; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--panel); padding-right: 2px;
}
.bd-cols {
  position: absolute; top: 0; bottom: 0; left: var(--bd-axis); right: 0;
  display: grid; grid-template-columns: var(--bd-grid);
}
.bd-col { position: relative; }
/* блоки — сплошная заливка цветом проекта, без рамок; тёмный текст читается
   на всех цветах палитры */
.bd-seg {
  position: absolute; left: 3px; right: 3px; border-radius: 5px; overflow: hidden; cursor: pointer; z-index: 1;
  background: var(--tl-color);
  padding: 1px 5px; font-size: 11px; line-height: 13px; color: rgba(0, 0, 0, 0.85);
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
/* выделенный блок и его метки времени */
.bd-seg.sel { outline: 2px solid #fff; outline-offset: -2px; }
/* во время правки линии и подписи приглушаем вместе с блоками */
.bd-line.dim { border-top-color: #22303c; }
.bd-line.dim span { opacity: 0.4; }
.bd-line.hot { border-top-color: #fff; border-top-width: 2px; }
/* участок до колонки: линия обычная, подпись — белая и жирная */
.bd-line.hot-label { border-top-color: #fff; border-top-width: 2px; }
.bd-line.hot-label span, .bd-line.hot span { color: #fff !important; font-weight: 700; }
.bd-line.hot span { color: #fff; font-weight: 700; top: -17px; height: 34px; }
.bd-line.hot-label span { top: -17px; height: 34px; }
/* черновик новой записи: пока не выбран проект, он только на экране */
.bd-draft-grip {
  position: absolute; left: 0; right: 0; top: -6px; height: 14px;
  border-top: 3px solid var(--accent); border-radius: 3px;
}
/* Гасим яркостью, а не прозрачностью: при opacity сквозь блок просвечивали
   линии времени, которые должны оставаться под ним. */
.bd-seg.dim, .bd-pause.dim { filter: brightness(0.45) saturate(0.75); }
/* черновик всегда тёмный, цвет проекта — в рамке и подписи */
.bd-draft.colored { border-color: var(--tl-color); color: var(--tl-color); }
.bd-draft {
  position: absolute; left: 3px; right: 3px; z-index: 1; border-radius: 5px;
  border: 2px dashed var(--accent); color: var(--accent); font-size: 10px; line-height: 11px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 0 3px; overflow: hidden; background: #0e1a22;
}
/* панель действий над выделенным блоком — внизу экрана */
.tl-actions {
  flex-shrink: 0; background: var(--panel); border-top: 1px solid #2c3b48;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 6px;
}
.tla-title { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tla-btns { display: flex; gap: 6px; overflow-x: auto; }
.tla-btn {
  flex: 0 0 auto; white-space: nowrap; background: var(--panel-2); color: var(--text);
  border: 1px solid #223140; border-radius: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.tla-btn.danger { color: var(--danger); }
/* окно во время сохранения */
.modal-card.sheet-busy { position: relative; pointer-events: none; }
.modal-card.sheet-busy::after {
  content: ""; position: absolute; inset: 0; background: rgba(14, 26, 34, 0.45);
  border-radius: inherit;
}
.bd-projedit { text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.bd-edit {
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-height: 34px; padding-right: 4px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.bd-seg.jt { border-top-left-radius: 0; border-top-right-radius: 0; }
.bd-seg.jb { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* пауза — слабо-серая заливка без рамок, стыкуется с отрезками без зазора */
.bd-pause {
  position: absolute; left: 3px; right: 3px;
  /* Штриховка поверх непрозрачного фона: линии времени сквозь паузу не видны,
     и она не путается ни с блоками работы, ни с сеткой. */
  background-color: var(--panel);
  /* штриховка и боковые границы — один и тот же сплошной цвет, без прозрачности */
  background-image: repeating-linear-gradient(45deg, #2d3d4b 0 5px, transparent 5px 10px);
  border-left: 5px solid #2d3d4b; border-right: 5px solid #2d3d4b;
  color: var(--muted); font-size: 11px; line-height: 12px;
  padding: 0 5px; overflow: hidden; box-sizing: border-box; text-align: center;
  display: flex; align-items: center; justify-content: center;
}
.bd-pause.tl-tap { cursor: pointer; }
.bd-add.stop { color: var(--danger); }
.bd-add.tall { height: 40px; font-size: 20px; } /* завершить / сменить проект — крупная цель для пальца */
/* Лаконичный "+" без рамки и фона. На цветных блоках (штриховка стопа) —
   с лёгкой подложкой, иначе не читается. */
.bd-add {
  position: absolute; left: 3px; right: 3px; height: 20px; z-index: 2; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #8aa0b0; font-size: 18px; border-radius: 5px;
  background: rgba(23, 33, 43, 0.75);
}
/* пустое место над первым и под последним блоком — вся область тапается */
.bd-zone {
  position: absolute; left: 3px; right: 3px; z-index: 1; cursor: pointer;
  display: flex; justify-content: center;
  color: #56697a; font-size: 20px; line-height: 1; /* незаметный серый "+" */
}
.bd-zone.top { align-items: flex-end; padding-bottom: 2px; }
.bd-zone.bottom { align-items: flex-start; padding-top: 2px; }
.bd-zone:active { background: rgba(46, 166, 160, 0.10); border-radius: 6px; }
.bd-seg.open { background: linear-gradient(to bottom, var(--tl-color), transparent); }
.bd-seg.pending {
  background: repeating-linear-gradient(135deg, var(--danger) 0 4px, transparent 4px 7px);
  color: var(--danger); font-weight: 700; text-align: center; padding: 0;
}
.bd-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; max-width: 100%; }
.bd-seg.tiny { padding: 0 3px; font-size: 9px; line-height: 9px; }
.bd-dur { opacity: 0.85; }

/* Телефон боком: высоты мало — в режиме сводки прячем чипы и поле ввода,
   вся высота под шкалу. Вносить записи — повернув обратно или в чате. */
/* В режиме сводки чипы и поле ввода не нужны: записи вносятся тапом по шкале,
   а для чата есть 💬. Ответ на действие показывается карточкой над ними. */
#tabShifts.mode-summary #shiftsChips,
#tabShifts.mode-summary .composer { display: none; }

@media (orientation: landscape) and (max-height: 500px) {
  /* Шапка — вертикальной колонкой справа: сверху вниз место дороже, чем вбок */
  #appScreen {
    display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr;
  }
  #appScreen > .topbar {
    grid-column: 2; grid-row: 1 / span 2;
    flex-direction: column; justify-content: flex-start; gap: 8px;
    padding: 8px 6px; border-bottom: none; border-left: 1px solid #182129; overflow-y: auto;
  }
  #appScreen > #searchBar { grid-column: 1; grid-row: 1; }
  #appScreen > #tabShifts { grid-column: 1; grid-row: 2; min-height: 0; }
  .topbar-left { flex: none; flex-direction: column; gap: 2px; }
  .topbar-left > div:last-child { display: none; } /* имя и "в сети" — не влезают по ширине */
  .avatar { width: 32px; height: 32px; font-size: 13px; }
  .topbar-date { flex-direction: column; margin: 0; gap: 6px; }
  .topbar-right { flex-direction: column; gap: 2px; }
}
