:root {
  --bg: #f4efe4;
  --panel: rgba(255, 252, 246, 0.94);
  --panel-strong: #fffaf0;
  --line: #dccfb7;
  --text: #29231a;
  --muted: #776c5d;
  --accent: #135d66;
  --danger: #b9382f;
  --shadow: 0 14px 36px rgba(61, 45, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 32%),
    linear-gradient(135deg, #efe4cf 0%, #f6f2ea 42%, #e4efe9 100%);
  min-height: 100vh;
  scrollbar-gutter: stable;
}

body.modal-open {
  overflow: hidden;
}

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

.shell {
  padding: 24px;
}

.topbar,
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(131, 110, 76, 0.13);
}

.title h1,
.settings-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.title p,
.settings-header p,
.muted {
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.button,
.icon-button {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: filter 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}

.button:hover {
  filter: brightness(1.08);
}

.button.secondary,
.icon-button {
  background: rgba(234, 223, 202, 0.9);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(61, 45, 18, 0.08);
  border: 1px solid rgba(131, 110, 76, 0.14);
}

.button.secondary:hover,
.icon-button:hover {
  background: rgba(220, 207, 183, 0.95);
  filter: none;
}

.filters,
.range-panel,
.settings-card,
.sidebar,
.board {
  background: var(--panel);
  border: 1px solid rgba(131, 110, 76, 0.15);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.settings-card {
  padding: 18px;
  overflow-x: auto;
}

.filters {
  display: grid;
  gap: 20px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.range-panel {
  padding: 16px 20px;
  margin-bottom: 16px;
}

.range-panel-card {
  display: grid;
  gap: 16px;
}

.range-panel-card.compact {
  gap: 10px;
}

.range-panel-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.range-panel-main.compact {
  gap: 8px;
}

.range-panel-main h3,
.orders-table-header h3 {
  margin: 0;
  font-size: 20px;
}

.range-panel-main p,
.orders-table-header p,
.range-summary span {
  margin: 6px 0 0;
  color: var(--muted);
}

.range-panel-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.range-panel-fields.compact {
  grid-template-columns: repeat(3, minmax(140px, auto)) minmax(220px, 1fr);
  gap: 10px;
}

.range-summary {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid rgba(125, 110, 80, 0.12);
}

.range-summary strong {
  font-size: 15px;
}

.compact-button {
  padding: 10px 14px;
  min-height: 44px;
}

.collapsible-panel {
  transition: opacity 160ms ease, transform 160ms ease;
}

.collapsible-panel.is-hidden {
  display: none;
}

.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(245, 235, 216, 0.9);
  border: 1px solid rgba(131, 110, 76, 0.12);
  font-size: 13px;
  cursor: pointer;
  transition: background 100ms ease;
}

.chip:hover {
  background: rgba(234, 220, 196, 0.95);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.layout.single-column {
  grid-template-columns: minmax(0, 1fr);
}

.board,
.sidebar {
  padding: 20px 22px;
}

.summary-toggle {
  padding: 8px 14px;
  border-radius: 999px;
}

.board-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-row {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.summary-row.is-hidden {
  display: none;
}

.summary-section,
.filter-section {
  display: grid;
  gap: 10px;
}

.summary-section-title,
.filter-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #786750;
}

.summary-section-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group {
  display: grid;
  gap: 12px;
}

.filter-group > span {
  font-weight: 700;
  color: #786750;
}

.filter-section {
  padding-top: 10px;
  border-top: 1px solid rgba(125, 110, 80, 0.12);
}

.filter-section:first-child,
.summary-section:first-child {
  padding-top: 0;
  border-top: none;
}

.gantt-help {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.load-pill {
  padding: 8px 10px;
  background: #edf3ef;
  border-radius: 999px;
  color: #245247;
}

.load-pill.overload {
  background: #fbe8e5;
  color: var(--danger);
}

.gantt-table {
  display: flex;
  border: 1px solid rgba(125, 110, 80, 0.12);
  border-radius: 12px;
  overflow: hidden;
}

.gantt-left {
  flex-shrink: 0;
  width: 420px;
  border-right: 2px solid rgba(125, 110, 80, 0.18);
}

.gantt-right {
  flex: 1;
  overflow-x: auto;
  min-width: 0;
}

.gantt-fixed-header {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  background: rgba(248, 243, 232, 0.92);
  border-bottom: 1px solid rgba(125, 110, 80, 0.12);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gantt-fixed {
  height: 168px;
  padding: 14px;
  border-bottom: 1px solid rgba(125, 110, 80, 0.12);
  background: rgba(255, 250, 240, 0.86);
  overflow: hidden;
}

.gantt-scroll-header,
.gantt-scroll-row {
  display: grid;
  grid-template-columns: repeat(var(--gantt-columns, 14), 64px);
}

.gantt-scroll-header {
  border-bottom: 1px solid rgba(125, 110, 80, 0.12);
}

.gantt-scroll-row {
  border-bottom: 1px solid rgba(125, 110, 80, 0.12);
  position: relative;
}

.gantt-day-header {
  height: 52px;
  border-right: 1px solid rgba(125, 110, 80, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
  background: rgba(248, 243, 232, 0.92);
}

.gantt-cell {
  height: 168px;
  border-right: 1px solid rgba(125, 110, 80, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 0;
  pointer-events: none;
}

.order-meta {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  height: 100%;
}

.meta-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.gantt-del {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
}

.gantt-del:hover {
  color: var(--danger);
}

.meta-end {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.meta-timing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1 1 180px;
}

.meta-plan-hours {
  font-size: 12px;
  color: #6f624f;
  white-space: nowrap;
}

.meta-adjustment-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.meta-adjustment-field span {
  margin: 0;
  white-space: nowrap;
}

.meta-adjustment-field input {
  width: 92px;
  padding: 4px 8px;
  border-radius: 999px;
}

.bar-buffer {
  width: 28px;
  height: 6px;
  border-radius: 4px;
  opacity: 0.25;
  margin-bottom: 4px;
}

.meta-order {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.45;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  text-overflow: clip;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.meta-order::-webkit-scrollbar {
  display: none;
}

.meta-product {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  text-overflow: clip;
  scrollbar-width: none;
}

.meta-product::-webkit-scrollbar {
  display: none;
}

.meta-note-stack {
  display: grid;
  gap: 6px;
  max-height: 58px;
  overflow: auto;
}

.meta-note-item {
  font-size: 11px;
  line-height: 1.35;
  color: #6a5842;
  background: rgba(232, 221, 199, 0.55);
  border: 1px dashed rgba(125, 110, 80, 0.2);
  border-radius: 10px;
  padding: 5px 7px;
}

.meta-note-item-primary {
  background: rgba(227, 238, 232, 0.78);
  border-style: solid;
  border-color: rgba(54, 110, 77, 0.18);
}

.meta-note-item span {
  display: block;
  color: var(--muted);
  margin-bottom: 2px;
}

.meta-note-item strong {
  display: block;
  font-weight: 600;
  white-space: pre-wrap;
}

.meta-footer {
  display: grid;
  gap: 8px;
  min-height: 56px;
}

.meta-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.meta-footer-detail {
  align-items: flex-start;
}

.meta-footer-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.meta-line-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.meta-line-switch span {
  margin: 0;
}

.meta-line-switch select {
  width: auto;
  min-width: 88px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.92);
}

.meta-note-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 12px;
  color: var(--accent);
  background: rgba(19, 93, 102, 0.08);
  border: 1px solid rgba(19, 93, 102, 0.12);
  white-space: nowrap;
}

.meta-note-link:hover {
  background: rgba(19, 93, 102, 0.14);
}

.line-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
}

.line-badge {
  color: white;
}

.status-active {
  background: #e6f1fb;
  color: #185fa5;
}

.status-pending {
  background: #f1efe8;
  color: #5f5e5a;
}

.status-done {
  background: #eaf3de;
  color: #3b6d11;
}

.bar-pending {
  opacity: 0.4;
}

.gantt-bar-block {
  position: absolute;
  top: 14px;
  left: var(--bar-left);
  width: var(--bar-width);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  z-index: 2;
}

.gantt-bar-meta {
  font-size: 11px;
  line-height: 1;
  color: #6f624f;
  white-space: nowrap;
}

.gantt-bar-surface {
  height: 22px;
  flex: 1;
  min-width: 18px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: color-mix(in srgb, var(--bar-color) 88%, white);
  border: 1px solid color-mix(in srgb, var(--bar-color) 85%, black 8%);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.gantt-bar-title {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: #12485b;
  font-weight: 700;
}

.bar-label {
  margin-top: auto;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
}

.panel {
  background: rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(41, 35, 26, 0.28);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-card {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: rgba(255, 252, 246, 0.98);
  border: 1px solid rgba(131, 110, 76, 0.16);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(61, 45, 18, 0.22);
  padding: 22px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 28px;
}

.modal-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.modal-close {
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 24px;
  border-radius: 999px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.note-sheet {
  background: rgba(244, 238, 225, 0.72);
  border: 1px solid rgba(131, 110, 76, 0.14);
  border-radius: 18px;
  padding: 14px;
}

.note-sheet-header {
  margin-bottom: 12px;
}

.note-sheet-header h4 {
  margin: 0;
  font-size: 16px;
}

.note-sheet-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.note-grid .wide {
  grid-column: span 2;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.stack.two {
  grid-template-columns: 1fr 1fr;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-strong);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(19, 93, 102, 0.4);
  box-shadow: 0 0 0 3px rgba(19, 93, 102, 0.08);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.order-list {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.order-card {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.86);
}

.footer-note,
.empty-state {
  margin-top: 12px;
  color: var(--muted);
}

.orders-table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.orders-table-header h2 {
  margin: 0;
  font-size: 22px;
}

.orders-table-wrap {
  overflow: auto;
  border: 1px solid rgba(125, 110, 80, 0.12);
  border-radius: 16px;
  background: rgba(255, 252, 246, 0.88);
}

.orders-table {
  min-width: 1180px;
}

.orders-table th {
  position: sticky;
  top: 0;
  background: #f6efe1;
  z-index: 1;
}

.orders-table td {
  vertical-align: middle;
}

.orders-table input,
.orders-table select {
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 10px;
}

.cell-product {
  min-width: 220px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-link,
.danger-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid rgba(19, 93, 102, 0.12);
  background: rgba(19, 93, 102, 0.08);
  color: var(--accent);
  cursor: pointer;
}

.danger-link {
  border-color: rgba(185, 56, 47, 0.16);
  background: rgba(185, 56, 47, 0.08);
  color: var(--danger);
}

.table-empty {
  text-align: center;
  color: var(--muted);
}

.note-page-shell {
  max-width: 1080px;
  margin: 0 auto;
}

.note-page-grid {
  display: grid;
  gap: 18px;
}

.note-summary-card,
.note-fields-card {
  background: var(--panel);
  border: 1px solid rgba(131, 110, 76, 0.15);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.note-summary-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.note-summary-header h2,
.note-fields-card h2 {
  margin: 0;
  font-size: 24px;
}

.note-summary-header p,
.note-fields-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.note-meta-item {
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid rgba(125, 110, 80, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
}

.note-meta-item span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.note-meta-item strong {
  display: block;
  line-height: 1.45;
}

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

.note-basic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.note-basic-grid .wide {
  grid-column: span 2;
}

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

.note-field-edit {
  cursor: default;
}

.note-edit-input {
  width: 100%;
}

.note-edit-textarea {
  min-height: 120px;
}

.note-field-card {
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid rgba(125, 110, 80, 0.12);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 96px;
}

.note-field-card.wide {
  grid-column: span 2;
}

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

.note-field-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.note-field-card strong {
  display: block;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-field-card.is-empty strong {
  color: #ab9d88;
  font-weight: 500;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(125, 110, 80, 0.12);
}

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

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .range-panel-main,
  .filters,
  .settings-header {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar,
  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .note-grid {
    grid-template-columns: 1fr;
  }

  .range-panel-fields {
    grid-template-columns: 1fr;
  }

  .range-panel-fields.compact {
    grid-template-columns: 1fr;
  }

  .note-grid .wide,
  .note-grid .full {
    grid-column: auto;
  }

  .note-fields-grid,
  .note-summary-meta,
  .note-basic-grid {
    grid-template-columns: 1fr;
  }

  .note-field-card.wide,
  .note-field-card.full,
  .note-basic-grid .wide {
    grid-column: auto;
  }

  .note-summary-header,
  .meta-footer-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .meta-timing {
    align-items: flex-start;
  }

  .gantt-left {
    width: 300px;
  }

  .stack.two {
    grid-template-columns: 1fr;
  }
}
