/* «Прораб» — панель план-графиков стройки.
   Палитра: бетон #EEEDE8 · уголь #191A1C · сигнальный оранжевый #FF5A00
   готово #178A4C · просрочка #D42B1E · висит #E19E00 */

:root {
  --bg: #EEEDE8;
  --card: #FFFFFF;
  --ink: #191A1C;
  --muted: #6B6A66;
  --line: #D8D6CF;
  --accent: #FF5A00;
  --done: #178A4C;
  --danger: #D42B1E;
  --warn: #E19E00;
  --radius: 6px;
  --shadow: 4px 4px 0 rgba(25, 26, 28, .16);
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px 80px; }

/* ── Сигнальная лента — фирменный элемент ─────────────────────── */
.tape {
  background: repeating-linear-gradient(-45deg,
    var(--accent) 0 12px, var(--ink) 12px 24px);
}
.progress {
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--card);
  overflow: hidden;
}
.progress > i {
  display: block; height: 100%;
  background: repeating-linear-gradient(-45deg,
    var(--accent) 0 10px, var(--ink) 10px 20px);
  background-size: 28px 28px;
  transition: width .5s ease;
}
@media (prefers-reduced-motion: no-preference) {
  .progress > i { animation: crawl 1.6s linear infinite; }
  @keyframes crawl { to { background-position: 28px 0; } }
}

/* ── Шапка ────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 0 14px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 6px;
}
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-mark { width: 34px; height: 34px; border: 3px solid var(--ink); border-radius: 4px; }
.logo b {
  font-family: var(--font-display); font-weight: 900;
  font-size: 20px; letter-spacing: .04em;
}
.logo span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); display: block; }
.topbar .user { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.linklike { background: none; border: none; text-decoration: underline; color: var(--ink); padding: 0; }

.today-line { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin: 10px 0 26px; }

/* ── Карточки и кнопки ────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  border: 2px solid var(--ink);
  background: var(--card);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-weight: 600;
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:hover { box-shadow: 3px 3px 0 rgba(25,26,28,.2); transform: translate(-1px,-1px); }
.btn:active { transform: translate(0,0); box-shadow: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-done { background: var(--done); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--muted); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: none; transform: none; }

h1, h2 { font-family: var(--font-display); letter-spacing: .01em; }
h1 { font-size: clamp(26px, 4vw, 40px); font-weight: 900; margin: 0; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; }
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}

/* ── Логин ────────────────────────────────────────────────────── */
.login-box { max-width: 380px; margin: 10vh auto 0; padding: 28px; }
.login-box .tape { height: 10px; margin: -28px -28px 24px; border-radius: 4px 4px 0 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-family: var(--font-mono); font-size: 12px; margin-bottom: 4px; }
.field input, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 2px solid var(--ink); border-radius: var(--radius); background: var(--card);
}
.error { color: var(--danger); font-size: 13px; min-height: 20px; }

/* ── Дашборд ──────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.pcard { padding: 20px; text-decoration: none; display: block; position: relative; }
.pcard:hover { box-shadow: 6px 6px 0 rgba(25,26,28,.2); }
.pcard h3 { font-family: var(--font-display); font-weight: 700; font-size: 19px; margin: 0 0 2px; }
.pcard .addr { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.pcard .pct { font-family: var(--font-display); font-weight: 900; font-size: 34px; line-height: 1; }
.pcard .pct small { font-size: 16px; }
.pcard .progress { margin: 10px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--font-mono); font-size: 11.5px; padding: 3px 8px;
  border: 1.5px solid var(--line); border-radius: 20px; color: var(--muted);
}
.chip.b-done { border-color: var(--done); color: var(--done); }
.chip.b-prog { border-color: var(--accent); color: var(--accent); }
.chip.b-over { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.chip.b-stall { border-color: var(--warn); color: var(--warn); font-weight: 600; }

.newcard {
  display: flex; align-items: center; justify-content: center;
  min-height: 170px; border-style: dashed; box-shadow: none;
  color: var(--muted); font-weight: 600; background: transparent;
}
.newcard:hover { color: var(--ink); border-color: var(--accent); }

/* ── Страница проекта ─────────────────────────────────────────── */
.back { font-family: var(--font-mono); font-size: 13px; text-decoration: none; display: inline-block; margin: 4px 0 14px; }
.back:hover { color: var(--accent); }
.phead { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 40px; margin-bottom: 10px; }
.phead .addr { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.bigpct { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: .9; }
.phead-progress { flex: 1 1 260px; min-width: 220px; }
.summary-chips { margin: 8px 0 26px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 940px) { .layout { grid-template-columns: 1fr; } }

section.card { padding: 20px; margin-bottom: 24px; }

/* цепочка чекпоинтов */
.chain {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  row-gap: 26px;
}
.node { position: relative; text-align: center; padding-top: 2px; }
.node::before {
  content: ""; position: absolute; top: 21px; left: 0; right: 0;
  border-top: 2px dashed var(--line); z-index: 0;
}
.node .dot {
  position: relative; z-index: 1;
  width: 40px; height: 40px; margin: 0 auto 8px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #fff;
}
.node.s-done .dot { background: var(--done); border-color: var(--done); }
.node.s-prog .dot { background: var(--accent); border-color: var(--accent); }
.node.s-cancel .dot { background: var(--line); border-color: var(--line); color: var(--muted); }
.node.f-over .dot { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(212,43,30,.25); }
.node.f-stall .dot { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(225,158,0,.3); }
.node .nm { font-size: 12.5px; font-weight: 600; line-height: 1.25; padding: 0 4px; }
.node .dt { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.node .dt.over { color: var(--danger); font-weight: 600; }
.node .dt.stall { color: var(--warn); font-weight: 600; }

/* список этапов */
.stage-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 13px 0; border-top: 1.5px solid var(--line);
}
.stage-row:first-of-type { border-top: none; }
.stage-main { flex: 1 1 220px; min-width: 0; }
.stage-main b { font-size: 15px; }
.stage-main .detail { font-size: 13px; color: var(--muted); }
.stage-dates { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); flex: 0 0 auto; min-width: 118px; }
.badge {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; border: 1.5px solid; white-space: nowrap;
}
.badge.s-planned { color: var(--muted); border-color: var(--line); }
.badge.s-prog { color: var(--accent); border-color: var(--accent); }
.badge.s-done { color: var(--done); border-color: var(--done); }
.badge.s-cancel { color: var(--muted); border-color: var(--line); text-decoration: line-through; }
.badge.f-over { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.f-stall { color: #fff; background: var(--warn); border-color: var(--warn); }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.addstage-toggle { margin-top: 14px; }
.addstage-form { margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--ink); display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.addstage-form .full { grid-column: 1 / -1; }

/* Гант */
.gantt { overflow-x: auto; }
.gantt-inner { min-width: 640px; position: relative; }
.g-row { display: grid; grid-template-columns: 170px 1fr; align-items: center; min-height: 34px; }
.g-label { font-size: 13px; font-weight: 600; padding-right: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; height: 100%; border-left: 1.5px solid var(--line); }
.g-bar {
  position: absolute; top: 7px; height: 18px; border-radius: 4px;
  border: 2px solid var(--ink); background: var(--card); min-width: 10px;
}
.g-bar.s-done { background: var(--done); border-color: var(--done); }
.g-bar.s-prog {
  background: repeating-linear-gradient(-45deg, var(--accent) 0 7px, #ffb28a 7px 14px);
  border-color: var(--accent);
}
.g-bar.s-cancel { background: var(--line); border-color: var(--line); }
.g-bar.f-over { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(212,43,30,.35); }
.g-head { position: relative; height: 24px; margin-left: 170px; }
.g-month { position: absolute; top: 0; font-family: var(--font-mono); font-size: 11px; color: var(--muted); border-left: 1.5px solid var(--line); padding-left: 5px; height: 100%; }
.g-today {
  position: absolute; top: 24px; bottom: 0; width: 0;
  border-left: 2px solid var(--danger); z-index: 2;
}
.g-today::after {
  content: "сегодня"; position: absolute; top: -22px; left: -4px;
  font-family: var(--font-mono); font-size: 10px; color: #fff;
  background: var(--danger); padding: 1px 5px; border-radius: 3px;
}

/* ── Ассистент ────────────────────────────────────────────────── */
.assistant { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.assistant .tape { height: 8px; border-radius: 4px 4px 0 0; margin: -20px -20px 16px; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 140px; max-height: 46vh; padding-right: 4px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 3px; }
.msg.ai { align-self: flex-start; background: var(--bg); border: 1.5px solid var(--line); border-bottom-left-radius: 3px; }
.msg .acts { margin-top: 6px; font-family: var(--font-mono); font-size: 12px; color: var(--done); }
.msg.pending { color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.chat-form { display: flex; gap: 8px; margin-top: 14px; }
.chat-form input { flex: 1; padding: 10px 12px; border: 2px solid var(--ink); border-radius: var(--radius); min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }
.hint code { font-family: var(--font-mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* журнал */
.ev { display: flex; gap: 10px; padding: 9px 0; border-top: 1.5px solid var(--line); font-size: 13.5px; }
.ev:first-of-type { border-top: none; }
.ev time { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); flex: 0 0 96px; padding-top: 2px; }
.ev .src { font-family: var(--font-mono); font-size: 10.5px; color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.demo-banner {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--ink); color: #fff; text-align: center; padding: 7px 12px;
}
.demo-banner b { color: var(--accent); }

/* ── Навигация в шапке: боксовый переключатель ────────────────── */
.segmented {
  display: flex; margin-left: auto; margin-right: 14px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.segmented a {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em;
  text-transform: uppercase; text-decoration: none; color: var(--ink);
  padding: 8px 16px; background: var(--card); white-space: nowrap;
}
.segmented a + a { border-left: 2px solid var(--ink); }
.segmented a:hover:not(.on) { background: #f1efe8; }
.segmented a.on { background: var(--ink); color: #fff; }

/* ── Инструмент ───────────────────────────────────────────────── */
.tools-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}

/* плитки-счётчики */
.tool-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.tstat {
  flex: 1 1 150px; border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.tstat b { font-family: var(--font-display); font-weight: 900; font-size: 30px; line-height: 1; }
.tstat span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.tstat.t-object b { color: var(--accent); }
.tstat.t-repair b { color: var(--warn); }

/* группы по расположению */
.tool-groups { display: flex; flex-direction: column; gap: 28px; }
.tool-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tool-group-head .g-ic { font-size: 20px; line-height: 1; }
.tool-group-head h2 { margin: 0; }
.tool-group-head .g-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  border: 1.5px solid var(--line); border-radius: 20px; padding: 1px 9px;
}

/* карточка инструмента */
.toolgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 16px; }
.tool-card {
  border: 2px solid var(--ink); border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.tool-card .strip { height: 7px; }
.tool-card.t-object .strip { background: var(--accent); }
.tool-card.t-person .strip { background: var(--ink); }
.tool-card.t-repair .strip { background: var(--warn); }
.tool-card .body { padding: 14px 16px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.tool-nm { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 1.2; }
.tool-note { font-size: 13px; color: var(--muted); }
.tool-where {
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 7px; margin-top: 2px;
}
.tool-where .w-ic { font-size: 15px; }
.tool-card-acts { display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 12px; }
.tool-card-acts .spacer { margin-left: auto; }

.tool-move-inline {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed var(--line);
}
.tool-move-inline select, .tool-move-inline input {
  width: 100%; padding: 8px 10px; border: 2px solid var(--ink);
  border-radius: var(--radius); background: var(--card); font-size: 13px;
}
.tool-hist { margin-top: 12px; padding-top: 10px; border-top: 1.5px dashed var(--line); }
.tool-hist .ev time { flex: 0 0 74px; }

@media (max-width: 600px) {
  body { font-size: 14px; }
  .wrap { padding: 0 14px 60px; }
  .stage-dates { min-width: 0; }
  .g-row { grid-template-columns: 120px 1fr; }
  .g-head { margin-left: 120px; }
  .segmented { margin-right: 0; }
  .toolgrid { grid-template-columns: 1fr; }
}
