:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #59636e;
  --border: #d0d7de;
  --accent: #0969da;
  --good: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --todo: #6e7781;
  --shadow: 0 12px 36px rgba(31, 35, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #ffffff 0%, var(--bg) 55%);
  min-height: 100vh;
}

.topbar {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  padding: 1.1rem 1.3rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fa 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.top-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

input[type="search"],
select,
button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  height: 34px;
  padding: 0 0.65rem;
  font-size: 0.9rem;
}

input[type="search"] {
  width: min(360px, 42vw);
}

button {
  cursor: pointer;
}

.view-switch {
  display: flex;
}

.view-switch button {
  border-radius: 0;
  min-width: 84px;
}

.view-switch button:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.view-switch button:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.view-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 1rem;
}

.filters,
.content,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.filters {
  padding: 0.9rem;
  height: fit-content;
  position: sticky;
  top: 80px;
  overflow: hidden;
}

.filters h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
}

.filters label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
  font-size: 0.87rem;
  color: var(--muted);
  min-width: 0;
}

.filters select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.ghost {
  width: 100%;
  margin-top: 0.2rem;
}

.gh-sync {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

.gh-sync summary {
  cursor: pointer;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--muted);
  -webkit-user-select: none;
  user-select: none;
  list-style: none;
}

.gh-sync summary::before {
  content: "\25B8\00A0";
  font-size: 0.75rem;
}

.gh-sync[open] summary::before {
  content: "\25BE\00A0";
}

.gh-sync-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.gh-sync-label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.87rem;
  color: var(--muted);
}

.gh-sync-label input {
  width: 100%;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  height: 30px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}

.filters .gh-sync-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.gh-sync-check input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
  cursor: pointer;
}

.gh-load-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.gh-load-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gh-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1rem;
  word-break: break-word;
}

.gh-status--error { color: var(--danger); }
.gh-status--success { color: var(--good); }

.gh-save-link {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--good);
  border: 1px solid var(--good);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  text-align: center;
  text-decoration: none;
}

.stats {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
}

.content {
  padding: 0.6rem;
  min-height: 70vh;
}

.project-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.8rem;
  overflow: hidden;
}

.project-group > header {
  padding: 0.55rem 0.7rem;
  background: #f6f8fa;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
}

.gantt-board {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}

.gantt-header {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(520px, 1.6fr) 108px 108px 80px;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #e0eaff;
  border-bottom: 1px solid var(--border);
}

.gantt-header-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
}

.collapse-all-btn {
  font-size: 0.72rem;
  height: 22px;
  padding: 0 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--muted);
  border-color: var(--border);
}

.gantt-header-right {
  position: relative;
  min-height: 46px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: linear-gradient(90deg, #e0eaff 0%, #d0e0ff 100%);
  overflow: hidden;
}

.gantt-year {
  position: absolute;
  top: 0;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8ecf0;
  border-right: 1px solid #c8d0d8;
  overflow: hidden;
}

.gantt-year span {
  font-size: 0.72rem;
  font-weight: 700;
  color: #3d4852;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
  pointer-events: none;
}

.gantt-quarter {
  position: absolute;
  top: 18px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #d8dee4;
  overflow: hidden;
}

.gantt-quarter span {
  font-size: 0.75rem;
  font-weight: 600;
  color: #3d4852;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 3px;
  pointer-events: none;
}

.gantt-project {
  border: 0;
  border-bottom: 1px solid #edf1f4;
  border-radius: 0;
  margin: 0;
}

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

.gantt-project-header {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(520px, 1.6fr) 108px 108px 80px;
  gap: 0.7rem;
  align-items: center;
  background: #f8fafc;
}

.project-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.gantt-project-title {
  font-weight: 600;
}

.gantt-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(520px, 1.6fr) 108px 108px 80px;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
  border-top: 1px solid #f0f2f4;
}

.gantt-left {
  min-width: 0;
}

.gantt-right {
  min-width: 520px;
}

.gantt-track {
  position: relative;
  width: 100%;
  min-height: 24px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: linear-gradient(90deg, #f6f8fa 0%, #eef2f6 100%);
  overflow: hidden;
}

.project-track {
  min-height: 20px;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(260px, 1fr) 120px 120px auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid #f0f2f4;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-main {
  min-width: 0;
}

.item-title {
  font-size: 0.9rem;
  margin: 0;
}

.item-meta {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 99px;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}

.pill.status-DONE { color: #fff; background: var(--good); border-color: var(--good); }
.pill.status-IN_PROGRESS { color: #fff; background: var(--accent); border-color: var(--accent); }
.pill.status-TODO { color: #fff; background: #6e7781; border-color: #6e7781; }
.pill.status-REQUESTED { color: #fff; background: #8250df; border-color: #8250df; }
.pill.status-BLOCKED { color: #fff; background: var(--danger); border-color: var(--danger); }
.pill.priority-High-priority { color: var(--danger); border-color: #f2b8be; }
.pill.priority-Medium-priority { color: var(--warn); border-color: #f4d9a7; }

.project-header-main {
  display: grid;
  gap: 0.45rem;
}

.project-headline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.project-schedule-summary {
  font-size: 0.78rem;
  color: var(--muted);
}

.project-timebar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

.schedule-track {
  width: 100%;
  height: 8px;
  border-radius: 99px;
  border: 1px solid #d8dee4;
  background: linear-gradient(90deg, #f6f8fa 0%, #eef2f6 100%);
  position: relative;
  overflow: hidden;
}

.schedule-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, #218bff 0%, #0969da 100%);
}

.schedule-bar.status-DONE { background: linear-gradient(90deg, #2da44e 0%, #1a7f37 100%); }
.schedule-bar.status-IN_PROGRESS { background: linear-gradient(90deg, #54aeff 0%, #0969da 100%); }
.schedule-bar.status-TODO { background: linear-gradient(90deg, #8c959f 0%, #6e7781 100%); }
.schedule-bar.status-REQUESTED { background: linear-gradient(90deg, #a475f9 0%, #8250df 100%); }
.schedule-bar.status-BLOCKED { background: linear-gradient(90deg, #ff938a 0%, #cf222e 100%); }

.schedule-bar.overdue {
  box-shadow: 0 0 0 1px #cf222e inset;
}

.schedule-empty {
  font-size: 0.77rem;
  color: var(--muted);
}

.timeline-date-col {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #cf222e;
  z-index: 2;
}

.gantt-today-line span {
  position: absolute;
  top: -18px;
  left: -16px;
  font-size: 0.68rem;
  color: #cf222e;
  font-weight: 600;
}

.timeline-date-col strong {
  display: block;
  color: var(--ink);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.item-actions button {
  height: 30px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

th,
td {
  border-bottom: 1px solid #edf1f4;
  padding: 0.5rem;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f6f8fa;
}

.row-title {
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-panel {
  position: fixed;
  right: 1rem;
  top: 90px;
  width: min(420px, 92vw);
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 0.9rem;
  transform: translateX(120%);
  transition: transform 200ms ease;
  z-index: 15;
}

.detail-panel.open {
  transform: translateX(0%);
}

.close-detail {
  margin-left: auto;
  display: block;
}

.detail-panel dl {
  margin: 0;
}

.detail-panel dt {
  margin-top: 0.7rem;
  font-weight: 600;
  font-size: 0.84rem;
}

.detail-panel dd {
  margin: 0.2rem 0;
  color: var(--muted);
  word-break: break-word;
}

.empty {
  padding: 1.2rem;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }

  .timeline-item,
  .gantt-header,
  .gantt-project-header,
  .gantt-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .timeline-date-col {
    text-align: left;
  }

  .gantt-right {
    min-width: 0;
  }

  .gantt-header-right {
    min-height: 32px;
  }

  input[type="search"] {
    width: min(290px, 70vw);
  }
}
