* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', sans-serif;
  background: #f4f6fb;
  color: #1a1a2e;
  font-size: 14px;
  line-height: 1.5;
}
.sidebar {
  position: fixed; left: 0; top: 0;
  width: 200px; height: 100vh;
  background: #1a3d6b; color: #fff;
  padding: 0; z-index: 100;
  display: flex; flex-direction: column;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  font-size: 15px; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.sidebar-logo small {
  display: block; font-size: 10px;
  color: rgba(255,255,255,0.5); font-weight: 400; margin-top: 2px;
}
.sidebar-section {
  font-size: 10px; color: rgba(255,255,255,0.4);
  padding: 14px 16px 4px; letter-spacing: 0.5px;
}
.sidebar a {
  display: block; padding: 9px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none; font-size: 13px;
  transition: all 0.12s;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar a.active {
  background: rgba(255,255,255,0.13);
  color: #fff; border-left-color: #5b9bd5;
}
.main { margin-left: 200px; padding: 24px 28px; min-height: 100vh; width: calc(100% - 200px); }
.page-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 18px; font-weight: 700; color: #1a3d6b; }
.metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: #fff; border-radius: 10px;
  border: 1px solid #e8eaf0; padding: 14px 18px;
}
.metric-card .label { font-size: 11px; color: #888; margin-bottom: 6px; }
.metric-card .value { font-size: 28px; font-weight: 700; color: #1a3d6b; }
.metric-card .value.danger { color: #e74c3c; }
.metric-card .value.warn { color: #e67e22; }
.card {
  background: #fff; border-radius: 10px;
  border: 1px solid #e8eaf0; padding: 18px 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px; font-weight: 600;
  color: #555; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid #f0f2f8;
}
.form-grid { display: grid; gap: 12px; margin-bottom: 16px; }
.form-grid.col2 { grid-template-columns: 1fr 1fr; }
.form-grid.col3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.col4 { grid-template-columns: repeat(4, 1fr); }
.form-group label {
  display: block; font-size: 11px;
  color: #777; margin-bottom: 5px; font-weight: 500;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 10px;
  font-size: 13px; font-family: inherit;
  border: 1px solid #dde1ea; border-radius: 6px;
  background: #fff; color: #1a1a2e;
  transition: border-color 0.12s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: #1a3d6b;
  box-shadow: 0 0 0 3px rgba(26,61,107,0.08);
}
.btn {
  padding: 9px 18px; font-size: 13px;
  font-weight: 600; border-radius: 6px;
  cursor: pointer; border: none;
  transition: background 0.12s, opacity 0.12s;
  font-family: inherit;
}
.btn-primary { background: #1a3d6b; color: #fff; }
.btn-primary:hover { background: #153261; }
.btn-secondary {
  background: #f0f3f8; color: #1a3d6b;
  border: 1px solid #d0d8e8;
}
.btn-secondary:hover { background: #e4eaf4; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; color: #888; font-weight: 600;
  border-bottom: 2px solid #edf0f7;
  background: #fafbfd; white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid #f0f2f8; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafc; }
.badge {
  display: inline-block; padding: 3px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 600;
}
.badge-blue { background: #e8f0fe; color: #1a3d6b; }
.badge-green { background: #e6f9f0; color: #1a8a50; }
.badge-orange { background: #fff3e8; color: #c0670a; }
.badge-red { background: #fde8e8; color: #c0392b; }
.badge-gray { background: #f0f2f5; color: #666; }
.stock-bar {
  height: 5px; background: #eee;
  border-radius: 3px; overflow: hidden; margin-top: 4px;
}
.stock-bar-fill { height: 100%; border-radius: 3px; }
.fill-ok { background: #27ae60; }
.fill-warn { background: #f39c12; }
.fill-danger { background: #e74c3c; }
.order-line {
  border: 1px solid #e0e5f0;
  border-radius: 8px; padding: 14px 16px;
  margin-bottom: 10px; background: #fafbfd;
  position: relative;
}
.order-line-header {
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.line-num {
  background: #1a3d6b; color: #fff;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bom-preview {
  background: #f4f6fb; border-radius: 6px;
  padding: 10px 12px; margin-top: 10px;
  font-size: 12px;
}
.bom-row {
  display: flex; justify-content: space-between;
  gap: 12px;
  padding: 4px 0; border-bottom: 1px solid #eceef4;
}
.bom-row:last-child { border-bottom: none; }
.bom-shortage { color: #e74c3c; font-weight: 600; }
.bom-ok { color: #27ae60; }
.popup-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.popup-box {
  background: #fff; border-radius: 12px;
  width: 480px; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.popup-header {
  padding: 16px 20px; font-size: 15px;
  font-weight: 700; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
}
.popup-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.popup-close {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: #888; line-height: 1;
}
.popup-item {
  padding: 10px 12px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.popup-item:hover {
  background: #f0f4fb; border-color: #d0d8ee;
}
.popup-search {
  width: 100%; padding: 8px 10px; margin-bottom: 12px;
  border: 1px solid #dde1ea; border-radius: 6px;
  font-size: 13px;
}
.material-summary-row {
  display: flex; justify-content: space-between;
  align-items: center; padding: 8px 0;
  gap: 12px;
  border-bottom: 1px solid #f0f2f8;
}
.material-summary-row:last-child { border-bottom: none; }
.flex { display: flex; gap: 8px; align-items: center; }
.space-between { display: flex; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.empty {
  color: #888; font-size: 12px;
  padding: 12px 0;
}
.inline-value {
  min-height: 37px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #dde1ea;
  border-radius: 6px;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
@media (max-width: 1024px) {
  .sidebar {
    position: static; width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap;
    align-items: center; padding-bottom: 8px;
  }
  .sidebar-logo, .sidebar-section { width: 100%; }
  .sidebar a { border-left: none; border-bottom: 2px solid transparent; }
  .sidebar a.active { border-left-color: transparent; border-bottom-color: #5b9bd5; }
  .main { margin-left: 0; width: 100%; padding: 16px; }
  .metrics, .form-grid.col4, .form-grid.col3, .form-grid.col2 { grid-template-columns: 1fr; }
  .space-between { flex-direction: column; align-items: stretch; }
  .flex { flex-wrap: wrap; }
  .popup-box { width: min(480px, calc(100vw - 24px)); }
}
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: #1a3d6b;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.link-button:hover {
  text-decoration: underline;
}
.popup-box-lg {
  width: min(920px, calc(100vw - 24px));
}
.popup-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.popup-meta-card {
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}
.popup-meta-card .label {
  font-size: 11px;
  color: #7f8a9a;
  margin-bottom: 4px;
}
.popup-meta-card .value {
  font-size: 13px;
  font-weight: 600;
  color: #1a3d6b;
}
.popup-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.shortage-qty {
  color: #c0392b;
  font-weight: 700;
}
@media (max-width: 1024px) {
  .popup-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .popup-meta-grid {
    grid-template-columns: 1fr;
  }
}
.order-header-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.order-header-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.order-header-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-start;
}
@media (max-width: 1024px) {
  .order-header-row {
    grid-template-columns: 1fr;
  }
  .order-header-actions {
    flex-wrap: wrap;
  }
}
.timeline-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #dde1ea;
  border-radius: 6px;
  background: #fff;
  color: #1a1a2e;
}
.timeline-input:focus {
  outline: none;
  border-color: #1a3d6b;
  box-shadow: 0 0 0 3px rgba(26,61,107,0.08);
}
