:root {
  color-scheme: light dark;
  --brand-deep: #193B60;
  --brand: #004E8A;
  --brand-light: #DAEDFB;
  --accent: #3A9DD6;
  --silver: #A7ABB0;
  --ink: #1E293B;
  --muted: #475569;
  --bg: #F0F5FA;
  --surface: #fff;
  --line: #c7d5e1;
  --selected: var(--brand-light);
  --link: var(--brand);
  --urgent: #a33136;
  --pending: #8c580b;
  --success: #226c4f;
  font: 16px/1.5 Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
@media (prefers-color-scheme:dark) {
  :root {
    --bg: #101d2a;
    --surface: #192a3b;
    --ink: #edf4fc;
    --muted: #b3c3d2;
    --line: #3c5367;
    --selected: #20415d;
    --link: #91d1fb;
    --urgent: #ffa5a0;
    --pending: #f2c47e;
    --success: #85d5b3;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  overflow-wrap: anywhere;
}
header {
  background: var(--brand-deep);
  color: #fff;
  border-bottom: 2px solid var(--silver);
  padding-top: env(safe-area-inset-top);
}
.bar,
main,
nav {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding-inline: max(14px,env(safe-area-inset-left))
    max(14px,env(safe-area-inset-right));
}
.bar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bar > strong {
  font-size: 17px;
  font-weight: 650;
}
.app {
  position: fixed;
  inset-inline: 0;
  top: var(--app-top, 0px);
  height: 100vh;
  height: var(--app-height,100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app > main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-block: 12px 16px;
}
header,
#nav,
#outgoing {
  flex: none;
}
#nav {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.app.typing #nav {
  display: none;
}
#nav a {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  height: 55px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-decoration: none;
}
#nav a[aria-current] {
  color: var(--link);
  font-weight: 700;
}
#nav a[aria-current] svg {
  stroke-width: 2.3;
}
button,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--link);
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}
.primary,
button[aria-pressed=true] {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
button:disabled {
  opacity: .55;
  cursor: default;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
main {
  padding-top: 8px;
  padding-bottom: max(40px,env(safe-area-inset-bottom));
}
h1,
h2,
h3,
p,
dl {
  margin: 0;
}
h1 {
  font-size: clamp(1.55rem,4vw,2.2rem);
  line-height: 1.2;
  letter-spacing: -.035em;
  margin-block: 6px 16px;
}
h2 {
  font-size: 1.18rem;
}
h3 {
  font-size: 1rem;
}
a {
  color: var(--link);
}
small,
.muted,
dt,
label {
  color: var(--muted);
}
.panel,
.ticket {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
}
.narrow {
  max-width: 600px;
  margin: 16px auto;
}
.stack,
.panel,
.group {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}
.row,
.links,
.heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.heading {
  justify-content: space-between;
}
label {
  display: grid;
  gap: 4px;
  font-size: .88rem;
  font-weight: 600;
}
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 400;
  line-height: 1.4;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input[type=checkbox] {
  width: 20px;
  min-height: 20px;
}
textarea {
  resize: vertical;
  min-height: 68px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr));
  gap: 12px;
}
.board {
  display: grid;
  gap: 14px;
  align-items: start;
  grid-template-columns: repeat(4, minmax(min(78vw,220px),1fr));
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding-bottom: 10px;
}
.ticket {
  display: grid;
  gap: 4px;
  text-decoration: none;
  color: var(--ink);
  border-left: 4px solid var(--accent);
}
.ticket:hover {
  border-color: var(--link);
}
.ticket small, small, dt {font-size:14px}
.board > section {scroll-snap-align:start; min-width:0}
.priority-0,
.priority-1 {
  color: var(--urgent);
}
.state-deferred {
  color: var(--pending);
}
.state-done {
  color: var(--success);
}
dl {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(140px,1fr));
  gap: 10px;
}
dt {
  font-size: .8rem;
}
dd {
  margin: 1px 0;
}
.feed {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: auto;
  overscroll-behavior: contain;
  max-height: 65vh;
  max-height: 65dvh;
  min-height: 170px;
  padding: 12px 4px;
  scrollbar-width: thin;
}
.bubble {
  align-self: flex-start;
  border-radius: 16px 16px 16px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 9px 13px;
  max-width: min(86%,620px);
  min-width: 120px;
  display: grid;
  gap: 3px;
}
.bubble.mine {
  align-self: flex-end;
  background: var(--selected);
  border-radius: 16px 16px 4px 16px;
}
.bubble.system {
  align-self: center;
  max-width: 94%;
  text-align: center;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 3px 8px;
  font-size: 13px;
}
.bubble footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  text-align: right;
  color: var(--muted);
  font-size: .75rem;
}
.bubble p,
.preserve {
  white-space: pre-wrap;
}
.bubble .tag {
  font-weight: 700;
}
.quote {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  color: var(--muted);
  font-size: .85rem;
}
.gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 8px;
  min-width: 0;
}
.gallery:empty {
  display: none;
}
.gallery img {
  max-width: 100%;
  max-height: 210px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
.gallery audio,
.gallery a {
  max-width: 100%;
  min-width: 0;
}
summary {
  cursor: pointer;
  color: var(--link);
  padding: 6px 0;
  font-weight: 600;
}
details[open] > summary {
  margin-bottom: 8px;
}
.empty {
  padding: 18px 4px;
  color: var(--muted);
}
[hidden] {
  display: none!important;
}
#notice:not(:empty) {
  position: fixed;
  bottom: calc(66px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: var(--brand-deep);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  width: max-content;
  max-width: 92vw;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  width: min(420px,94vw);
  padding: 20px;
}
dialog::backdrop {
  background: #07132188;
}
.bubble .more {
  padding: 0 8px;
  min-height: 26px;
  min-width: 36px;
  border: 0;
  background: transparent;
  color: var(--link);
  font-size: 1.05rem;
  margin-right: auto;
}
#identity {
  position: relative;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--brand-light);
  color: var(--brand-deep);
  border-radius: 50%;
  font-size: 14px;
  list-style: none;
}
.avatar::-webkit-details-marker {
  display: none;
}
#identity details[open] > summary {
  margin: 0;
}
.profile-menu {
  position: absolute;
  z-index: 5;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  display: grid;
  gap: 6px;
  padding: 14px;
  width: min(290px,85vw);
  max-height: 60vh;
  overflow: auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 22px #10274528;
}
.profile-menu button {
  min-height: 36px;
}
fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
fieldset .row {
  display: flex;
  padding: 4px;
}
#outgoing {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 4px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
#outgoing[open] .stack {
  max-height: 45vh;
  overflow: auto;
  padding-bottom: 8px;
}
.outgoing-bubbles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.outgoing-bubbles:empty {
  display: none;
}

.segments,
.filter-selects {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 2px;
  border-radius: 9px;
  background: var(--selected);
}
.segments button,
.filter-selects select {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.segments button[aria-pressed=true] {
  background: var(--surface);
  color: var(--link);
  box-shadow: 0 1px 3px #10274528;
}
.filter-selects select + select {
  border-inline-start: 1px solid var(--line);
}
.list-filters {
  display: grid;
  gap: 8px;
}
.space-label,
.space-picker {
  align-self: flex-start;
  width: auto;
  max-width: 100%;
  min-height: 32px;
  padding: 3px 0;
  background: transparent;
  border: 0;
  font-size: 16px;
  font-weight: 650;
  color: var(--ink);
  text-overflow: ellipsis;
}
.app[data-screen=chat] > main {
  display: flex;
  overflow: hidden;
  padding-block: 6px;
}
.app[data-screen=chat] #main > .stack,
.chat-feed {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  gap: 6px;
}
.chat-feed .feed {
  flex: 1;
  min-height: 0;
  max-height: none;
}
.chat-feed > button {
  align-self: center;
  min-height: 32px;
  font-size: 14px;
}
.composer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: grid;
  gap: 4px;
  background: var(--bg);
  padding: 4px 0;
  min-width: 0;
}
.composer-line {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
  padding: 2px 4px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.composer-line textarea {
  flex: 1;
  resize: none;
  border: 0;
  border-radius: 12px;
  padding: 8px 2px;
  min-height: 38px;
  max-height: 126px;
  line-height: 22px;
  overflow-y: auto;
}
.composer-line button {
  flex: none;
  width: 38px;
  height: 38px;
  min-height: 0;
  padding: 0;
  border: 0;
}
.composer-line button:not(.primary) {
  background: transparent;
}
.media-tray {
  display: grid;
  gap: 3px;
}
.media-tray audio {
  max-width: 100%;
  height: 36px;
}
.media-tray small:empty {
  display: none;
}
.media-tray button {
  justify-self: start;
  min-height: 32px;
  font-size: 14px;
}
.media-tools .media-tray:not([hidden]) {
  margin-top: 6px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.subcontractor {
  justify-self: start;
  padding: 1px 8px;
  border-radius: 8px;
  background: var(--selected);
}
.author-position {
  margin-inline-start: .4em;
}
@media (max-width: 600px) {
  .app[data-screen=new] #main > .stack {
    min-height: 100%;
    display: flex;
    flex-direction: column;
  }
  .app[data-screen=new] .panel,
  .app[data-screen=new] .panel > .stack,
  .app[data-screen=new] form {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .app[data-screen=new] button[type=submit] {
    margin-top: auto;
  }
}

.day-divider {
  align-self: center;
  border-radius: 12px;
  background: var(--selected);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
}
.bubble, .bubble .more {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.bubble-head {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 14px;
}
.bubble-head .tag {
  flex: none;
  margin-inline-start: auto;
  white-space: nowrap;
  text-decoration: none;
}
.bubble .author {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}
.author-0 {
  color: #356484;
}
.author-1 {
  color: #456749;
}
.author-2 {
  color: #705580;
}
.author-3 {
  color: #865749;
}
.author-4 {
  color: #356969;
}
.author-5 {
  color: #685d88;
}
@media (prefers-color-scheme:dark) {
  .author-0 {
    color: #9cc8e7;
  }
  .author-1 {
    color: #abcdad;
  }
  .author-2 {
    color: #d4b3df;
  }
  .author-3 {
    color: #e3baab;
  }
  .author-4 {
    color: #9acdc9;
  }
  .author-5 {
    color: #c6bce4;
  }
}
.message-sheet {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 14px;
  width: min(380px, 95vw);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  box-shadow: 0 6px 24px #0003;
}
.sheet-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet-heading h2 {
  font-size: 16px;
}
.sheet-heading button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 23px;
  border: 0;
}
.sheet-content {
  display: grid;
  gap: 6px;
}
.sheet-content button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: 10px;
}
.sheet-content small:empty {
  display: none;
}
.sheet-options {
  margin: 0;
  padding: 0;
  border: 0;
}
.sheet-results {
  max-height: min(46dvh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-ticket {
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.sheet-ticket[aria-current] {
  opacity: 1;
  background: var(--selected);
}
@media (min-width: 641px) {
  .message-sheet::backdrop {
    background: #07132120;
  }
}
@media (max-width:640px) {
  .message-sheet {
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    padding: 8px max(16px, env(safe-area-inset-right)) max(14px,
      env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .sheet-grip {
    width: 36px;
    height: 5px;
    background: var(--silver);
    border-radius: 4px;
    margin: 0 auto 6px;
  }
  .sheet-grip,
  .sheet-heading {
    touch-action: none;
  }
}
#push-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex: none;
  gap: 8px 12px;
  width: min(952px, calc(100% - 28px));
  margin: 10px auto 0;
  padding: 10px 14px;
  border: 1px solid var(--brand);
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--brand-deep);
  font-size: 15px;
}
#push-banner[hidden] {
  display: none;
}
#push-banner p {
  flex: 1 1 220px;
  margin: 0;
}
@media (prefers-color-scheme:dark) {
  #push-banner {
    background: var(--selected);
    color: var(--ink);
    border-color: var(--accent);
  }
}
body:not([data-first-screen]) #push-banner {
  display: none;
}
#push-banner button {
  min-height: 36px;
  font-size: 15px;
}
.space-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.space-controls > :first-child {
  min-width: 0;
  flex: 1;
}
.space-controls details {
  position: relative;
}
.space-controls summary {
  list-style: none;
  padding: 4px 8px;
}
.space-controls details button {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 2;
  width: max-content;
}

.signin { display: grid; gap: 12px; padding: 24px 16px; max-width: 30em; }
.signin input { font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line, #cbd5e1); width: 100%; box-sizing: border-box; }

.voice-attachment {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
}
.voice-attachment small {
  text-align: start;
  font-size: 14px;
}

/* Сегменты — ширина по тексту (Виталий 23.11): «Все» и «Мои» узкие, «Без исполнителя» шире, всё в одну строку. */
.segments button {
  flex: 1 1 auto;
  padding: 2px 10px;
}

body[data-screen="schedule"] main { max-width: 1580px; }
.schedule-toolbar, .schedule-nav { display: flex; gap: 8px; align-items: center; }
.schedule-toolbar { flex-wrap: wrap; margin-bottom: 10px; }
.schedule-toolbar h1 { font-size: 20px; margin: 0 auto 0 0; font-variant-numeric: tabular-nums; }
.schedule-toolbar select { width: auto; max-width: 100%; }
.schedule-nav button { min-width: 34px; padding: 3px 10px; }
.schedule-body { display: grid; grid-template-columns: clamp(150px, 17vw, 215px) minmax(0, 1fr); gap: 14px; }
.schedule-backlog { display: grid; align-content: start; gap: 12px; }
.schedule-backlog section, .schedule-scroll, .schedule-alerts { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.schedule-backlog h3, .schedule-alerts h3 { font-size: 15px; margin: 0; padding: 8px 12px; }
.schedule-job { display: block; padding: 8px 12px; text-decoration: none; font-size: 14px; border-top: 1px solid var(--line); }
.schedule-job small, .schedule-legend { display: block; color: var(--muted); font-size: 12px; }
.schedule-legend { margin: 6px 2px; }
.schedule-content, .schedule-timeline { min-width: 0; }
.schedule-scroll { overflow-x: auto; }
.schedule-grid { display: grid; grid-template-columns: clamp(82px, 8vw, 120px) minmax(0, 1fr); min-width: 0; }
.schedule-person { position: sticky; left: 0; z-index: 3; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); padding: 12px 8px; font-size: 14px; font-weight: 600; }
.schedule-axis, .schedule-track { position: relative; overflow: hidden; background-image: linear-gradient(to right, var(--line) 1px, transparent 1px); background-size: var(--hour-width) 100%; border-bottom: 1px solid var(--line); }
.schedule-axis { height: 52px; }
.schedule-day, .schedule-hour { position: absolute; white-space: nowrap; padding-left: 3px; }
.schedule-day { top: 0; height: 24px; font-size: 13px; background: var(--selected); border-left: 1px solid var(--line); }
.schedule-hour { bottom: 2px; font-size: 10px; color: var(--muted); }
.schedule-track { min-height: calc(23px + var(--lanes) * 37px); }
.schedule-day-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--silver); }
.schedule-day-line.travel { color: var(--urgent); font-size: 14px; padding-left: 3px; line-height: 18px; }
.schedule-lane { position: absolute; inset-inline: 0; top: calc(18px + var(--lane) * 37px); height: 32px; pointer-events: none; }
.schedule-lane a { pointer-events: auto; position: absolute; }
.schedule-bar { top: 0; height: 25px; min-width: 3px; overflow: hidden; white-space: nowrap; text-decoration: none; border-radius: 4px; background: #316599; color: white; font: 600 12px/25px Inter, sans-serif; }
.schedule-bar.in_progress { background-color: #287160; }
.schedule-bar.deferred { background-color: #675584; }
.schedule-bar.late { background-color: #a64c05; }
.schedule-bar.overdue { background-color: #a52532; }
.schedule-bar.overlap { background-image: repeating-linear-gradient(135deg, transparent 0 4px, #92182bbd 4px 7px); outline: 1px solid #a52532; outline-offset: -1px; }
.schedule-caption { top: 0; color: var(--link); background: var(--surface); white-space: nowrap; font: 600 12px/25px Inter, sans-serif; text-decoration: none; }
.schedule-caption.before { transform: translateX(-100%); }
.schedule-actual { height: 4px; min-width: 2px; bottom: 0; background: var(--ink); }
.schedule-due { z-index: 1; height: 29px; border-left: 2px solid var(--urgent); font-size: 11px; color: var(--urgent); padding-inline: 2px; }
.schedule-alerts { margin-bottom: 10px; border-left: 3px solid var(--urgent); }
.schedule-alerts a { display: block; padding: 3px 12px 7px; font-size: 14px; }
@media (max-width: 899px) {
  .schedule-body { display: flex; flex-direction: column; gap: 8px; }
  .schedule-timeline { order: -1; }
  .schedule-grid { grid-template-columns: 100px minmax(0, 1fr); min-width: 1150px; }
}
