:root {
  --bg: #F9F6F1; --surface: #FFFFFF;
  --border: #E4E4E0; --border-strong: #CACAC4;
  --text-primary: #1A1A18; --text-secondary: #6B6B65; --text-tertiary: #9E9E98;
  --accent: #2563EB; --accent-light: #EFF4FF; --accent-mid: #BFCFFE;
  --green-bg: #ECFDF5; --green-text: #065F46; --green-solid: #198754;
  --amber-bg: #FFFBEB; --amber-text: #92400E;
  --purple-bg: #F5F3FF; --purple-text: #4C1D95;
  --red-bg: #FEF2F2; --red-text: #991B1B;
  --gray-bg: #F3F4F6; --gray-text: #374151;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

a { color: inherit; }

/* Environment banner（登入頁用的整列提示條，正式環境不渲染這個 div） */
.env-banner {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  padding: 5px 12px; text-align: center;
}
/* Environment tag（頁首標題後方的小標籤版本） */
.env-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 9px; border-radius: var(--radius-sm); flex-shrink: 0;
}
.env-banner-test { background: #B45309; color: #fff; }
.env-banner-dev { background: #4B5563; color: #fff; }

/* Top bar */
.topbar {
  background: #4B4B52;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 22px; font-weight: 600; color: #fff; text-decoration: none; }
.topbar-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.15); }
.topbar-nav a { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.75); text-decoration: none; padding: 5px 10px; border-radius: var(--radius-sm); transition: all 0.15s; }
.topbar-nav a:hover { color: #fff; background: rgba(255,255,255,0.1); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.lang-switcher { display: flex; align-items: center; }
.lang-select {
  appearance: none; -webkit-appearance: none; border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius-sm);
  padding: 5px 24px 5px 10px; font-size: 12px; font-weight: 500; color: #fff; cursor: pointer;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
  background-color: transparent; font-family: inherit;
}
.lang-select option { color: #1A1A18; }
.lang-select:hover { border-color: rgba(255,255,255,0.4); }
.lang-select:focus { outline: none; border-color: #fff; }
.role-badge {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.1); border-radius: var(--radius-sm);
  padding: 5px 12px; font-size: 12px; font-weight: 500; color: #fff;
  min-width: 0;
}
.role-badge-email {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-icon { flex-shrink: 0; }
.topbar .btn { background: transparent; border-color: rgba(255,255,255,0.25); color: #fff; }
.topbar .btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.4); color: #fff; }
.topbar .btn.preview-toggle-active,
.preview-toggle-active { background: var(--amber-bg); border-color: var(--amber-text); color: var(--amber-text); }
.topbar .btn.preview-toggle-active:hover,
.preview-toggle-active:hover { background: var(--amber-bg); border-color: var(--amber-text); color: var(--amber-text); }
.breadcrumb-bar { background: var(--border); border-bottom: 1px solid var(--border-strong); padding: 8px 32px; position: sticky; top: 56px; z-index: 90; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); max-width: 1360px; margin: 0 auto; }
.breadcrumb-sep { color: var(--text-tertiary); }
.breadcrumb-link { color: var(--accent); cursor: pointer; text-decoration: none; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

/* Layout */
.main { padding: 32px; max-width: 1360px; margin: 0 auto; }

/* Home */
.home-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.home-section-header .home-section-label { margin-bottom: 0; }
.home-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-tertiary); margin-bottom: 14px;
}
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 32px;
}
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px 28px; cursor: pointer; transition: all 0.18s; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; display: block; text-decoration: none; color: inherit;
}
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent); opacity: 0; transition: opacity 0.18s;
}
.project-card:hover { border-color: var(--accent-mid); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.project-card:hover::before { opacity: 1; }
.project-card.status-preparing::before { background: var(--gray-text); }
.project-card.status-evt::before { background: var(--amber-text); }
.project-card.status-dvt::before { background: var(--purple-text); }
.project-card.status-pvt::before { background: var(--accent); }
.project-card.status-mp::before { background: var(--green-text); }
.card-name { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; letter-spacing: -0.2px; }
.card-status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 100px; }
.card-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 5px; }
.card-updated {
  position: absolute; right: 20px; bottom: 10px; font-size: 9px; letter-spacing: 0.2px;
  color: var(--text-tertiary); opacity: 0.55;
}

.project-card.potential { border-style: dashed; border-width: 2px; box-shadow: none; }
.project-card.potential::before { display: none; }
.project-card.potential:hover { border-color: var(--accent); background: var(--accent-light); box-shadow: none; }
.potential-tag { font-size: 10px; color: var(--text-tertiary); font-weight: 500; margin-top: 4px; }

.project-card.closed { opacity: 0.6; }
.project-card.closed:hover { opacity: 1; }
.closed-projects-section summary { cursor: pointer; }
.closed-projects-section summary::marker { font-size: 10px; }

/* Status pills */
.pill-preparing { background: var(--gray-bg); color: var(--gray-text); }
.pill-evt  { background: var(--amber-bg); color: var(--amber-text); }
.pill-dvt  { background: var(--purple-bg); color: var(--purple-text); }
.pill-pvt  { background: var(--accent-light); color: var(--accent); }
.pill-mp   { background: var(--green-bg); color: var(--green-text); }

/* Delete button on card */
.card-delete-btn {
  position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: transparent; color: var(--text-tertiary); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s; z-index: 2;
  opacity: 0;
}
.project-card:hover .card-delete-btn { opacity: 1; }
.card-delete-btn:hover { background: var(--red-bg); color: #DC2626; }

/* Detail header */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.detail-header-left { display: flex; flex-direction: column; gap: 4px; }
.detail-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary); }
.detail-subtitle { font-size: 13px; color: var(--text-secondary); }
.detail-title-input {
  font-size: 26px; font-weight: 700; letter-spacing: -0.5px; color: var(--text-primary);
  border: none; border-bottom: 2px solid transparent; background: transparent; font-family: inherit;
  padding: 0 2px; width: 320px; transition: border-color 0.15s;
}
.detail-title-input:hover { border-bottom-color: var(--border); }
.detail-title-input:focus { outline: none; border-bottom-color: var(--accent); }
.detail-sub-input {
  font-size: 13px; color: var(--text-secondary); border: none; border-bottom: 1px solid transparent;
  background: transparent; font-family: inherit; padding: 0 2px; width: 240px; transition: border-color 0.15s;
}
.detail-sub-input:hover { border-bottom-color: var(--border); }
.detail-sub-input:focus { outline: none; border-bottom-color: var(--accent); }

.mp-header-block { display: flex; align-items: center; gap: 8px; }
.mp-header-label { font-size: 12px; color: var(--text-tertiary); font-weight: 500; white-space: nowrap; }
.mp-date-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px; font-size: 13px;
  color: var(--text-primary); transition: border-color 0.15s; width: 130px; text-align: center;
  background: var(--surface); font-family: inherit;
}
.mp-date-input:focus { outline: none; border-color: var(--accent); }
.mp-date-text { font-size: 13px; font-weight: 500; color: var(--text-primary); }

.date-mode-toggle { display: flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; font-size: 10px; font-weight: 500; flex-shrink: 0; }
.modal-field .date-mode-toggle { align-self: flex-start; }
.date-mode-toggle span { padding: 2px 7px; color: var(--text-tertiary); background: var(--surface); transition: all 0.12s; user-select: none; line-height: 1.7; cursor: pointer; }
.date-mode-toggle span:hover { background: var(--bg); }
.date-mode-toggle span.active { background: var(--accent); color: #fff; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.detail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.detail-card.full-width, .full-width { grid-column: 1 / -1; }
.detail-card-title { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 14px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.info-value { font-size: 13px; color: var(--text-primary); font-weight: 500; text-align: right; flex: 1; min-width: 0; word-break: break-word; }
.info-input {
  border: none; border-bottom: 1px solid transparent; border-radius: 0; padding: 0 2px; font-size: 13px;
  font-weight: 500; color: var(--text-primary); text-align: right; background: transparent; font-family: inherit;
  flex: 1; min-width: 0; transition: border-color 0.15s;
}
.info-input:hover { border-bottom-color: var(--border); }
.info-input:focus { outline: none; border-bottom-color: var(--accent); }

.status-select {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 28px 5px 10px; font-size: 13px; font-weight: 500; cursor: pointer; min-width: 130px;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B65' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
  background-color: var(--surface); font-family: inherit;
}
.status-select:focus { outline: none; border-color: var(--accent); }

.filter-date-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.filter-date-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 10px;
  font-size: 13px; font-family: inherit; color: var(--text-primary); background-color: var(--surface);
  transition: border-color 0.15s;
}
.filter-date-input:focus { outline: none; border-color: var(--accent); }

/* Stage track */
.stage-track { display: flex; gap: 0; margin-top: 4px; }
.stage-item { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; }
.stage-item:not(:last-child)::after { content: ''; position: absolute; top: 14px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.stage-item.line-fill:not(:last-child)::after { background: var(--green-solid); }
.stage-dot {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600;
  color: var(--text-tertiary); z-index: 1; position: relative; transition: all 0.2s;
}
.stage-item.done .stage-dot { background: var(--green-solid); border-color: var(--green-solid); color: #fff; }
.stage-item.active .stage-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-light); }
.stage-name { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; font-weight: 500; text-align: center; }
.stage-item.done .stage-name { color: var(--green-text); }
.stage-item.active .stage-name { color: var(--accent); font-weight: 700; }
.stage-item.clickable .stage-dot, .stage-item.clickable .stage-name { cursor: pointer; }
.stage-item.clickable:hover .stage-dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }
.stage-item.clickable:hover .stage-name { color: var(--accent); }

.stage-date-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 8px; cursor: default; }
.stage-date-row { display: flex; align-items: center; gap: 4px; }
.stage-date-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 2px; font-size: 11px;
  color: var(--text-primary); width: 92px; flex-shrink: 0; text-align: center; transition: border-color 0.15s;
  background: var(--surface); font-family: inherit;
}
.stage-date-input:focus { outline: none; border-color: var(--accent); }
.stage-date-text { font-size: 11px; color: var(--text-primary); font-weight: 500; text-align: center; display: block; width: 92px; flex-shrink: 0; padding: 3px 2px; }
.stage-date-text.empty { color: var(--text-tertiary); }

.stage-attempts { display: flex; flex-direction: column; align-items: center; gap: 3px; margin-top: 3px; cursor: default; }
.stage-attempt-row { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.stage-attempt-round { font-size: 10px; color: var(--text-tertiary); font-weight: 600; min-width: 14px; flex-shrink: 0; }
.stage-attempt-date-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px 2px; font-size: 11px;
  width: 92px; flex-shrink: 0; text-align: center; background: var(--surface); font-family: inherit; color: var(--text-primary);
  transition: border-color 0.15s;
}
.stage-attempt-date-input:focus { outline: none; border-color: var(--accent); }
.stage-attempt-date-text { font-size: 11px; color: var(--text-primary); font-weight: 500; text-align: center; display: block; width: 92px; flex-shrink: 0; padding: 3px 2px; }
.stage-attempt-remove { border: none; background: transparent; color: var(--text-tertiary); font-size: 9px; cursor: pointer; padding: 0 2px; width: 14px; flex-shrink: 0; }
.stage-attempt-remove:hover { color: #DC2626; }
.stage-attempt-remove-spacer { width: 14px; flex-shrink: 0; }
.stage-attempt-add { border: none; background: transparent; color: var(--accent); font-size: 10px; cursor: pointer; padding: 2px 0; font-weight: 600; }
.stage-attempt-add:hover { text-decoration: underline; }

/* Notes */
.note-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 13px; color: var(--text-primary); font-family: inherit; resize: vertical; min-height: 80px;
  flex: 1; transition: border-color 0.15s; background: var(--surface);
}
.note-textarea:focus { outline: none; border-color: var(--accent); }
.note-textarea-lg { min-height: 360px; }

/* Buttons */
.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 5px 12px; font-size: 12px; font-weight: 500; color: var(--text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; transition: all 0.15s; white-space: nowrap;
  font-family: inherit; text-decoration: none;
}
.btn:hover { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; color: #fff; }
.btn-danger { color: #DC2626; }
.btn-danger:hover { border-color: #DC2626; background: var(--red-bg); color: #DC2626; }
.save-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Files */
.file-list { display: flex; flex-direction: column; }
.file-item { display: grid; grid-template-columns: 72px auto 1fr auto; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg); }
.file-icon { min-width: 34px; height: 34px; padding: 0 3px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; letter-spacing: -0.2px; flex-shrink: 0; }
.icon-pdf { background: #FEE2E2; color: #DC2626; }
.icon-doc { background: #DBEAFE; color: #1D4ED8; }
.icon-xls { background: #D1FAE5; color: #065F46; }
.icon-ppt { background: #FEF3C7; color: #92400E; }
.icon-img { background: #F3E8FF; color: #6D28D9; }
.icon-def { background: var(--gray-bg); color: var(--gray-text); }
.file-date { font-size: 12px; color: var(--text-tertiary); }
.file-info { min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.file-name-link { text-decoration: none; cursor: pointer; }
.file-name-link:hover { text-decoration: underline; color: var(--accent); }
.file-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 30px; height: 30px; padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); font-size: 13px; text-decoration: none; cursor: pointer;
  font-family: inherit; transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg); }
.icon-btn.btn-danger:hover { border-color: #DC2626; background: var(--red-bg); color: #DC2626; }
.detail-delete-icon-btn { display: none; }
.file-item .btn-danger { opacity: 0; transition: opacity 0.15s; }
.file-item:hover .btn-danger { opacity: 1; }
.empty-hint { text-align: center; padding: 20px; color: var(--text-tertiary); font-size: 13px; }

/* Upload zone (dropzone) */
.upload-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-md); padding: 24px; text-align: center;
  color: var(--text-tertiary); font-size: 13px; cursor: pointer; transition: all 0.18s; margin-top: 12px;
  background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.upload-zone-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone-text { font-weight: 500; }
.upload-zone-sub { font-size: 11px; margin-top: 4px; color: var(--text-tertiary); }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--text-primary); color: #fff; padding: 10px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md); opacity: 1; transform: translateY(0);
  transition: all 0.25s;
}
.toast-hide { opacity: 0; transform: translateY(8px); }
.toast-error { background: #DC2626; }
.toast-success { background: var(--text-primary); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 380px; max-width: 90vw; box-shadow: var(--shadow-md); }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--text-primary); }

/* Gantt-style timeline: markers positioned by month index, not actual day-of-month proportion,
   so every month is an equal-width column and both rows (MP Target / Stage Progress) line up
   on the same month. Visually presented as a table (bordered container, column gridlines, row
   separators) even though the underlying layout is absolutely-positioned, not a real table.
   Rendered inline as a third Active Projects view (not a modal), so it can use the full
   page width; .gantt-scroll only kicks in if the page is narrower than the gantt's min-width. */
.gantt-scroll { overflow-x: auto; }
.gantt-nav-inline { align-items: center; gap: 6px; }
.gantt-nav-btn {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary);
  text-decoration: none; font-size: 14px; background: var(--surface);
}
.gantt-nav-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.gantt-nav-today { font-size: 12px; color: var(--accent); text-decoration: none; }
.gantt-nav-today:hover { text-decoration: underline; }
.gantt { min-width: 900px; padding: 0; border: 1px solid #A9B8C6; border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }

/* Row-label column (left) and corner cell share the same fixed width as flex siblings
   of .gantt-axis-row / .gantt-track, so the 0-100% pct positioning inside those two
   still lines up vertically column-for-column between the header and each row. */
.gantt-header-row { display: flex; border-bottom: 1px solid var(--border); }
.gantt-corner { width: 64px; flex-shrink: 0; border-right: 1px solid var(--border); }

/* min-height (not just padding) matters here: the row's only children are
   position:absolute ticks, which don't contribute to its box height, so without
   an explicit min-height the row collapses and its own border-bottom cuts
   through the tick text instead of sitting below it. */
.gantt-axis-row { position: relative; flex: 1; min-width: 0; min-height: 36px; padding: 10px 0; }
.gantt-tick { position: absolute; top: 10px; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--text-tertiary); white-space: nowrap; }

.gantt-row { display: flex; border-bottom: 1px solid var(--border); }
.gantt-row:last-child { border-bottom: none; }
.gantt-row-label {
  width: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 11px; font-weight: 600; line-height: 1.3; color: var(--text-tertiary); padding: 4px;
  border-right: 1px solid var(--border);
}
.gantt-track { position: relative; flex: 1; min-width: 0; padding: 18px 0; }
.gantt-today-col { position: absolute; top: 0; bottom: 0; background: var(--accent-light); z-index: 0; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); z-index: 0; }
.gantt-stack { position: absolute; top: 18px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 12px; align-items: center; z-index: 2; }
.gantt-stack-month { display: none; }
.gantt-marker {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 14px 8px; border-radius: var(--radius-md);
  min-width: 84px; font-size: 12px; font-weight: 700; line-height: 1.3;
  text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, transform 0.15s;
}
.gantt-marker:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.gantt-marker-code { font-size: 12px; font-weight: 700; }
.gantt-marker-label { font-size: 10px; font-weight: 600; opacity: 0.8; }
.gantt-marker-date { font-size: 10px; font-weight: 500; opacity: 0.6; }
.gantt-marker.status-preparing { background: var(--gray-bg); color: var(--gray-text); border: 1px solid #D1D5DB; }
.gantt-marker.status-evt { background: var(--amber-bg); color: var(--amber-text); border: 1px solid #FDE68A; }
.gantt-marker.status-dvt { background: var(--purple-bg); color: var(--purple-text); border: 1px solid #DDD6FE; }
.gantt-marker.status-pvt { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-mid); }
.gantt-marker.status-mp { background: var(--green-bg); color: var(--green-text); border: 1px solid #A7F3D0; }

@media (max-width: 640px) {
  .gantt { min-width: 0; }
  .gantt-header-row { display: none; }
  .gantt-row { flex-direction: column; }
  .gantt-row-label {
    width: auto; justify-content: flex-start; border-right: none; border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: 0.04em; padding: 7px 12px;
  }
  .gantt-track { padding: 12px; min-height: 0 !important; }
  .gantt-gridline, .gantt-today-col { display: none; }
  .gantt-stack {
    position: static; transform: none; left: auto !important; width: 100%;
    align-items: stretch; margin-bottom: 14px;
  }
  .gantt-stack:last-child { margin-bottom: 0; }
  .gantt-stack-month { display: block; font-size: 11px; font-weight: 700; color: var(--text-tertiary); margin-bottom: 6px; }
  .gantt-marker { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px; width: 100%; }
}
.modal-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.modal-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.modal-input { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; font-family: inherit; color: var(--text-primary); transition: border-color 0.15s; width: 100%; }
.modal-input:focus { outline: none; border-color: var(--accent); }
.modal-textarea { resize: vertical; min-height: 100px; }
.modal-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Confirm modal */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 500; display: flex; align-items: center; justify-content: center; }
.confirm-box { background: var(--surface); border-radius: var(--radius-lg); padding: 24px 28px; width: 340px; max-width: 90vw; box-shadow: var(--shadow-md); }
.confirm-msg { font-size: 14px; color: var(--text-primary); line-height: 1.6; margin-bottom: 20px; }
.confirm-row { display: flex; justify-content: flex-end; gap: 8px; }

/* Announcement section */
.announce-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.announce-cards { display: flex; flex-direction: column; }
.announce-card { cursor: pointer; transition: background 0.15s; position: relative; display: flex; align-items: center; gap: 16px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.announce-cards .announce-card:last-child, .announce-more-grid .announce-card:last-child { border-bottom: none; }
.announce-card:hover { background: var(--bg); }
.announce-card-date { font-size: 11px; color: var(--text-tertiary); font-weight: 500; white-space: nowrap; flex-shrink: 0; width: 72px; }
.announce-card-body { flex: 1; min-width: 0; }
.announce-card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.announce-card-preview { font-size: 12px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.announce-card-arrow { font-size: 13px; color: var(--text-tertiary); flex-shrink: 0; transition: color 0.15s; }
.announce-card:hover .announce-card-arrow { color: var(--accent); }
.announce-more-wrap { overflow: hidden; max-height: 0; transition: max-height 0.4s ease; }
.announce-more-wrap.open { max-height: 2000px; }
.announce-more-grid { display: flex; flex-direction: column; }
.announce-toggle-btn { display: flex; align-items: center; gap: 6px; margin: 10px auto 0; font-size: 12px; font-weight: 500; color: var(--text-secondary); background: none; border: 1px solid var(--border); border-radius: 100px; padding: 4px 14px; cursor: pointer; transition: all 0.15s; }
.announce-toggle-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.announce-toggle-btn .arrow { transition: transform 0.3s; display: inline-block; }
.announce-toggle-btn.open .arrow { transform: rotate(180deg); }

.ann-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 300; display: flex; align-items: center; justify-content: center; }
.ann-modal { background: var(--surface); border-radius: var(--radius-lg); padding: 28px 32px; width: 520px; max-width: 90vw; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-md); position: relative; }
.ann-modal-date { font-size: 12px; color: var(--text-tertiary); font-weight: 500; margin-bottom: 8px; }
.ann-modal-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; line-height: 1.4; }
.ann-modal-body { font-size: 14px; color: var(--text-secondary); line-height: 1.8; white-space: pre-wrap; }
.ann-modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 18px; color: var(--text-tertiary); cursor: pointer; }
.ann-modal-close:hover { color: var(--text-primary); }
.ann-add-modal { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 480px; max-width: 90vw; box-shadow: var(--shadow-md); }
.ann-body-input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; font-family: inherit; color: var(--text-primary); resize: vertical; min-height: 120px; transition: border-color 0.15s; }
.ann-body-input:focus { outline: none; border-color: var(--accent); }

/* Autosave indicator */
.autosave-badge { font-size: 11px; color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity 0.3s; }
.autosave-badge.show { opacity: 1; }
.autosave-badge.saved { color: #059669; }

/* Potential detail */
.potential-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 100px; background: var(--amber-bg); color: var(--amber-text); margin-bottom: 4px; }
.closed-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 100px; background: var(--gray-bg); color: var(--gray-text); margin-bottom: 4px; }
.promote-btn { background: var(--green-bg); border-color: #6EE7B7; color: var(--green-text); font-weight: 600; }
.promote-btn:hover { background: #D1FAE5; border-color: #34D399; color: var(--green-text); }

/* Roadmap section */
.roadmap-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.roadmap-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.roadmap-empty { text-align: center; padding: 28px; color: var(--text-tertiary); font-size: 13px; border: 2px dashed var(--border); border-radius: var(--radius-md); }

/* Settings */
.settings-tabs-row {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); margin: 12px 0 20px;
}
.settings-tabs { display: flex; gap: 24px; }
.settings-tab {
  padding: 10px 0; font-size: 13px; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Simple table */
.table-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; overflow-x: auto; }
.simple-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.simple-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-tertiary); padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.simple-table td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.simple-table tbody tr:last-child td { border-bottom: none; }
.change-log-table td:nth-child(1), .change-log-table td:nth-child(2),
.change-log-table td:nth-child(3), .change-log-table td:nth-child(5) { white-space: nowrap; }
.simple-table tbody tr:hover { background: var(--bg); }
.table-row-link { cursor: pointer; }
.new-user-row { background: var(--accent-light); }
.new-user-row:hover { background: var(--accent-light); }
.new-user-row .modal-input { max-width: 260px; }

/* ── Responsive ─────────────────────────────────────────────────── */

.info-notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
.notes-col { display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .info-notes-grid { grid-template-columns: 1fr; }

  .detail-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .detail-header > div:last-child { align-items: flex-start; }
  .detail-title-input { width: 100%; }
  .detail-sub-input { width: 100%; }
  .mp-header-block { flex-wrap: wrap; }
  .mp-date-input { width: auto; max-width: 160px; min-width: 120px; }
}

@media (max-width: 640px) {
  .main { padding: 16px; }

  .topbar {
    height: auto; min-height: 56px; padding: 8px 16px;
    flex-wrap: wrap; row-gap: 6px;
  }
  .topbar-left { flex-wrap: wrap; row-gap: 6px; }
  .topbar-nav { border-left: none; padding-left: 0; margin-left: 0; }
  .topbar-right { flex-basis: 100%; justify-content: flex-end; }
  .breadcrumb-bar { padding: 6px 16px; position: static; }
  .role-badge-email { max-width: 140px; }

  .home-section-header { flex-wrap: wrap; row-gap: 8px; }

  /* 標題/副標各自獨立一行；Back 隱藏（breadcrumb 已可回首頁）、Delete 縮成小圖示按鈕，
     跟 MP Target 共用同一行、垂直置中對齊 */
  .detail-header { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .detail-header-left { display: contents; }
  .detail-title, .detail-title-input,
  .detail-subtitle, .detail-sub-input { flex-basis: 100%; }
  .mp-header-block { flex: 1; min-width: 0; }
  .detail-header > div:last-child { flex-shrink: 0; }
  .detail-back-link, .detail-delete-btn { display: none; }
  .detail-delete-icon-btn { display: inline-flex; }
  .autosave-badge { display: none; }

  .project-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .info-row { flex-wrap: wrap; row-gap: 4px; }
  .info-input { width: 100%; text-align: left; }

  .detail-card { padding: 16px; }

  .stage-track {
    overflow-x: auto; padding-bottom: 8px; margin-bottom: -2px;
    scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
  }
  .stage-track::-webkit-scrollbar { height: 5px; }
  .stage-track::-webkit-scrollbar-thumb {
    background: var(--border-strong); border-radius: 3px;
  }
  .stage-track .stage-item { flex: 0 0 72px; }

  .save-row, .modal-row, .confirm-row { flex-wrap: wrap; }

  .modal, .ann-modal, .ann-add-modal { padding: 20px; }

  .announce-card-date { width: 56px; }
}

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