/* BITL Timeline — дизайн по мотивам bitlfinance.ru */
@font-face { font-family: 'Unbounded'; font-weight: 400; src: url(/assets/fonts/Unbounded-Regular.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Unbounded'; font-weight: 500; src: url(/assets/fonts/Unbounded-Medium.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Unbounded'; font-weight: 600; src: url(/assets/fonts/Unbounded-SemiBold.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Unbounded'; font-weight: 700; src: url(/assets/fonts/Unbounded-Bold.ttf) format('truetype'); font-display: swap; }

:root {
  --bg: #151515; --card: #222020; --card2: #2b2929; --line: #3a3a3a; --line2: #4a4a4a;
  --text: #ececec; --muted: #ababab; --orange: #ff592d; --red: #e53517;
  --grad: linear-gradient(63deg, #ea670d 0%, #eb3300 50%, #e20541 100%);
  --gray-bar: #5a5a5a; --font: 'Unbounded', 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --r: 24px; --r2: 16px; --r3: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
a { color: var(--orange); text-decoration: none; }
button, input, select, textarea { font-family: var(--font); font-size: 13px; color: var(--text); }
input, select, textarea { background: var(--card2); border: 1px solid var(--line); border-radius: var(--r3); padding: 9px 12px; outline: none; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); }
input[type=date] { color-scheme: dark; }
input[type=number] { width: 72px; text-align: center; }
textarea { resize: vertical; min-height: 44px; width: 100%; line-height: 1.4; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ababab' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 5px; letter-spacing: .02em; }
.hidden { display: none !important; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: var(--r2); padding: 12px 20px; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--grad); color: #fff; white-space: nowrap; transition: transform .1s, opacity .15s; }
.btn:hover { transform: translateY(-1px); opacity: .95; }
.btn:active { transform: translateY(0); }
.btn.sec { background: var(--card2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.sec:hover { border-color: var(--line2); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; padding: 8px 12px; }
.btn.ghost:hover { color: var(--text); }
.btn.sm { padding: 8px 14px; font-size: 12px; border-radius: 12px; }
.btn.danger { background: transparent; color: #ff7a7a; border: 1px solid #5a2a2a; font-weight: 500; }
.btn.icon { padding: 8px; width: 32px; height: 32px; justify-content: center; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

header.top { display: flex; align-items: center; gap: 24px; padding: 18px 32px; border-bottom: 1px solid #222; position: sticky; top: 0; background: rgba(21,21,21,.92); backdrop-filter: blur(8px); z-index: 20; }
header.top .logo { display: flex; align-items: center; gap: 14px; color: var(--text); }
header.top .logo svg { height: 26px; width: auto; }
header.top .logo .app { font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px; }
header.top .spacer { flex: 1; }
header.top .muted { color: var(--muted); font-size: 12px; }
main { padding: 28px 32px 60px; max-width: 1800px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 28px; font-weight: 600; margin: 0 0 6px; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border-radius: var(--r); padding: 22px 24px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-top: 18px; }
.tl-card { background: var(--card); border-radius: var(--r); padding: 22px; cursor: pointer; border: 1px solid transparent; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; gap: 8px; }
.tl-card:hover { border-color: var(--line2); transform: translateY(-2px); }
.tl-card .client { font-size: 17px; font-weight: 600; }
.tl-card .track { font-size: 12px; color: var(--muted); }
.tl-card .dates { font-size: 12px; margin-top: 6px; }
.tl-card .foot { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.tl-card .foot .muted { flex: 1; font-size: 11px; }
.badge { display: inline-block; font-size: 10px; padding: 3px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.badge.orange { color: var(--orange); border-color: #5a2a1c; background: #2a1a14; }
.empty { padding: 60px; text-align: center; color: var(--muted); }

/* --- модальное окно --- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: var(--r); padding: 28px; width: 560px; max-width: 100%; max-height: 92vh; overflow: auto; }
.modal h2 { margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field input, .field select { width: 100%; }
.track-opt { border: 1px solid var(--line); border-radius: var(--r2); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.track-opt.on { border-color: var(--orange); background: #2a1a14; }
.track-opt .n { font-weight: 600; font-size: 13px; }
.track-opt .d { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.err { color: #ff7a7a; font-size: 12px; margin-top: 8px; }

/* --- редактор --- */
.ed-head { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start; margin-bottom: 18px; }
.ed-head .fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.ed-head .fields .field { margin: 0; }
.ed-head input.client { font-size: 18px; font-weight: 600; width: 360px; }
.ed-head .status { font-size: 11px; color: var(--muted); text-align: right; margin-bottom: 8px; min-height: 16px; }
.ed-head .status.dirty { color: var(--orange); }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.meta { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 18px; }
.meta .m { background: var(--card2); border-radius: var(--r2); padding: 10px 16px; min-width: 130px; }
.meta .m .l { font-size: 10px; color: var(--muted); }
.meta .m .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.link-box { display: flex; align-items: center; gap: 10px; background: var(--card2); border-radius: var(--r2); padding: 8px 8px 8px 16px; font-size: 12px; }
.link-box code { font-family: ui-monospace, Menlo, monospace; color: var(--text); font-size: 12px; word-break: break-all; }

/* --- диаграмма --- */
.gantt-wrap { overflow-x: auto; overflow-y: hidden; border-radius: var(--r); background: var(--card); padding: 6px; }
table.gantt { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; }
table.gantt th, table.gantt td { padding: 0; border-bottom: 1px solid #2e2c2c; vertical-align: middle; }
table.gantt thead th { position: sticky; top: 0; background: var(--card); z-index: 3; font-weight: 500; }
table.gantt .g-num, table.gantt .g-name, table.gantt .g-own { position: sticky; background: var(--card); z-index: 2; text-align: left; }
table.gantt .g-num { left: 0; width: 34px; min-width: 34px; text-align: center; color: var(--muted); font-size: 11px; }
table.gantt .g-name { left: 34px; width: 380px; min-width: 300px; padding: 8px 12px 8px 6px; font-size: 11.5px; line-height: 1.4; }
table.gantt .g-own { left: 414px; width: 170px; min-width: 150px; padding: 6px 10px; font-size: 11px; color: var(--muted); border-right: 1px solid var(--line); }
table.gantt thead .g-num, table.gantt thead .g-name, table.gantt thead .g-own { z-index: 4; font-size: 11px; color: var(--muted); }
table.gantt .g-dates { font-size: 10px; color: var(--muted); margin-top: 3px; }
table.gantt .g-month { text-align: center; font-size: 11px; padding: 8px 4px 4px; border-left: 1px solid var(--line); color: var(--text); white-space: nowrap; }
table.gantt .g-month:first-of-type { border-left: 0; }
table.gantt .g-week { font-size: 9.5px; color: var(--muted); text-align: center; min-width: 38px; width: 38px; padding: 4px 0 8px; font-weight: 400; }
table.gantt .g-week.brk { color: #6f6f6f; }
table.gantt .g-week.now { color: var(--orange); font-weight: 600; }
table.gantt .g-week span { display: inline-block; }
table.gantt .g-cell { height: 40px; position: relative; background-image: linear-gradient(to right, #3d3a3a 1px, transparent 1px); background-size: 100% 100%; background-position: -1px 0; }
table.gantt .g-cell.brk { background-color: #1b1b1b; }
table.gantt .g-cell.now { box-shadow: inset 2px 0 0 var(--orange); }
table.gantt .g-week.now::after { content: 'сегодня'; display: block; font-size: 8px; font-weight: 400; }
table.gantt .bar { position: absolute; top: 50%; left: 0; right: 0; height: 16px; margin-top: -8px; background: var(--orange); }
table.gantt .bar.ext { background: var(--gray-bar); }
table.gantt .bar.first { left: 3px; border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
table.gantt .bar.last { right: 3px; border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
table.gantt tbody tr:hover td { background-color: #262424; }
table.gantt tbody tr:hover .g-cell.brk { background-color: #1f1e1e; }
.chip { display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); margin: 2px 3px 2px 0; color: var(--text); white-space: nowrap; }
.chip.bitl { color: var(--orange); border-color: #5a2a1c; }
.legend { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); margin: 14px 4px 0; }
.legend .sw { display: inline-block; width: 26px; height: 9px; border-radius: 5px; vertical-align: middle; margin-right: 8px; }
.legend .sw.main { background: var(--grad); }
.legend .sw.ext { background: var(--gray-bar); }
.legend .sw.brk { width: 2px; background: #6f6f6f; border-radius: 0; height: 12px; }
.legend .sw.now { width: 2px; background: var(--orange); border-radius: 0; height: 12px; }

/* --- таблица этапов --- */
table.stages { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
table.stages th { font-size: 11px; color: var(--muted); font-weight: 500; text-align: left; padding: 0 8px; }
table.stages td { background: var(--card2); padding: 10px 8px; vertical-align: top; }
table.stages td:first-child { border-radius: var(--r2) 0 0 var(--r2); text-align: center; color: var(--muted); font-size: 12px; padding-top: 18px; width: 40px; }
table.stages td:last-child { border-radius: 0 var(--r2) var(--r2) 0; }
table.stages td.name { width: 38%; }
table.stages td.own { width: 22%; }
table.stages td.own input { width: 100%; margin-bottom: 6px; }
table.stages .chips .chip { cursor: pointer; user-select: none; }
table.stages .chips .chip.on { background: #2a1a14; color: var(--orange); border-color: #5a2a1c; }
table.stages td .hint { font-size: 10px; color: var(--muted); margin-top: 5px; white-space: nowrap; }
table.stages input[type=date] { width: 150px; }
table.stages .act { display: flex; gap: 4px; flex-wrap: wrap; width: 120px; }
table.stages .chk { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding-top: 10px; white-space: nowrap; }
table.stages .chk input { width: auto; accent-color: var(--orange); }
.breaks .b-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
.breaks .b-row .field { margin: 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line2); color: var(--text); padding: 12px 20px; border-radius: var(--r2); font-size: 13px; z-index: 100; box-shadow: 0 10px 40px rgba(0,0,0,.5); }

/* --- публичный просмотр --- */
.pub-hero { background: var(--card); border-radius: 36px; padding: 36px; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; margin-bottom: 20px; }
.pub-hero h1 { font-size: 30px; }
.pub-hero .client { color: var(--orange); font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.pub-hero .sub { color: var(--muted); font-size: 13px; }
.pub-hero .dl { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.pub-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.pub-meta .m { background: var(--card); border-radius: var(--r2); padding: 12px 18px; min-width: 150px; }
.pub-meta .m .l { font-size: 10px; color: var(--muted); }
.pub-meta .m .v { font-size: 16px; font-weight: 600; }
.pub-foot { margin-top: 36px; color: var(--muted); font-size: 11px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.keydates { margin-top: 24px; }
.keydates table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.keydates th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.keydates td { padding: 10px 12px; border-bottom: 1px solid #2e2c2c; vertical-align: top; }
.keydates td.n { color: var(--muted); width: 36px; }
.keydates td.d { white-space: nowrap; }
@media (max-width: 900px) {
  header.top, main { padding-left: 16px; padding-right: 16px; }
  .pub-hero { grid-template-columns: 1fr; padding: 24px; }
  .pub-hero .dl { justify-content: flex-start; }
  .ed-head { grid-template-columns: 1fr; }
  table.gantt .g-name { width: 240px; min-width: 200px; }
  table.gantt .g-own { left: 274px; }
  h1 { font-size: 22px; }
}
@media print {
  body { background: #fff; color: #000; }
  header.top, .pub-hero .dl, .pub-foot { display: none; }
}

/* --- обзор по фазам --- */
.ov { display: flex; flex-direction: column; gap: 4px; min-width: 760px; }
.ov-row { display: grid; grid-template-columns: 250px 1fr; gap: 14px; min-height: 64px; border-radius: var(--r2); }
.ov-row:nth-child(even) { background: #1c1b1b; }
.ov-head { min-height: 30px; }
.ov-head .ov-label { font-size: 11px; color: var(--muted); display: flex; align-items: center; }
.ov-label { padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.ov-label b { font-size: 13px; font-weight: 600; }
.ov-label span { font-size: 11px; color: var(--muted); line-height: 1.35; }
.ov-track { position: relative; }
.ov-m { position: absolute; top: 0; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; border-left: 1px solid var(--line); }
.ov-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: #2e2c2c; }
.ov-brk { position: absolute; top: 0; bottom: 0; background: rgba(255,255,255,.035); }
.ov-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange); z-index: 2; }
.ov-today-lbl { position: absolute; top: 2px; transform: translateX(-50%); font-size: 9px; color: var(--orange); }
.ov-bar { position: absolute; top: 14px; height: 20px; border-radius: 10px; background: var(--orange); min-width: 8px; display: flex; align-items: center; justify-content: center; z-index: 1; }
.ov-bar span { font-size: 10px; color: #fff; font-weight: 500; white-space: nowrap; }
.ov-ext { position: absolute; top: 14px; height: 20px; border-radius: 10px; background: var(--gray-bar); margin-left: -6px; padding-left: 6px; box-sizing: content-box; }
.ov-sub { position: absolute; top: 38px; font-size: 10px; color: var(--muted); max-width: 95%; line-height: 1.3; }
.ov-sub.r { text-align: right; }
.ov-ms { min-height: 96px; background: transparent !important; }
.ov-line { position: absolute; left: 0; right: 0; top: 14px; height: 1px; background: var(--line2); }
.ov-mark { position: absolute; top: 9px; transform: translateX(-50%); width: 130px; text-align: center; }
.ov-mark i { display: block; width: 9px; height: 9px; background: var(--orange); transform: rotate(45deg); margin: 0 auto 6px; }
.ov-mark.money i { width: 12px; height: 12px; background: var(--red); margin-top: -1px; }
.ov-mark span { display: block; font-size: 10px; color: var(--muted); line-height: 1.3; }
.ov-mark span b { color: var(--text); font-weight: 600; }
.ov-mark.money span, .ov-mark.money span b { color: var(--text); }
.ov-mark.lvl1 { top: 9px; }
.ov-mark.lvl1 span { padding-top: 28px; }
.headline { display: flex; align-items: center; gap: 16px; border-left: 4px solid var(--orange); padding: 6px 0 6px 16px; margin: 6px 0 18px; }
.headline b { font-size: 18px; font-weight: 600; }
.headline span { color: var(--muted); font-size: 12px; }

/* --- роли --- */
.roles-wrap { overflow-x: auto; }
table.roles { width: 100%; border-collapse: separate; border-spacing: 0 6px; min-width: 760px; }
table.roles th { text-align: left; padding: 10px 12px; background: var(--card2); font-weight: 500; vertical-align: top; }
table.roles th:first-child { border-radius: var(--r3) 0 0 var(--r3); color: var(--muted); font-size: 11px; width: 130px; }
table.roles th:last-child { border-radius: 0 var(--r3) var(--r3) 0; }
table.roles th b { display: block; font-size: 12px; font-weight: 600; }
table.roles th span { font-size: 10px; color: var(--muted); }
table.roles td { padding: 10px 12px; font-size: 11.5px; vertical-align: middle; background: #1c1b1b; line-height: 1.45; border-left: 1px solid #2a2828; }
table.roles td:first-child { border-radius: var(--r3) 0 0 var(--r3); font-weight: 600; border-left: 0; }
table.roles td:last-child { border-radius: 0 var(--r3) var(--r3) 0; }
table.roles tr.ask td { background: #2a1a14; }
table.roles tr.ask td:first-child { color: #ff8a5c; }
table.roles td.role.bitl { color: var(--orange); }

/* --- ключевые даты --- */
.kd { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.kd-item { display: grid; grid-template-columns: 14px 100px 1fr; gap: 10px; align-items: center; padding: 7px 0; font-size: 12.5px; border-bottom: 1px solid #2a2828; }
.kd-item i { width: 8px; height: 8px; background: var(--orange); transform: rotate(45deg); }
.kd-item.money i { width: 11px; height: 11px; background: var(--red); }
.kd-item.money span { font-weight: 600; }
.kd-phases div { font-size: 12px; padding: 3px 0; }
.kd-check { background: var(--card2); border-radius: var(--r2); padding: 18px 20px; }
.kd-c { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; padding: 5px 0; }
.kd-c i { flex: 0 0 12px; height: 12px; border: 1.5px solid var(--orange); border-radius: 3px; margin-top: 3px; }
table.gantt tr.g-phase td { padding: 10px 8px 4px 46px; color: #ff8a5c; font-weight: 600; font-size: 12px; background: var(--card); position: sticky; left: 0; }
table.gantt .g-name b { font-weight: 600; }
table.gantt .g-desc { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
table.gantt .g-msl { color: #ff8a5c; }
table.gantt .g-ms { position: absolute; right: -5px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; background: #fff; transform: rotate(45deg); z-index: 2; }
table.gantt .g-ms.money { background: var(--red); width: 11px; height: 11px; margin-top: -5.5px; }
.legend .sw.ms { width: 8px; height: 8px; background: #fff; transform: rotate(45deg); border-radius: 1px; }
.legend .sw.ms.money { background: var(--red); }
.toggle-details { margin: 22px 0 10px; }

/* --- редактор: карточки этапов и фаз --- */
.st-card { background: var(--card2); border-radius: var(--r2); padding: 12px 14px; margin-bottom: 8px; display: grid; grid-template-columns: 36px 1fr; gap: 10px 12px; }
.st-card .num { color: var(--muted); font-size: 12px; padding-top: 10px; text-align: center; }
.st-card .g1 { display: grid; grid-template-columns: 200px 1fr 1fr; gap: 10px; }
.st-card .g2a { display: grid; grid-template-columns: 260px 90px 150px 80px 80px 1fr; gap: 10px; align-items: end; }
.st-card .g2b { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.st-card .g3 { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.st-card .field { margin: 0; }
.st-card input, .st-card select, .st-card textarea { width: 100%; }
.st-card textarea { min-height: 38px; font-size: 12px; }
.st-card .chips .chip { cursor: pointer; user-select: none; }
.st-card .chips .chip.on { background: #2a1a14; color: var(--orange); border-color: #5a2a1c; }
.st-card .chk { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.st-card .chk input { width: auto; accent-color: var(--orange); }
.st-card .hint { font-size: 10px; color: var(--muted); }
.st-card .act { display: flex; gap: 4px; }
.ph-row { display: grid; grid-template-columns: 30px 1.2fr 1.5fr 1.5fr 1.5fr auto; gap: 10px; align-items: end; background: var(--card2); border-radius: var(--r2); padding: 10px 12px; margin-bottom: 8px; }
.ph-row .field { margin: 0; }
.ph-row input { width: 100%; }
.ph-row .num { color: var(--muted); font-size: 12px; padding-bottom: 10px; text-align: center; }
.pace { display: flex; gap: 4px; }
.pace .btn.on { border-color: var(--orange); color: var(--orange); }
.subsec { margin-top: 26px; }
.subsec h2 { margin-bottom: 6px; }
.subsec .desc { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
@media (max-width: 900px) {
  .ov-row { grid-template-columns: 150px 1fr; }
  .kd { grid-template-columns: 1fr; }
  .st-card .g1, .st-card .g2a, .st-card .g2b, .ph-row { grid-template-columns: 1fr 1fr; }
}

table.roles td.merged { background: var(--card2); box-shadow: inset 3px 0 0 var(--orange); }
