:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --line: #d7ddd9;
  --line-strong: #aeb9b3;
  --text: #1c2522;
  --muted: #66716d;
  --teal: #247c78;
  --teal-dark: #175a56;
  --green: #496b2f;
  --brown: #5b3b2e;
  --red: #c7382f;
  --blue: #2f7faa;
  --amber: #b7791f;
  --done: #277149;
  --open: #a65d14;
  --danger: #b7332c;
  --shadow: 0 12px 28px rgba(32, 46, 40, 0.08);
  font-family: "Pretendard", "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

body.editor-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.board-header,
.summary-bar,
.editor-panel,
.schedule-panel,
.calendar-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.title-block h1,
.panel-head h2,
.calendar-toolbar h2,
.detail-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.title-block h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.meta-row span,
.save-state {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  background: #f7f9f8;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button,
.icon-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-weight: 800;
}

.button {
  padding: 0 12px;
}

.button--primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.button--ghost {
  background: #f8faf9;
}

.button--danger {
  background: #fff6f5;
  border-color: #dbaaa6;
  color: var(--danger);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.page-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.stat-block {
  min-height: 78px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.stat-block:last-child {
  border-right: 0;
}

.stat-block span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-block strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.stat-subline {
  display: block;
  margin-top: 7px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  word-break: keep-all;
}

.editor-panel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(24, 34, 31, 0.46);
  border: 0;
  border-radius: 0;
}

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

.editor-card {
  width: min(1180px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(10, 22, 18, 0.24);
}

.editor-head,
.step-editor__head,
.form-actions,
.detail-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.editor-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.editor-head h2 {
  margin: 0;
  font-size: 20px;
}

.editor-head__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.editor-saved-flag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #e7f5ec;
  color: #1f7a44;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  animation: savedFlagIn 0.18s ease;
}

@keyframes savedFlagIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.editor-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.editor-summary span {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-right: 1px solid var(--line);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.editor-summary span:last-child {
  border-right: 0;
}

.schedule-form {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(520px, 1.45fr);
  gap: 16px;
  padding: 16px 18px 18px;
  align-items: start;
}

.schedule-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.schedule-form input,
.schedule-form select,
.schedule-form textarea {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.schedule-form textarea {
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.45;
}

.form-section,
.step-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-section {
  padding: 14px;
}

.form-section__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 30px;
  margin-bottom: 10px;
}

.form-section__head strong,
.step-editor__head strong {
  font-size: 14px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

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

.step-editor {
  min-width: 0;
  padding: 0;
}

.step-editor__head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.step-editor__head div {
  display: grid;
  gap: 3px;
}

.step-editor__head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.step-table-head,
.step-row {
  display: grid;
  grid-template-columns: 44px minmax(126px, 0.95fr) minmax(160px, 1.25fr) minmax(104px, 0.75fr) 66px 118px;
  gap: 8px;
  align-items: center;
}

.step-table-head {
  min-height: 36px;
  padding: 0 12px;
  background: #f3f6f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  border-bottom: 1px solid var(--line);
}

.step-rows {
  display: grid;
}

.step-row {
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.step-row:last-child {
  border-bottom: 0;
}

.step-row label {
  gap: 4px;
}

.step-index {
  height: 28px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 6px;
  background: #edf7f6;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 900;
  cursor: grab;
  user-select: none;
}

.step-index:active {
  cursor: grabbing;
}

.step-index b {
  font-size: 12px;
}

.step-row.dragging {
  opacity: 0.45;
}

.step-row.drag-over {
  background: #eef6f1;
  outline: 2px dashed var(--teal-dark, #2f6b4f);
  outline-offset: -2px;
  border-radius: 6px;
}

.step-row input[type="hidden"] {
  display: none;
}

.step-row-dday {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.step-row-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
  align-items: center;
}

.step-row-actions .mini-button {
  min-width: 30px;
  padding: 0 7px;
}

.form-actions {
  grid-column: 1 / -1;
  position: sticky;
  bottom: 0;
  z-index: 2;
  justify-content: flex-end;
  padding-top: 2px;
  background: var(--surface);
}

.work-area {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.schedule-panel,
.calendar-panel,
.detail-panel {
  min-width: 0;
}

.schedule-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  max-height: calc(100vh - 188px);
}

.product-filter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface);
}

.product-filter__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.pf-reset {
  border: 1px solid var(--line);
  background: #f7f9f8;
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}

.pf-reset.is-active {
  background: var(--accent, #2f6b4f);
  color: #fff;
  border-color: transparent;
}

.product-filter__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 132px;
  overflow-y: auto;
}

.pf-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 5px 11px 5px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.pf-chip small {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
}

.pf-chip:hover {
  border-color: var(--accent, #2f6b4f);
}

.pf-chip .pf-check {
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  color: #fff;
  flex-shrink: 0;
}

.pf-chip.is-on {
  background: #eef6f1;
  border-color: var(--accent, #2f6b4f);
  color: #1f5a3f;
}

.pf-chip.is-on .pf-check {
  background: var(--accent, #2f6b4f);
  border-color: var(--accent, #2f6b4f);
}

.pf-chip.is-on small {
  color: #3f7a5f;
}

.panel-head,
.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-head h2,
.calendar-toolbar h2,
.detail-title h2 {
  font-size: 20px;
}

.panel-head select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 0 8px;
  font-weight: 700;
}

.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: #fff;
}

.schedule-list {
  display: block;
  overflow: auto;
  padding-right: 4px;
}

.schedule-card {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  overflow: visible;
}

.schedule-card + .schedule-card {
  margin-top: 10px;
}

.schedule-card.is-selected {
  border-color: var(--teal);
  outline: 2px solid rgba(36, 124, 120, 0.16);
}

.schedule-card__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
}

.card-select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.schedule-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.card-head-channel {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  vertical-align: middle;
}

.event-chip .chip-channel {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.7;
}

.schedule-card__tools {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mini-button {
  min-height: 30px;
  border: 1px solid var(--line);
  background: #f8faf9;
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.status-pill {
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
}

.status-pill.is-open {
  background: var(--open);
}

.status-pill.is-done {
  background: var(--done);
}

.dday-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 7px;
  min-height: 26px;
  border-radius: 5px;
  padding: 3px 7px;
  background: #edf7f6;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.schedule-card__body {
  padding: 0 12px 12px;
}

.schedule-card__body[hidden] {
  display: none;
}

.schedule-card__meta {
  display: grid;
  gap: 4px;
  margin: 9px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.progress-track {
  height: 8px;
  background: #edf1ef;
  border-radius: 999px;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-detail {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.card-memo {
  border-left: 3px solid var(--line-strong);
  padding-left: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.card-step-list {
  display: grid;
  gap: 6px;
}

.card-step-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf9;
  padding: 7px 8px;
}

.card-step-item input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.card-step-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.card-step-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-step-dday {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.calendar-panel {
  padding: 16px;
  min-height: 640px;
}

.month-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
}

.weekday-row {
  margin-top: 12px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  overflow: hidden;
  border-radius: 7px 7px 0 0;
}

.weekday-row span {
  min-height: 34px;
  display: grid;
  place-items: center;
  background: var(--brown);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 13px;
  font-weight: 900;
}

.weekday-row span:last-child {
  border-right: 0;
}

.weekday-row .sunday {
  background: var(--red);
}

.weekday-row .saturday {
  background: var(--blue);
}

.calendar-grid {
  border-left: 1px solid var(--line-strong);
  border-top: 1px solid var(--line-strong);
}

.calendar-day {
  min-height: 116px;
  background: #fff;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  padding: 7px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 5px;
}

.calendar-day.is-muted {
  background: #f1f3f2;
  color: #b1b9b5;
}

.calendar-day.is-today {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.day-number {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: center;
  font-weight: 900;
  font-size: 13px;
}

.day-number .holiday {
  color: var(--red);
  font-size: 11px;
  line-height: 1.2;
}

.event-stack {
  display: grid;
  gap: 4px;
  align-content: start;
}

.event-chip {
  width: 100%;
  border: 0;
  border-left: 4px solid var(--teal);
  background: #edf7f6;
  color: var(--text);
  border-radius: 5px;
  padding: 5px 6px;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.event-chip small {
  display: inline-block;
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
}

.event-chip[data-kind="생산"] {
  border-left-color: var(--green);
  background: #eff5eb;
}

.event-chip[data-kind="발주"] {
  border-left-color: var(--red);
  background: #fff0ef;
}

.event-chip[data-kind="선적"] {
  border-left-color: var(--blue);
  background: #eef6fa;
}

.event-chip[data-kind="검역"] {
  border-left-color: var(--amber);
  background: #fff6e8;
}

.event-chip[data-kind="통관"] {
  border-left-color: var(--brown);
  background: #f5efec;
}

.event-chip[data-kind="입고"] {
  border-left-color: var(--teal);
}

.event-chip[data-kind="출시"] {
  border-left-color: var(--red);
  background: #fff0ef;
}

.event-chip.is-done {
  opacity: 0.7;
}

.detail-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.6fr);
  gap: 14px;
  padding: 16px;
}

.detail-panel.is-collapsed .detail-notes,
.detail-panel.is-collapsed .timeline {
  display: none;
}

.detail-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.detail-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.detail-title p {
  margin: 7px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.detail-notes {
  display: grid;
  gap: 7px;
}

.note-row {
  border-left: 3px solid var(--line-strong);
  padding-left: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-content: start;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.timeline-item label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 42px;
}

.timeline-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.timeline-item strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.timeline-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline-item .dday-text {
  color: var(--teal-dark);
  display: inline;
  margin-top: 0;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 1180px) {
  .work-area,
  .detail-panel {
    grid-template-columns: 1fr;
  }

  .schedule-form {
    grid-template-columns: 1fr;
  }

  .step-table-head,
  .step-row {
    grid-template-columns: 40px minmax(120px, 0.95fr) minmax(160px, 1.3fr) minmax(96px, 0.75fr) 62px 112px;
  }

  .schedule-panel {
    max-height: none;
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .weekday-row,
  .calendar-grid {
    min-width: 840px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .board-header {
    display: grid;
  }

  .header-actions {
    justify-content: flex-start;
  }

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

  .editor-panel {
    padding: 8px;
  }

  .editor-card {
    max-height: calc(100vh - 16px);
  }

  .editor-head,
  .editor-summary,
  .schedule-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .editor-summary span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-summary span:last-child {
    border-bottom: 0;
  }

  .step-table-head {
    display: none;
  }

  .step-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .step-row-actions {
    justify-content: flex-start;
  }

  .stat-block:nth-child(2n) {
    border-right: 0;
  }

  .stat-block:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}
