/* ---------- Timeline (Gantt) ---------- */
.content:has(> .gantt) { overflow: hidden; }
.gantt { display: flex; flex-direction: column; height: 100%; position: relative; }
.g-toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.g-toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { padding: 0 12px; height: 30px; color: var(--muted); border-left: 1px solid var(--border); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); color: var(--text); }
.seg button.on { background: var(--sel); color: var(--blue); font-weight: 600; }
.tgl { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; font-size: 13px; }
.tgl input { display: none; }
.tgl span { width: 30px; height: 18px; border-radius: 9px; background: var(--track-strong); position: relative; transition: .15s; flex-shrink: 0; }
.tgl span::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #ffffff; top: 2px; left: 2px; transition: .15s; }
.tgl input:checked + span { background: var(--green); }
.tgl input:checked + span::after { left: 14px; }
.tgl:has(input:checked) { color: var(--text); }

.g-scroll { flex: 1; overflow: auto; min-height: 0; }
.g-inner { position: relative; min-height: 100%; padding-bottom: 120px; }
.g-head { position: sticky; top: 0; z-index: 6; display: flex; background: var(--surface); border-bottom: 1px solid var(--border); }
.g-corner {
  position: sticky; left: 0; z-index: 7; width: var(--leftw); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border-strong);
  display: grid; grid-template-columns: var(--gcols); align-items: end; padding-bottom: 8px; color: var(--muted); font-size: 12px;
}
.g-scale { position: relative; flex-shrink: 0; }
.g-scale-row { position: relative; height: 28px; }
.g-u { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--border); padding: 0 6px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; font-size: 12px; color: var(--muted); }
.g-u.top { font-weight: 600; color: var(--text); }
.g-u.bot { justify-content: center; padding: 0; border-top: 1px solid var(--border); }
.g-u.bot.off { color: var(--faint); background: var(--soft); }

.g-body { position: relative; }
.g-bg { position: absolute; top: 0; bottom: -120px; pointer-events: none; }
.g-col { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-soft); }
.g-off { position: absolute; top: 0; bottom: 0; background: var(--soft); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); opacity: .8; }

.g-row { height: 34px; position: relative; border-bottom: 1px solid var(--line); }
.g-row.task[data-sched] { cursor: crosshair; }
.g-row.selected { background: rgba(69, 115, 210, .07); }
.g-left {
  position: sticky; left: 0; z-index: 4; width: var(--leftw); height: 100%; background: var(--surface); border-right: 1px solid var(--border-strong);
  display: grid; grid-template-columns: var(--gcols); align-items: center; font-size: 13px;
}
.g-row.task .g-left { cursor: pointer; }
.g-row.task .g-left:hover { background: var(--row-hover); }
.g-row.selected .g-left { background: var(--sel); }
.g-c { padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.g-c.wbs { color: var(--faint); font-size: 12px; padding-left: 14px; }
.g-c.num { text-align: right; padding-right: 12px; }
.g-c.name { display: flex; align-items: center; gap: 8px; color: var(--text); min-width: 0; }
.g-corner .g-c.name { color: var(--muted); }
.g-row.sec, .g-row.sec .g-left { background: var(--row-hover); }
.g-row.sec .g-left { font-weight: 600; }
.g-row.sec .g-c { color: var(--text); }
.g-row.sec .g-c.name { gap: 2px; }
.g-row.sec .sname { overflow: hidden; text-overflow: ellipsis; cursor: text; padding: 2px 4px; border-radius: 4px; }
.g-row.sec .sname:hover { background: var(--hover); }
.g-row.sec .caret { transition: transform .15s; }
.g-row.sec .caret.collapsed { transform: rotate(-90deg); }
.g-secmenu { opacity: 0; margin-left: auto; }
.g-row.sec:hover .g-secmenu { opacity: 1; }
.g-row.task.is-done .t-title { color: var(--muted); text-decoration: line-through; }
.ms-ico { color: var(--muted); font-size: 11px; }
.g-add { color: var(--muted); cursor: pointer; padding-left: 26px; }
.g-add:hover { color: var(--text); }
.g-inline { flex: 1; border: 1px solid var(--blue); border-radius: 5px; padding: 4px 8px; outline: 0; margin-left: 20px; }
.g-hint { position: absolute; left: calc(var(--leftw) + 20px); top: 0; height: 100%; display: flex; align-items: center; color: var(--faint); font-size: 12px; pointer-events: none; }

.g-layer { position: absolute; top: 0; z-index: 3; pointer-events: none; }
.g-arrows { position: absolute; left: 0; top: 0; overflow: visible; }
.g-arrows path { fill: none; stroke: var(--arrow); stroke-width: 1.4; }
.g-arrows path.crit { stroke: var(--red); stroke-width: 1.8; }
.g-arrows .ah { fill: var(--arrow); stroke: none; }
.g-arrows .ah.crit { fill: var(--red); }
#g-temp { stroke: var(--blue); stroke-width: 2; stroke-dasharray: 5 4; }

.g-bar {
  position: absolute; height: 22px; border-radius: 6px; background: var(--c); pointer-events: auto; cursor: grab;
  display: flex; align-items: center; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); color: #1e1f21;
}
.g-bar::before { content: ''; position: absolute; inset: 0; border-radius: 6px; background: var(--bar-veil); }
.g-prog { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--c); }
.g-text { position: relative; z-index: 1; padding: 0 9px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.g-bar.active { cursor: grabbing; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); z-index: 5; }
.g-bar.crit { outline: 2px solid var(--red); outline-offset: 1px; }
.g-bar.is-done, .g-ms.is-done { opacity: .5; }
.g-bar.link-target, .g-ms.link-target { outline: 2px solid var(--blue); outline-offset: 2px; }
.g-h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2; }
.g-h.l { left: -2px; }
.g-h.r { right: -2px; }
.g-dot {
  position: absolute; right: -15px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--blue); cursor: crosshair; opacity: 0; z-index: 3; transition: opacity .1s;
}
.g-bar:hover .g-dot, .g-ms:hover .g-dot { opacity: 1; }
.g-ms { position: absolute; width: 18px; height: 18px; pointer-events: auto; cursor: grab; }
.g-ms::before { content: ''; position: absolute; inset: 3px; background: var(--ink); transform: rotate(45deg); border-radius: 2px; }
.g-ms.crit::before { background: var(--red); }
.g-ms .g-dot { right: -16px; }
.g-sum { position: absolute; height: 7px; background: var(--ink); pointer-events: none; }
.g-sum::before, .g-sum::after { content: ''; position: absolute; top: 7px; border-top: 5px solid var(--ink); }
.g-sum::before { left: 0; border-right: 6px solid transparent; }
.g-sum::after { right: 0; border-left: 6px solid transparent; }
.g-label { position: absolute; height: 34px; display: flex; align-items: center; white-space: nowrap; font-size: 12px; color: var(--text); pointer-events: none; }
.g-tip { position: fixed; display: none; z-index: 60; background: var(--text); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 5px; pointer-events: none; white-space: nowrap; }

/* ---------- Detail panel extras ---------- */
.inline-field { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.inline-field input[type=range] { width: 180px; accent-color: var(--green); }
.mini-swatches { display: flex; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.mini-sw { width: 20px; height: 20px; border-radius: 5px; outline: 2px solid transparent; outline-offset: 1px; }
.mini-sw.sel { outline-color: var(--text); }
.mini-sw.def { position: relative; }
.mini-sw.def::after { content: 'P'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }
.deps { display: flex; flex-direction: column; gap: 4px; }
.dep { display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.dep .t-title { flex: 1; }
.dep .icon-btn { width: 24px; height: 24px; }
.dep-add { max-width: 100%; color: var(--muted); }
.succ { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.mfield { width: 100%; height: 38px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 10px; outline: 0; background: var(--surface); }
.mfield:focus { border-color: var(--blue); }
.field:disabled { color: var(--faint); }

/* ---------- PDF export ---------- */
html:has(body.printing) { height: auto; }
body.printing { display: block; height: auto; overflow: visible; }
body.printing #sidebar, body.printing #detail, body.printing .tabs, body.printing .top-actions,
body.printing .g-toolbar, body.printing .toast, body.printing .pt-row .icon-btn, body.printing .g-dot,
body.printing .g-secmenu, body.printing .g-hint, body.printing .g-add { display: none !important; }
body.printing #main, body.printing .content, body.printing .gantt, body.printing .g-scroll { overflow: visible !important; height: auto !important; display: block; }
body.printing .topbar { border: 0; padding: 16px 24px 12px; }
body.printing .g-inner { padding-bottom: 0; }
body.printing .g-bg { bottom: 0; }
body.printing .g-row.selected, body.printing .g-row.selected .g-left { background: var(--surface); }

.gantt { --leftw: 540px; --gcols: 44px 1fr 90px 90px 66px; }
.gantt.with-base { --leftw: 606px; --gcols: 44px 1fr 90px 90px 66px 66px; }
.g-row.sec { background: var(--row-hover); }
.g-c.var-late { color: var(--red); font-weight: 600; }
.g-c.var-early { color: var(--green); font-weight: 600; }
.with-base .g-bar { height: 17px; }
.g-base { position: absolute; height: 5px; border-radius: 3px; background: var(--faint); opacity: .75; pointer-events: none; }
.g-base.ms { width: 9px !important; height: 9px; border-radius: 1px; transform: rotate(45deg); background: transparent; border: 1.5px solid var(--faint); }
.btn.menu-btn svg:last-child { margin-left: 2px; }
.d-base { font-size: 13px; color: var(--muted); }
.d-base b { font-weight: 600; }
.d-base .late { color: var(--red); }
.d-base .early { color: var(--green); }

:root[data-theme="dark"] .g-tip { background: #3a3b3e; }
:root[data-theme="dark"] .g-bar { box-shadow: none; }

/* ---------- Zoom bar ---------- */
#main { position: relative; }
.g-zoombar {
  position: absolute; right: 22px; bottom: 18px; z-index: 9; display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 5px 8px 5px 12px;
}
.g-zoombar .icon-btn { font-size: 18px; font-weight: 600; width: 26px; height: 26px; }
.g-zoombar input[type=range] { width: 150px; accent-color: var(--blue); }
.g-zoom-label { font-size: 12px; color: var(--muted); min-width: 64px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.danger-text { color: var(--red); }

/* ---------- Dialogs: templates, settings, PDF ---------- */
.modal.wide { width: 620px; }
.modal label.chk { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--text); font-size: 14px; cursor: pointer; }
.chk-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.pdf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.tpl-desc { color: var(--muted); font-size: 12px; margin-top: 6px; min-height: 16px; }
.tpl-list { max-height: 52vh; overflow-y: auto; margin: 6px -4px 0; padding: 0 4px; }
.tpl-group { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 14px 0 6px; }
.tpl-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.tpl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tpl-info b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-info small { color: var(--muted); font-size: 12px; }
.tpl-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.tpl-rename { flex: 1; height: 30px; border: 1px solid var(--blue); border-radius: 6px; padding: 0 8px; outline: 0; background: var(--surface); }
.set-sec { font-weight: 600; margin: 18px 0 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.set-sec:first-of-type { border-top: 0; padding-top: 0; margin-top: 4px; }
.logo-row { display: flex; align-items: center; gap: 8px; }
.logo-prev { width: 170px; height: 54px; border: 1px dashed var(--border-strong); border-radius: 8px; display: grid; place-items: center; color: var(--faint); font-size: 12px; overflow: hidden; background: #fff; }
.logo-prev img { max-width: 160px; max-height: 46px; }
.modal p.small { font-size: 13px; margin: 6px 0; }
.modal code { font-size: 12px; word-break: break-all; color: var(--text); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.about { margin-top: 14px !important; }
.modal { max-height: 92vh; overflow-y: auto; }
