:root {
  --bg: #f7f6f1;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --surface-green: #f2f7f2;
  --line: #e4e1d8;
  --line-strong: #d6d1c5;
  --text: #24312b;
  --muted: #737b74;
  --faint: #969d96;
  --green: #234f3a;
  --green-2: #2f7357;
  --sage: #dfe9df;
  --yellow: #9b731d;
  --yellow-bg: #fbf2d7;
  --orange: #b8562b;
  --orange-bg: #fff0e8;
  --red: #a7433d;
  --bluegreen: #2f766f;
  --shadow: 0 10px 28px rgba(36, 49, 43, 0.06);
  font-family: Inter, "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #cdd9cd;
  border-radius: 8px;
  background: var(--surface-green);
  color: var(--green);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 14px;
}

.brand small,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.nav-main,
.nav-admin {
  display: grid;
  gap: 4px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 7px;
  color: #4f5d55;
  background: transparent;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  background: #eef4ee;
  color: var(--green);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 246, 241, 0.88);
  backdrop-filter: blur(18px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  font-weight: 760;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0;
}

.content {
  width: min(1440px, 100%);
  padding: 24px 30px 44px;
}

.page-stack {
  display: grid;
  gap: 16px;
}

.top-actions,
.section-actions,
.dialog-actions,
.row-actions,
.hero-controls,
.export-actions,
.tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-pill,
.status,
.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  line-height: 1;
  white-space: nowrap;
  background: #edf2ed;
  color: var(--green);
}

.mode-pill.admin {
  background: #e7f0ee;
  color: var(--bluegreen);
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 7px;
  font-weight: 720;
  white-space: nowrap;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-button {
  background: #f8e8e6;
  color: var(--red);
}

.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost {
  border-color: transparent;
  background: transparent;
}

i[data-lucide] {
  width: 16px;
  height: 16px;
  flex: none;
}

.panel,
.notion-doc,
.project-detail,
.report-hero,
.cafe-hero,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(36, 49, 43, 0.03);
}

.panel,
.notion-doc,
.project-detail {
  padding: 18px;
}

.report-hero,
.cafe-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  background: #fbfaf6;
}

.report-hero h2,
.cafe-hero h2 {
  margin-top: 4px;
  font-size: 22px;
}

.report-hero p,
.cafe-hero p,
.export-panel p {
  max-width: 780px;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.section-head,
.dialog-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.summary-card {
  position: relative;
  min-height: 136px;
  padding: 16px;
}

.summary-card span {
  display: block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1.05;
}

.summary-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.summary-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #edf3ed;
  color: var(--green);
}

.summary-card.warn .summary-icon,
.summary-card.warn {
  background: #fff8f3;
}

.summary-card.warn .summary-icon {
  color: var(--orange);
}

.summary-card.pending .summary-icon,
.summary-card.pending {
  background: #fffaf0;
}

.summary-card.pending .summary-icon {
  color: var(--yellow);
}

.dashboard-layout,
.cafe-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.75fr);
  gap: 16px;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.brief-column {
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.brief-column h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--green);
}

.brief-column.warn {
  background: #fff8f3;
  border-color: #f2d4c2;
}

.brief-column.decision {
  background: #fffaf0;
  border-color: #ead9a9;
}

.notion-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notion-list li {
  position: relative;
  padding-left: 18px;
}

.notion-list li::before {
  position: absolute;
  top: 8px;
  left: 2px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #a8b5aa;
  content: "";
}

.notion-list strong,
.notion-list span {
  display: block;
}

.notion-list strong {
  margin-bottom: 3px;
  font-size: 13px;
}

.notion-list span {
  color: #58635c;
  font-size: 13px;
  line-height: 1.6;
}

.soft-panel {
  background: var(--surface-soft);
}

.compact-project-list,
.attention-stack,
.timeline-list,
.project-card-list,
.risk-board {
  display: grid;
  gap: 10px;
}

.project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.project-row:hover,
.project-card:hover {
  border-color: var(--line-strong);
  background: #fffefa;
}

.row-main strong,
.row-main span {
  display: block;
}

.row-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 310px;
}

.cafe-digest .mini-metrics,
.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mini-metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-metric span,
.digest-note strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

canvas {
  display: block;
  width: 100%;
  height: 164px;
}

.digest-note {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.digest-note span {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.attention-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.attention-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.attention-item.warn {
  background: #fff8f3;
  border-color: #f1d2bf;
}

.attention-item.decision {
  background: #fffaf0;
  border-color: #ead9a9;
}

.filter-select {
  min-height: 34px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.project-card.active {
  border-color: #a9bcae;
  background: #fbfdf9;
}

.project-card-main {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.project-title-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.project-title-line h3 {
  font-size: 16px;
}

.project-card-main p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.project-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 12px 0;
}

.project-detail {
  padding: 0;
  overflow: hidden;
}

.detail-cover {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.detail-cover h2 {
  margin-top: 4px;
}

.detail-cover p {
  max-width: 820px;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.detail-status {
  display: grid;
  gap: 10px;
  justify-items: end;
  min-width: 220px;
}

.detail-grid,
.report-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.detail-sections {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.info-block,
.copy-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.copy-panel .copy-block {
  padding: 0;
  border: 0;
  background: transparent;
}

.copy-block h3,
.info-block h3 {
  margin-bottom: 8px;
  color: var(--green);
}

.copy-block p {
  color: #4f5d55;
  font-size: 14px;
  line-height: 1.7;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
  font-size: 14px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

.soft-table {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.soft-table-head,
.soft-table-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(120px, 1fr);
  min-width: 100%;
}

.soft-table-head {
  background: #f3f2ec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.soft-table-head span,
.soft-table-row span {
  padding: 11px 12px;
  border-right: 1px solid var(--line);
}

.soft-table-row {
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
}

.timeline-item,
.report-card,
.risk-card {
  position: relative;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.timeline-item > span,
.report-card-head span,
.risk-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.timeline-item strong,
.timeline-item p,
.timeline-item em {
  display: block;
  margin-top: 6px;
}

.timeline-item p {
  color: var(--muted);
  line-height: 1.6;
}

.timeline-item.warn,
.risk-card {
  background: #fffefa;
}

.timeline-item em,
.decision-note {
  padding: 9px 10px;
  border-radius: 7px;
  background: var(--yellow-bg);
  color: var(--yellow);
  font-size: 13px;
  font-style: normal;
}

.report-card-head,
.risk-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.report-card h3,
.risk-card h3 {
  margin-top: 4px;
  font-size: 16px;
}

.risk-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

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

.risk-card dl {
  margin-top: 12px;
}

.risk-card.decision {
  border-color: #ead9a9;
  background: #fffaf0;
}

.decision-note {
  margin-top: 12px;
}

.cafe-hero {
  background: #f6f1eb;
}

.cafe-metrics .summary-card {
  background: #fffdf8;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chart-card {
  min-height: 224px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.chart-card h3 {
  margin-bottom: 10px;
}

.export-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.progress {
  display: block;
  width: 112px;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7e1;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green-2);
}

.progress-text {
  min-width: 34px;
  color: var(--muted);
  font-size: 12px;
}

.status.未開始 {
  color: #68716c;
  background: #eceeea;
}

.status.進行中 {
  color: var(--bluegreen);
  background: #e5f1ef;
}

.status.待確認 {
  color: var(--yellow);
  background: var(--yellow-bg);
}

.status.延遲 {
  color: var(--orange);
  background: var(--orange-bg);
}

.status.已完成 {
  color: #174f34;
  background: #dff0e4;
}

.tag.warn {
  color: var(--orange);
  background: var(--orange-bg);
}

.tag.decision {
  color: var(--yellow);
  background: var(--yellow-bg);
}

.muted {
  color: var(--muted);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.6;
}

.dialog {
  width: min(900px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(28, 37, 33, 0.42);
}

.dialog-card {
  display: grid;
  gap: 16px;
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 20px;
  background: var(--surface);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field span {
  color: #455149;
  font-size: 13px;
  font-weight: 720;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

.field textarea {
  min-height: 94px;
  resize: vertical;
}

.form-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 720;
}

.inline-actions {
  display: inline-flex;
  gap: 6px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.18s ease;
}

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

.skeleton {
  min-height: 136px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eeece5, #f8f7f2, #eeece5);
  background-size: 220% 100%;
  animation: pulse 1.1s ease-in-out infinite;
}

.skeleton.wide {
  min-height: 160px;
}

.skeleton.tall {
  min-height: 360px;
}

@keyframes pulse {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@media (max-width: 1180px) {
  .metric-grid,
  .chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .cafe-layout,
  .risk-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 18px;
  }

  .content {
    padding: 18px;
  }

  .report-hero,
  .cafe-hero,
  .section-head,
  .project-title-line,
  .project-footer,
  .detail-cover,
  .export-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .metric-grid,
  .brief-grid,
  .detail-grid,
  .report-columns,
  .form-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .project-row,
  .project-card {
    grid-template-columns: 1fr;
  }

  .row-meta,
  .detail-status {
    justify-content: flex-start;
    justify-items: start;
    min-width: 0;
  }

  .card-actions {
    padding: 0 14px 14px;
  }
}
