:root {
  --ink: #1d1a16;
  --muted: #6f675e;
  --line: #e4dace;
  --paper: #f6f1e8;
  --panel: #fbf8f3;
  --accent: #0e6b62;
  --accent-soft: #e5f3f0;
  --summary: #2c2825;
  --danger: #8d3b2d;
  --row: 48px;
  --head: 52px;
  --week: 42px;
  --left: 680px;
  --col-task: 240px;
  --col-weeks: 72px;
  --col-resource: 180px;
  --col-progress: 84px;
  color: var(--ink);
  background: #e7e0d4;
  font: 14px/1.4 "Segoe UI", Candara, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 960px;
  height: 100vh;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px 10px;
}

.title-block { flex: 1; min-width: 0; }

.title {
  display: block;
  width: min(640px, 100%);
  border: none;
  background: transparent;
  color: inherit;
  font: 500 30px/1.15 Cambria, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  padding: 0 0 2px;
  border-radius: 0;
}

.title:focus {
  outline: none;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.date-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.date-field input,
select,
.weeks input,
.name input {
  font: inherit;
  color: var(--ink);
}

.date-field input,
.date-field select {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 8px;
}

.plan-switch {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.plan-switch select { min-width: 180px; max-width: 280px; }

.status {
  margin-left: auto;
  align-self: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.status.offline { background: #f8e8e4; color: var(--danger); }
.status.updated { background: #f3ead2; color: #6d5420; }
.status.saving, .status.paused { background: #ece7de; color: var(--muted); }

.save-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.save-toggle input { margin: 0; }

button {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #d9d0c3;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: #0c554e;
}

button:disabled {
  opacity: 0.38;
  cursor: default;
}

button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}


select {
  min-width: 220px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
}

.error {
  margin: 0 22px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8e8e4;
  color: var(--danger);
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  border-top: 1px solid var(--line);
}

.left-col {
  position: relative;
  width: calc(36px + var(--col-task) + var(--col-weeks) + var(--col-resource) + var(--col-progress) + 56px);
  max-width: calc(100% - 160px);
  min-width: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.right-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 48px),
    #f3eee6;
}

.cols {
  display: grid;
  grid-template-columns: 36px var(--col-task) var(--col-weeks) var(--col-resource) var(--col-progress);
  column-gap: 8px;
  align-items: center;
  padding: 0 12px;
  width: max-content;
  min-width: 100%;
  box-sizing: border-box;
}

.cols > * { min-width: 0; }

.resource-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.resource-chip {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.4;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e5f3f0;
  color: #0c554e;
}

.load {
  width: 58px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
}

.resource {
  width: auto;
  min-width: 0;
  max-width: 84px;
  flex: 0 1 76px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 3px 2px;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
}

.resource:hover, .resource:focus { border-color: #e6dccf; background: #fff; outline: none; }

.left-head-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}

.left-head-wrap::-webkit-scrollbar { height: 0; }

.left-head {
  height: var(--head);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.col-h { position: relative; overflow: visible; }

.col-grip, .pane-grip {
  position: absolute;
  top: 0;
  width: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: col-resize;
  z-index: 3;
}

.col-grip { right: -9px; height: 100%; }

.pane-grip { right: -5px; height: 100%; }

.col-grip:hover, .col-grip.dragging, .pane-grip:hover, .pane-grip.dragging {
  background: rgba(14, 107, 98, 0.35);
}

.left-body {
  flex: 1;
  overflow: auto;
  scrollbar-width: none;
}

.left-body::-webkit-scrollbar { width: 0; height: 0; }

.head-scroll {
  height: var(--head);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #f7f3ec;
}

.body-scroll {
  flex: 1;
  overflow: auto;
}

.time-head, .canvas { position: relative; }
.time-head { display: flex; }

.week-h {
  width: var(--week);
  height: var(--head);
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 6px;
  border-right: 1px solid #eadfD2;
  font-variant-numeric: tabular-nums;
}

.week-h strong { font-weight: 600; font-size: 13px; }
.week-h span { color: var(--muted); font-size: 11px; }
.week-h.shut { background: rgba(141, 59, 45, 0.12); }

.row {
  height: var(--row);
  border-bottom: 1px solid #efe7dc;
}

.row.child { height: 40px; }

.left-row { cursor: default; }
.left-row.hot, .g-row.hot { background: rgba(14, 107, 98, 0.05); }
.left-row.selected,
.g-row.selected { background: #b7e0d6; }
.left-row.selected { box-shadow: inset 4px 0 0 #0e6b62; }

.name {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.name-grip {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -8px;
  width: 8px;
  cursor: col-resize;
  z-index: 2;
}

.name-grip:hover, .name-grip.dragging { background: rgba(14, 107, 98, 0.35); }

.name input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 4px 6px;
}

.name.top input { font-weight: 600; }

.name input:hover, .weeks input:hover, .progress input:hover { border-color: #e6dccf; }
.name input:focus, .weeks input:focus, .progress input:focus, select:focus, .date-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.weeks input {
  width: 64px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-variant-numeric: tabular-nums;
}

.progress {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
}

.progress-sum {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  cursor: help;
}

.progress input {
  width: 52px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 4px 4px;
  font-variant-numeric: tabular-nums;
}

.weeks-sum {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted #b7aa9a;
  cursor: help;
  width: fit-content;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #4e483f;
}

.menu {
  position: fixed;
  z-index: 30;
  min-width: 260px;
  max-width: 440px;
  background: #fffdf9;
  border: 1px solid #d9d0c3;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(30, 26, 23, 0.14);
  padding: 6px;
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
}

.menu button:hover:not(:disabled) { background: var(--accent-soft); }

.menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: #d9d0c3;
}

.menu-note {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.canvas { height: 100%; }

.shades, .arrows { position: absolute; inset: 0; pointer-events: none; }

.today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid #c4553a;
  pointer-events: none;
  z-index: 2;
}

.shade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--week);
  border-right: 1px solid rgba(42, 36, 28, 0.06);
}

.shade.on { background: rgba(42, 36, 28, 0.035); }


.g-row { position: relative; }

.bar {
  position: absolute;
  border-radius: 7px;
  min-width: 8px;
  height: 22px;
  top: 13px;
  color: white;
  background: transparent;
}

.bar, .diamond { cursor: grab; }
body.bar-dragging, body.bar-dragging .bar, body.bar-dragging .diamond { cursor: grabbing; }

.bar:not(.summary):not(.milestone) { overflow: hidden; }

.bar-work {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--bar, #0e6b62);
}

.bar-shut {
  position: absolute;
  bottom: 0;
  height: 0;
  border-bottom: 3px dotted var(--bar, #2c2825);
  pointer-events: none;
}

.bar.d0 { background: transparent; }
.bar.d1, .bar.d2 {
  top: 9px;
  border-radius: 2px;
  background: transparent;
}
.bar.d1 .handle.end, .bar.d2 .handle.end { border-radius: 0 2px 2px 0; }

.bar.summary {
  height: 28px;
  top: 10px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  min-width: 6px;
  overflow: visible;
}

.bar-cap {
  position: absolute;
  top: 0;
  width: 2px;
  height: 34px;
  background: var(--bar, var(--summary));
  z-index: 2;
}

.bar-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--bar, #0e6b62) 62%, #16120e);
  box-shadow: inset -3px 0 0 color-mix(in srgb, var(--bar, #0e6b62) 38%, #16120e);
  pointer-events: none;
  z-index: 1;
}

.bar-progress.zero {
  width: 3px !important;
  box-shadow: none;
}

.progress-edge {
  position: absolute;
  top: 0;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
  z-index: 3;
}

.bar-cap.start { left: 0; }
.bar-cap.end { right: 0; }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 6px 8px;
}

.menu button.swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(42, 36, 28, 0.25);
  border-radius: 50%;
}

.menu button.swatch:hover:not(:disabled) { transform: scale(1.08); }

.color-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 8px;
  font-size: 13px;
}

.color-pick input[type="color"] {
  width: 36px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.bar.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0e6b62; }

.bar-label {
  position: absolute;
  left: 8px;
  right: 12px;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  z-index: 2;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}

.handle {
  position: absolute;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
  z-index: 2;
}

.handle.end {
  right: 0;
  z-index: 4;
  border-radius: 0 7px 7px 0;
}

.handle.start {
  left: 0;
  border-radius: 7px 0 0 7px;
}

.handle:hover { background: rgba(255, 255, 255, 0.35); }

.milestone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 3;
  overflow: visible;
}

.diamond {
  position: absolute;
  left: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: #1d1a16;
  transform: rotate(45deg);
  cursor: grab;
}

.milestone.selected .diamond {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0e6b62;
}

.milestone-label {
  position: absolute;
  color: var(--ink);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
}

.milestone-label.right { left: 12px; top: 50%; transform: translateY(-50%); }
.milestone-label.left { right: 12px; top: 50%; transform: translateY(-50%); }
.milestone-label.above { left: 0; bottom: calc(50% + 12px); transform: translateX(-50%); }
.milestone-label.below { left: 0; top: calc(50% + 12px); transform: translateX(-50%); }

.shutdown {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(141, 59, 45, 0.08);
  border-left: 1px dashed rgba(141, 59, 45, 0.4);
  border-right: 1px dashed rgba(141, 59, 45, 0.4);
  pointer-events: none;
  z-index: 1;
}

.shutdown-tag {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8d3b2d;
  white-space: nowrap;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 8px;
}

.menu-row input {
  width: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
}

.arrow { fill: none; stroke: rgba(42, 38, 34, 0.45); stroke-width: 1.4; pointer-events: none; }
.arrow.hot { stroke: var(--accent); stroke-width: 2; }
.arrow-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }

.print-box {
  position: fixed;
  z-index: 40;
  top: 72px;
  right: 22px;
  width: 280px;
  background: #fffdf9;
  border: 1px solid #d9d0c3;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(30, 26, 23, 0.14);
  padding: 10px 12px;
}

.print-choice, .print-range label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 13px;
}

.print-range input[type="date"],
.print-range input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

.print-actions { display: flex; gap: 6px; margin-top: 8px; }

@media print {
  @page { size: landscape; margin: 12mm; }
  html, body {
    height: auto;
    background: white;
    min-width: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .app { height: auto; overflow: visible; }
  .status, .date-field, .error, .plan-switch, .print-box { display: none !important; }
  .board { height: auto; overflow: visible; display: flex; align-items: flex-start; width: 100%; }
  .left-col { min-width: 0; width: 46%; max-width: none; }
  .cols {
    grid-template-columns: 28px minmax(0, 1.6fr) 40px minmax(0, 1fr) 46px;
    width: 100%;
  }
  .col-grip, .pane-grip, .name-grip { display: none !important; }
  .left-row { height: var(--row); overflow: hidden; }
  .right-col, .head-scroll, .body-scroll, .left-body { overflow: visible; height: auto; }
  .bar { min-width: 0; }
  .left-row.selected, .g-row.selected { background: transparent; box-shadow: none; }
  .bar.selected { box-shadow: none; }
  .milestone.selected .diamond { box-shadow: none; }
  .bar-work, .bar-progress, .bar-cap, .diamond, .shade.on, .shutdown, .week-h.shut {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.print-tight .week-h span { display: none; }
  body.print-tight .week-h { padding-left: 1px; }
  body.print-tight .week-h strong { font-size: 10px; }
  body.print-chart .left-col { display: none !important; }
  body.print-chart .right-col { width: 100%; }
}
