:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #1d2935;
  --muted: #637083;
  --line: #d8e0e8;
  --brand: #1f7a8c;
  --brand-dark: #145766;
  --accent: #d97706;
  --danger: #c2410c;
  --ok: #168a5a;
  --shadow: 0 14px 36px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(29, 41, 53, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(29, 41, 53, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Arial,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

button:hover {
  border-color: #aab8c7;
  background: #f8fafc;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.14);
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 760px;
}

.primary-action {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.primary-action:hover {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  transform: translateY(12px);
  border: 1px solid rgba(29, 41, 53, 0.08);
  border-radius: 8px;
  padding: 11px 14px;
  color: #fff;
  background: rgba(29, 41, 53, 0.94);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.22);
  font-size: 0.86rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.project-panel,
.editor-panel,
.chart-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.project-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.editor-panel,
.chart-panel,
.table-panel {
  min-width: 0;
  padding: 16px;
}

.panel-title,
.chart-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-title span,
#date-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--task-color);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.task-card.invalid {
  border-color: rgba(194, 65, 12, 0.45);
  border-left-color: var(--danger);
  background: #fff7ed;
}

.task-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.task-fields label:first-child,
.task-fields label:last-child {
  grid-column: 1 / -1;
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.task-name {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.task-name:focus {
  box-shadow: none;
}

.delete-btn {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--danger);
}

.status-text {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-text.warning {
  color: var(--danger);
}

.duration-badge {
  flex: 0 0 auto;
  min-width: 86px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  background: var(--ink);
  text-align: center;
  font-weight: 800;
}

.chart-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.gantt-chart {
  min-width: 780px;
}

.timeline-grid,
.gantt-row {
  display: grid;
  grid-template-columns: 160px repeat(var(--columns), minmax(64px, 1fr));
}

.timeline-grid {
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.corner-cell,
.tick-cell,
.task-label,
.bar-lane {
  min-height: 42px;
  border-right: 1px solid var(--line);
}

.corner-cell,
.tick-cell {
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.gantt-row {
  border-bottom: 1px solid var(--line);
}

.gantt-row:last-child {
  border-bottom: 0;
}

.task-label {
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 8px 10px;
  background: #fff;
}

.task-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.task-label span {
  color: var(--muted);
  font-size: 0.76rem;
}

.bar-lane {
  position: relative;
  grid-column: 2 / -1;
  min-height: 54px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(100% / var(--columns) - 1px),
      rgba(216, 224, 232, 0.82) calc(100% / var(--columns) - 1px),
      rgba(216, 224, 232, 0.82) calc(100% / var(--columns))
    );
}

.gantt-bar {
  position: absolute;
  top: 12px;
  left: var(--left);
  width: var(--width);
  min-width: 12px;
  height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  color: #fff;
  background: var(--task-color);
  box-shadow: 0 8px 16px rgba(17, 24, 39, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.gantt-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.78rem;
  font-weight: 800;
}

.gantt-bar time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  opacity: 0.88;
}

.empty-chart {
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
}

.table-panel {
  margin-top: 16px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  background: var(--ok);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill.warning {
  background: var(--danger);
}

@media (max-width: 980px) {
  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
  }

  .header-actions {
    justify-content: flex-start;
    max-width: none;
  }

  .project-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .project-panel,
  .task-fields {
    grid-template-columns: 1fr;
  }

  .header-actions button {
    flex: 1 1 140px;
  }

  .toast {
    right: 10px;
    bottom: 12px;
    left: 10px;
    text-align: center;
  }
}

@media print {
  body {
    background: #fff;
  }

  .editor-panel,
  .header-actions,
  .project-panel {
    display: none;
  }

  .app-shell {
    width: 100%;
  }

  .workspace {
    display: block;
  }

  .chart-panel,
  .table-panel {
    box-shadow: none;
  }
}
