:root {
  --purple-950: #170833;
  --purple-900: #1f0d47;
  --purple-800: #2e1065;
  --purple-700: #4c1d95;
  --purple-600: #6d28d9;
  --purple-500: #7c3aed;
  --purple-300: #c4b5fd;
  --purple-200: #ddd6fe;
  --purple-100: #ede9fe;
  --purple-50: #f5f3ff;
  --teal-700: #0f766e;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-200: #99f6e4;
  --teal-100: #ccfbf1;
  --yellow-500: #eab308;
  --yellow-400: #facc15;
  --yellow-300: #fde047;
  --yellow-100: #fef9c3;
  --yellow-ink: #713f12;
  --ink: #1f1637;
  --muted: #6e6787;
  --bg: #f6f4fb;
  --card: #ffffff;
  --border: #e5e0f1;
  --shadow: 0 1px 2px rgba(31, 22, 55, 0.05), 0 6px 20px rgba(76, 29, 149, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
}
a { color: var(--purple-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0.4em 0; }

/* Top bar */
.topbar { background: linear-gradient(90deg, var(--purple-950), var(--purple-800) 60%, #123b4a); color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--yellow-400); box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.25); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--purple-200); padding: 8px 12px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.08); }
.nav a.active { color: var(--purple-900); background: var(--yellow-400); }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 24px 16px 40px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; transition: opacity 0.4s; }
.flash.ok { background: var(--teal-100); color: var(--teal-700); border: 1px solid var(--teal-200); }
.flash.err { background: var(--yellow-100); color: var(--yellow-ink); border: 1px solid var(--yellow-300); }
.flash.hide { opacity: 0; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--purple-200); background: #fff; color: var(--purple-700); font-weight: 500; font-size: 0.9rem; cursor: pointer; font-family: inherit; line-height: 1.3; }
.btn:hover { background: var(--purple-50); text-decoration: none; }
.btn.primary { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }
.btn.primary:hover { background: var(--purple-700); }
.btn.teal { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }
.btn.teal:hover { background: var(--teal-700); }
.btn.yellow { background: var(--yellow-400); border-color: var(--yellow-400); color: var(--purple-900); }
.btn.yellow:hover { background: var(--yellow-300); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--purple-50); color: var(--purple-700); }
.btn.sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn.danger { color: #9f1239; border-color: #fecdd3; }
.btn.danger:hover { background: #fff1f2; }
form.inline { display: inline; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Hero */
.hero { background: linear-gradient(135deg, var(--purple-900) 0%, var(--purple-700) 55%, var(--teal-700) 100%); color: #fff; border-radius: 20px; padding: 28px 28px 24px; margin-bottom: 20px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(250,204,21,0.35), rgba(250,204,21,0) 70%); }
.hero h1 { font-size: 1.7rem; }
.hero .subtitle { color: var(--purple-200); }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.stat { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; color: var(--yellow-300); }
.stat span { font-size: 0.8rem; color: var(--purple-100); }
.stat.teal b { color: var(--teal-200); }

/* Launch schedule */
.month-block { margin-bottom: 22px; }
.month-title { font-size: 0.95rem; color: var(--purple-700); font-weight: 700; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.month-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.launch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.launch-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; }
.launch-card.overdue { border-color: var(--yellow-400); }
.launch-date { text-align: center; background: var(--purple-100); border-radius: 10px; padding: 6px 4px; color: var(--purple-800); }
.launch-date .day { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.launch-date .wd { font-size: 0.75rem; color: var(--purple-600); }
.launch-name { font-weight: 700; font-size: 1.02rem; color: var(--ink); }
.launch-meta { color: var(--muted); font-size: 0.82rem; margin: 2px 0 6px; }
.launch-meta b { color: var(--purple-700); font-weight: 600; }
.dday { font-weight: 700; font-size: 0.9rem; padding: 5px 10px; border-radius: 999px; background: var(--purple-50); color: var(--purple-700); white-space: nowrap; }
.dday.soon { background: var(--yellow-400); color: var(--purple-900); }
.dday.today { background: var(--yellow-400); color: var(--purple-900); animation: pulse 1.6s infinite; }
.dday.launched { background: var(--teal-100); color: var(--teal-700); }
.dday.past { background: var(--yellow-100); color: var(--yellow-ink); }
.dday.tbd { background: #f1eff6; color: var(--muted); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(250,204,21,0.5); } 50% { box-shadow: 0 0 0 6px rgba(250,204,21,0); } }

/* Progress */
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress { flex: 1; height: 8px; background: var(--purple-100); border-radius: 999px; overflow: hidden; min-width: 60px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal-500), var(--teal-600)); border-radius: 999px; }
.progress-label { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Badges / chips */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.st-pending { background: #eeecf4; color: var(--muted); }
.st-in_progress { background: var(--purple-100); color: var(--purple-700); }
.st-done { background: var(--teal-100); color: var(--teal-700); }
.st-blocked { background: var(--yellow-100); color: var(--yellow-ink); border: 1px solid var(--yellow-300); }
.ps-not_started { background: #f1eff6; color: var(--muted); border: 1px dashed var(--purple-300); }
.ps-active { background: var(--purple-100); color: var(--purple-700); }
.ps-launched { background: var(--teal-100); color: var(--teal-700); }
.ps-paused { background: var(--yellow-100); color: var(--yellow-ink); }
.ps-cancelled { background: #eeecf4; color: var(--muted); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.74rem; background: #f1eff6; color: var(--muted); white-space: nowrap; vertical-align: middle; }
.chip.warn { background: var(--yellow-400); color: var(--purple-900); font-weight: 600; }
.chip.soon { background: var(--yellow-100); color: var(--yellow-ink); font-weight: 600; }
.chip.teal { background: var(--teal-100); color: var(--teal-700); }
.chip.purple { background: var(--purple-100); color: var(--purple-700); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; background: var(--purple-50); white-space: nowrap; }
td:first-child { min-width: 200px; }
td .row-link { display: inline-block; min-width: 160px; }
td.nowrap { white-space: nowrap; }
tr:hover td { background: #faf9fd; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-line { line-height: 1.5; padding: 2px 0; white-space: nowrap; }
.cell-line + .cell-line { border-top: 1px dashed var(--border); }
.row-link { font-weight: 600; color: var(--ink); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.filters a.active { background: var(--purple-700); border-color: var(--purple-700); color: #fff; }
.filters a:hover { text-decoration: none; border-color: var(--purple-300); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.field .hint { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
input[type="text"], input[type="date"], input[type="password"], input[type="url"], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--purple-300); border-color: var(--purple-500); }
textarea { min-height: 96px; resize: vertical; }
input[type="file"] { font: inherit; font-size: 0.85rem; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-row .field { flex: 1; min-width: 140px; }
.form-row .field.grow { flex: 3; }

/* Project detail */
.project-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
@media (max-width: 700px) { .project-head { grid-template-columns: 1fr; } }
.project-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.project-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--muted); font-size: 0.88rem; margin-top: 6px; }
.project-meta b { color: var(--ink); font-weight: 600; }
.launch-big { text-align: right; }
.launch-big .label { font-size: 0.75rem; color: var(--muted); }
.launch-big .date { font-size: 1.2rem; font-weight: 700; color: var(--purple-800); }
.summary-box { margin-top: 12px; background: var(--purple-50); border-left: 3px solid var(--purple-400, var(--purple-500)); padding: 10px 14px; border-radius: 0 10px 10px 0; }

.stage-group { margin-top: 18px; }
.stage-group-title { font-size: 0.8rem; color: var(--teal-700); font-weight: 700; letter-spacing: 0.04em; margin-bottom: 6px; }
.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stage { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; align-items: start; }
.stage.done { background: #f4fbfa; border-color: var(--teal-200); }
.stage.in_progress { border-color: var(--purple-300); box-shadow: 0 0 0 3px var(--purple-50); }
.stage.blocked, .stage.overdue { border-color: var(--yellow-400); }
.stage-seq { width: 30px; height: 30px; border-radius: 50%; background: var(--purple-100); color: var(--purple-700); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; }
.stage.done .stage-seq { background: var(--teal-600); color: #fff; }
.stage.in_progress .stage-seq { background: var(--purple-600); color: #fff; }
.stage-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; display: flex; gap: 4px 14px; flex-wrap: wrap; }
.stage-conclusion { margin-top: 8px; background: var(--yellow-100); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; }
.stage-conclusion .label { font-size: 0.72rem; color: var(--yellow-ink); font-weight: 700; display: block; margin-bottom: 2px; }
.stage-files { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.stage-files li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stage-files .meta { color: var(--muted); font-size: 0.75rem; }
.stage-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
details.edit { margin-top: 8px; }
details.edit summary { cursor: pointer; color: var(--purple-600); font-size: 0.85rem; font-weight: 600; user-select: none; }
details.edit[open] summary { margin-bottom: 8px; }
.edit-panel { background: var(--purple-50); border-radius: 10px; padding: 12px; }
.edit-panel + .edit-panel { margin-top: 8px; }
.edit-panel h4 { margin: 0 0 8px; font-size: 0.85rem; color: var(--purple-700); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }
.list .main { flex: 1; min-width: 200px; }
.list .meta { color: var(--muted); font-size: 0.8rem; }
.list li.done .title { text-decoration: line-through; color: var(--muted); }
.title { font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--purple-200); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal-500); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--teal-200); }
.timeline .date { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.meeting-content { white-space: pre-wrap; line-height: 1.75; }
.decisions-box { background: var(--yellow-100); border-radius: 10px; padding: 12px 16px; white-space: pre-wrap; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.empty-action { margin-top: 12px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mt { margin-top: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.count { background: var(--purple-100); color: var(--purple-700); font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; font-weight: 700; }
.count.warn { background: var(--yellow-400); color: var(--purple-900); }
.login-box { max-width: 380px; margin: 60px auto; }

@media (max-width: 600px) {
  .launch-card { grid-template-columns: 56px 1fr; }
  .launch-card .dday { grid-column: 2; justify-self: start; }
  .stage { grid-template-columns: 30px 1fr; }
  .stage-actions { grid-column: 2; flex-direction: row; }
  .hero { padding: 22px 18px; }
  h1 { font-size: 1.35rem; }
}

/* grid 子項目允許縮小，避免手機版編輯面板超出卡片 */
.stage > div, .launch-card > div, .project-head > div { min-width: 0; }
.edit-panel { overflow: hidden; }

/* 業績貢獻信心度 */
.cf-high { background: var(--yellow-400); color: var(--purple-900); }
.cf-medium { background: var(--purple-200); color: var(--purple-800); }
.cf-low { background: var(--teal-100); color: var(--teal-700); border: 1px solid var(--teal-200); }

/* 首頁年曆 */
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; font-size: 0.78rem; color: var(--purple-100); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-active { background: #fff; }
.lg-planned { background: rgba(255,255,255,0.35); border: 1px dashed rgba(255,255,255,0.7); }
.lg-launched { background: var(--teal-200); }
.lg-paused { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); }
.plan-year { margin-bottom: 22px; }
.plan-year-title { font-size: 1.05rem; color: var(--purple-800); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 8px; }
@media (max-width: 420px) { .plan-grid { grid-template-columns: repeat(2, 1fr); } }
.plan-cell { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 10px 8px; min-height: 120px; display: flex; flex-direction: column; gap: 6px; }
.plan-cell.past { background: #faf9fd; }
.plan-cell.current { border-color: var(--yellow-400); box-shadow: 0 0 0 3px var(--yellow-100); }
.plan-month { font-weight: 700; color: var(--purple-800); display: flex; justify-content: space-between; align-items: center; }
.plan-events { font-size: 0.7rem; color: var(--muted); line-height: 1.4; border-left: 2px solid var(--purple-200); padding-left: 6px; }
.plan-chips { display: flex; flex-direction: column; gap: 6px; }
.plan-empty { color: var(--border); text-align: center; font-size: 0.8rem; padding-top: 8px; }
.plan-chip { display: block; border-radius: 9px; padding: 6px 8px; font-size: 0.78rem; line-height: 1.35; border: 1px solid transparent; color: var(--ink); }
.plan-chip:hover { text-decoration: none; filter: brightness(0.97); }
.chip-head { display: flex; gap: 5px; align-items: baseline; flex-wrap: wrap; }
.chip-day { font-size: 0.68rem; color: var(--purple-600); font-weight: 700; white-space: nowrap; }
.chip-name { font-weight: 600; }
.chip-sub { display: flex; justify-content: space-between; gap: 6px; font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.chip-dday { font-weight: 700; color: var(--purple-700); white-space: nowrap; }
.plan-chip .progress-wrap { margin-top: 4px; }
.plan-chip .progress { height: 5px; }
.plan-chip.tier-active { background: var(--purple-100); border-color: var(--purple-300); }
.plan-chip.tier-active .chip-name { color: var(--purple-900); }
.plan-chip.tier-planned { background: transparent; border: 1px dashed var(--purple-200); opacity: 0.55; }
.plan-chip.tier-planned:hover { opacity: 0.9; }
.plan-chip.tier-launched { background: var(--teal-100); border-color: var(--teal-200); }
.plan-chip.tier-launched .chip-name { color: var(--teal-700); }
.plan-chip.tier-paused { background: #f1eff6; opacity: 0.6; }
.plan-chip.tier-paused .chip-name { text-decoration: line-through; color: var(--muted); }
.launch-card.tier-planned { opacity: 0.6; border-style: dashed; box-shadow: none; }
.launch-card.tier-planned:hover { opacity: 1; }
.launch-card.tier-paused { opacity: 0.6; }
.launch-card.tier-launched { border-color: var(--teal-200); }

/* 首頁：專案底色依業績貢獻信心度（高黃、中紫、低綠），淡化與劃線仍由執行層級決定 */
.plan-chip.cf-bg-high, .launch-card.cf-bg-high { background: var(--yellow-100); border-color: var(--yellow-400); }
.plan-chip.cf-bg-medium, .launch-card.cf-bg-medium { background: var(--purple-100); border-color: var(--purple-300); }
.plan-chip.cf-bg-low, .launch-card.cf-bg-low { background: var(--teal-100); border-color: var(--teal-200); }
.plan-chip.cf-bg-high .chip-name { color: var(--purple-900); }
.plan-chip.cf-bg-low .chip-name { color: var(--teal-700); }
.plan-chip.tier-planned.cf-bg-high, .plan-chip.tier-planned.cf-bg-medium, .plan-chip.tier-planned.cf-bg-low { border-style: dashed; }
