:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-strong: #eef4ee;
  --ink: #1f2a24;
  --muted: #68736d;
  --line: #dfe6de;
  --brand: #315744;
  --brand-2: #c8913c;
  --accent: #27727d;
  --danger: #b54848;
  --warning: #9b6b22;
  --ok: #2f7554;
  --shadow: 0 12px 30px rgba(31, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

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

.sidebar {
  background: #24342d;
  color: #f7fbf6;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 18px;
}

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

.brand span:not(.brand-mark) {
  display: block;
  color: #cdd8d1;
  font-size: 13px;
  margin-top: 2px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand-2);
  color: #17231d;
  font-size: 20px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-group-label {
  margin: 14px 8px 2px;
  color: #aebbb5;
  font-size: 12px;
  font-weight: 800;
}

.nav-item {
  border: 0;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  background: transparent;
  color: #d7e0dc;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.main {
  padding: 26px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-2);
  font-weight: 700;
  font-size: 13px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.top-actions,
.report-tools,
.toolbar-panel,
.inline-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.date-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.env-pill.production {
  border-color: #d68b72;
  background: #fff0eb;
  color: var(--danger);
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 6px 0 12px;
}

.section-heading p,
.panel-title p {
  color: var(--muted);
  margin-bottom: 0;
}

.split-heading {
  margin-top: 28px;
}

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

.metric-grid.cafe {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin: 16px 0;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 104px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  font-size: 24px;
}

.metric small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.list-panel {
  margin-bottom: 0;
}

.mini-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.75;
}

.quick-actions {
  margin-top: 16px;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  margin-bottom: 0;
}

.form-panel label,
.toolbar-panel label,
.report-tools label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 39px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(39, 114, 125, 0.22);
  border-color: var(--accent);
}

.form-panel {
  display: grid;
  gap: 12px;
}

.form-mode {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-mode.editing {
  color: var(--warning);
}

.wide-form {
  margin-bottom: 16px;
}

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

.filter-panel {
  background: #fbfcfa;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.checkbox-line {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 39px;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

.btn {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  min-height: 39px;
  padding: 9px 13px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--accent);
}

.btn-danger {
  background: var(--danger);
}

.btn-ghost {
  background: var(--panel-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-small {
  min-height: 31px;
  padding: 6px 9px;
  font-size: 13px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.segmented-btn {
  border: 0;
  min-height: 38px;
  padding: 8px 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.segmented-btn.active {
  background: var(--brand);
  color: #fff;
}

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

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

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

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f8faf7;
  font-size: 12px;
  letter-spacing: 0;
}

td.actions {
  white-space: nowrap;
}

.project-group-row td {
  background: #eef5ef;
  border-bottom-color: #d5e2d8;
  padding: 0;
}

.project-group-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.project-group-toggle strong {
  font-size: 15px;
}

.project-group-toggle span:not(.icon-btn) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.not_started {
  background: #eef1ef;
  color: #59645d;
}

.status.in_progress {
  background: #e4f2f5;
  color: #226671;
}

.status.completed {
  background: #e4f3ea;
  color: var(--ok);
}

.status.overdue {
  background: #f9e7e4;
  color: var(--danger);
}

.source-tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f2eadc;
  color: #7b5620;
  font-size: 12px;
  font-weight: 800;
}

.report-panel {
  max-width: 1100px;
}

.report-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0;
}

.report-editor {
  width: 100%;
  min-height: 520px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}

.gantt-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.gantt-toolbar p,
.warning-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.gantt-save-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-color: #e3c780;
  background: #fff9e8;
}

.gantt-panel {
  padding: 0;
  overflow: hidden;
}

.gantt-chart {
  position: relative;
  overflow: auto;
  max-height: 72vh;
}

.gantt-grid {
  display: grid;
  grid-template-columns: minmax(560px, 640px) max-content;
  min-width: max-content;
  isolation: isolate;
}

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

.gantt-header-info,
.gantt-header-line {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8faf7;
}

.gantt-info {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) 48px 86px 86px 64px 42px minmax(40px, 0.55fr);
  gap: 6px;
  align-items: center;
  min-height: 54px;
  padding: 8px;
  border-right: 1px solid var(--line);
  font-size: 13px;
  position: sticky;
  left: 0;
  z-index: 12;
  background: #fff;
}

.gantt-header-info {
  z-index: 30;
}

.gantt-info span {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.gantt-row-info.indent-1 strong {
  padding-left: 18px;
}

.gantt-row-info.indent-2 strong {
  padding-left: 36px;
}

.gantt-name {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
  line-height: 1.35;
}

.gantt-name span {
  white-space: normal;
  overflow-wrap: anywhere;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.tree-spacer {
  width: 24px;
  flex: 0 0 24px;
}

.gantt-timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--gantt-cols), var(--gantt-cell));
  min-height: 54px;
  z-index: 1;
  background: #fff;
}

.gantt-header-line {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f8faf7;
}

.gantt-date-cell,
.gantt-cell {
  border-right: 1px solid #e8eee7;
}

.gantt-date-cell {
  display: grid;
  place-items: center;
  min-height: 54px;
  white-space: pre-line;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.gantt-bar {
  align-self: center;
  min-height: 20px;
  border-radius: 6px;
  padding: 2px 7px;
  color: #173029;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  z-index: 2;
  cursor: grab;
}

.gantt-bar.project {
  background: #b9d7c3;
}

.gantt-bar.milestone {
  background: #f2d28b;
}

.gantt-bar.task {
  background: #a8d2d8;
}

.gantt-bar.overdue {
  background: #efb0a7;
}

.gantt-bar.completed {
  background: #9ed0ad;
}

.actual-bar {
  align-self: end;
  min-height: 12px;
  margin-bottom: 6px;
  background: #486f86;
  color: #fff;
  cursor: default;
}

.gantt-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 1;
}

.today-marker {
  border-left: 2px solid #b54848;
}

.goal-marker {
  border-left: 2px dashed #c8913c;
}

.warning-panel {
  border-color: #e3c780;
  background: #fff9e8;
}

.backup-preview {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.backup-preview ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.system-status-panel {
  background: #f8faf7;
}

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

.system-status-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.system-status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.system-status-grid strong {
  display: block;
  font-size: 14px;
}

.backup-guidance ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.production-warning {
  border-color: #d68b72;
  background: #fff0eb;
}

.preview-blocked {
  color: var(--danger);
}

.preview-ok {
  color: var(--ok);
}

.mini-table {
  min-width: 0;
  margin: 10px 0;
}

.mini-table th,
.mini-table td {
  font-size: 13px;
  padding: 7px;
}

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

.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

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

.line-chart {
  width: 100%;
  min-height: 150px;
  background: linear-gradient(to bottom, #f8faf7 0 1px, transparent 1px 50px) repeat-y;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.line-chart polyline {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.revenue-line {
  stroke: var(--accent);
}

.target-line {
  stroke: var(--brand-2);
  stroke-dasharray: 7 7;
}

.chart-legend,
.chart-axis {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.legend-revenue::before,
.legend-target::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 4px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--accent);
}

.legend-target::before {
  background: var(--brand-2);
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-row div {
  height: 14px;
  border-radius: 999px;
  background: #eef4ee;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.print-report-view {
  display: none;
}

.toast {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  background: #22312b;
  color: #ffffff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: min(420px, calc(100vw - 48px));
}

.toast.show {
  display: block;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

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

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

  .main {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .work-grid {
    display: block;
  }

  .top-actions,
  .report-tools,
  .toolbar-panel {
    margin-top: 12px;
  }

  .metric-grid,
  .metric-grid.cafe,
  .metric-grid.compact,
  .system-status-grid,
  .form-grid,
  .filter-grid,
  .chart-grid,
  .dashboard-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

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

  .app-shell {
    display: block;
  }

  .sidebar,
  .topbar,
  .view,
  .toast {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .print-report-view {
    display: block;
    color: #111;
    padding: 24px;
  }

  .print-report-view h1 {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .print-report-view p {
    color: #444;
    margin-bottom: 18px;
  }

  .print-report-view pre {
    white-space: pre-wrap;
    font: 14px/1.65 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  }
}
